df424f2de0
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.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_header_footer | function | py | infra | 1.0.0 | impure | def pdf_add_header_footer(doc, header_text, footer_text, page_numbers) -> PDFDoc | Configura header y/o footer recurrente para todas las paginas del documento. Debe llamarse antes de pdf_add_page. El footer acepta {n} y {total} como placeholders para numeracion automatica. |
|
|
|
false | error_go_core |
|
PDFDoc con la configuracion de header/footer guardada; se aplica en cada pdf_add_page posterior | false | python/functions/infra/pdf_add_header_footer.py |
Ejemplo
doc = pdf_create(title="Reporte Mensual")
# Header con nombre del reporte, footer con numeracion
doc = pdf_add_header_footer(
doc,
header_text="Reporte de Ejecuciones — Abril 2026",
footer_text="Pagina {n} de {total}",
page_numbers=True,
)
# Las paginas añadidas despues tendran header y footer
doc = pdf_add_page(doc)
doc = pdf_add_text(doc, "Contenido...")
Notas
Internamente configura los campos header_text, footer_text y page_numbers del PDFDoc. La subclase _PDFWithHeaderFooter de pdf_create lee estos campos en sus metodos header() y footer() que fpdf2 llama automaticamente en cada add_page(). El alias {nb} de fpdf2 se activa via alias_nb_pages y fpdf2 lo reemplaza al renderizar el PDF final. Debe llamarse antes de cualquier pdf_add_page para que el header/footer se aplique a todas las paginas.