0819c35bbb
Añade 3 tipos Python (PDFDoc, PDFPage, PDFStyle) y 10 funciones Python para construir PDFs con fpdf2 (builder fluent), fusionar PDFs con pypdf y convertir HTML/Markdown a PDF via weasyprint (stub si no disponible). Añade pdf_simple_report en Go como stub hasta que go-pdf/fpdf se integre. - python/types/infra/: pdf_doc, pdf_page, pdf_style - python/functions/infra/: pdf_create, pdf_add_page, pdf_add_text, pdf_add_table, pdf_add_image, pdf_add_header_footer, pdf_from_html, pdf_from_markdown, pdf_merge, pdf_save - functions/infra/pdf_simple_report.go: stub Go con ReportSection/ReportTable - 17 tests Python pasando (pytest) - fpdf2 y pypdf añadidos via uv al venv Python Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.2 KiB
2.2 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_create | function | py | infra | 1.0.0 | impure | def pdf_create(title, author, subject, default_font, margin_left, margin_right, margin_top, margin_bottom) -> PDFDoc | Inicializa un documento PDF nuevo usando fpdf2. Crea un objeto FPDF configurado con metadatos y margenes. Retorna un PDFDoc listo para añadir paginas con pdf_add_page. |
|
|
|
false | error_go_core |
|
|
PDFDoc inicializado con objeto fpdf2 configurado, listo para pdf_add_page | true |
|
python/functions/infra/pdf_create_test.py | python/functions/infra/pdf_create.py |
Ejemplo
import sys
sys.path.insert(0, "python/functions/infra")
sys.path.insert(0, "python/types/infra")
from pdf_create import pdf_create
from pdf_add_page import pdf_add_page
from pdf_save import pdf_save
doc = pdf_create(title="Mi Reporte", author="Agente")
doc = pdf_add_page(doc)
pdf_save(doc, "reporte.pdf")
Notas
Funcion impura: inicializa un objeto FPDF con estado mutable. Usa una subclase interna _PDFWithHeaderFooter que sobreescribe header() y footer() de FPDF para soportar header/footer recurrente configurado via pdf_add_header_footer. Los margenes se aplican con set_margins y set_auto_page_break. Requiere fpdf2 instalado (uv add fpdf2).