47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.1 KiB
2.1 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pdf_add_image | function | py | infra | 1.0.0 | impure | def pdf_add_image(doc, image, x, y, width, height, keep_aspect) -> PDFDoc | Añade una imagen PNG o JPEG al documento PDF desde un path de archivo o bytes. Calcula automaticamente la dimension faltante si solo se especifica width o height para mantener la relacion de aspecto. |
|
|
|
false | error_go_core |
|
PDFDoc con la imagen embebida en la pagina activa | false | python/functions/infra/pdf_add_image.py |
Ejemplo
# Imagen desde path con ancho fijo (height automatico)
doc = pdf_add_image(doc, "assets/logo.png", x=15, y=10, width=40)
# Imagen desde bytes
with open("chart.png", "rb") as f:
img_bytes = f.read()
doc = pdf_add_image(doc, img_bytes, width=120)
# Imagen en posicion actual del cursor
doc = pdf_add_image(doc, "diagrama.png", width=fpdf_doc.fpdf.epw)
Notas
Soporta PNG y JPEG nativamente en fpdf2. Para bytes, usa io.BytesIO como wrapper. fpdf2 gestiona automaticamente la relacion de aspecto cuando solo se especifica una dimension (fpdf calcula la otra si h=0). El cursor se mueve 5mm debajo de la imagen tras insertarla. Para SVG necesitaria fpdf2[svg] como extra opcional.