Files
fn_registry/functions/infra/pdf_simple_report.md
T
egutierrez 0819c35bbb feat: issue/0020 — generacion de PDFs en Python y Go
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>
2026-04-13 02:02:51 +02:00

2.8 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_simple_report function go infra 1.0.0 impure func PdfSimpleReport(title string, sections []ReportSection, outputPath string) (string, error) Genera un PDF simple con titulo, secciones de texto y tablas opcionales. Stub activo: requiere go-pdf/fpdf que no esta en el modulo. Para PDFs desde Go añadir la dependencia; para casos complejos usar el builder Python.
pdf
report
go
stub
infra
false error_go_core
fmt
name desc
title titulo principal del reporte PDF, aparece en la cabecera del documento
name desc
sections lista de ReportSection, cada una con Title (string), Text (string) y Table opcional (*ReportTable con Headers y Rows)
name desc
outputPath ruta del archivo PDF a generar en disco
outputPath con el PDF generado, o string vacio + error si la dependencia no esta disponible false
functions/infra/pdf_simple_report.go

Tipos auxiliares

type ReportSection struct {
    Title string
    Text  string
    Table *ReportTable  // nil = sin tabla en esta seccion
}

type ReportTable struct {
    Headers []string
    Rows    [][]string
}

Ejemplo de uso

sections := []infra.ReportSection{
    {
        Title: "Estado del Registry",
        Text:  "El registry contiene 142 funciones, 38 tipos y 12 proposals pendientes.",
    },
    {
        Title: "Funciones por Dominio",
        Table: &infra.ReportTable{
            Headers: []string{"Dominio", "Funciones", "Tipos"},
            Rows: [][]string{
                {"core", "45", "12"},
                {"infra", "38", "8"},
                {"finance", "22", "6"},
            },
        },
    },
}

path, err := infra.PdfSimpleReport("Registry Status Report", sections, "registry_report.pdf")
if err != nil {
    log.Fatal(err)
}
fmt.Println("PDF generado:", path)

Activar la implementacion real

# Añadir dependencia al modulo Go
go get github.com/go-pdf/fpdf

# La funcion usa la API de go-pdf/fpdf:
# pdf := fpdf.New("P", "mm", "A4", "")
# pdf.AddPage()
# pdf.SetFont("Arial", "B", 16)
# pdf.Cell(0, 10, title)
# ... para cada seccion y tabla
# pdf.OutputFileAndClose(outputPath)

Notas

Stub activo: retorna fmt.Errorf("not implemented: ...") hasta que go-pdf/fpdf se añada al modulo. No añadida como dependencia directa porque solo la usa esta funcion y añade peso al modulo. Para generacion de PDFs desde el registry, la solucion recomendada es el builder Python (pdf_create_py_infra + pdf_add_text_py_infra + pdf_add_table_py_infra + pdf_save_py_infra) que es mas completo y no requiere dependencias adicionales en Go.