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>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package infra
|
|
|
|
import "fmt"
|
|
|
|
// ReportSection es una seccion de un reporte PDF simple.
|
|
// Contiene un titulo, texto descriptivo y una tabla opcional.
|
|
type ReportSection struct {
|
|
Title string
|
|
Text string
|
|
Table *ReportTable
|
|
}
|
|
|
|
// ReportTable es una tabla opcional dentro de una seccion de reporte.
|
|
type ReportTable struct {
|
|
Headers []string
|
|
Rows [][]string
|
|
}
|
|
|
|
// PdfSimpleReport genera un PDF simple con titulo, secciones y tablas opcionales.
|
|
//
|
|
// Stub: requiere go-pdf/fpdf que no esta en el modulo. Para generar PDFs
|
|
// desde Go usar la alternativa Python (pdf_create_py_infra + pdf_add_table_py_infra
|
|
// + pdf_save_py_infra) o añadir go-pdf/fpdf al go.mod.
|
|
//
|
|
// Para usar la implementacion real:
|
|
//
|
|
// go get github.com/go-pdf/fpdf
|
|
//
|
|
// y reemplazar el cuerpo de esta funcion con la implementacion completa.
|
|
func PdfSimpleReport(title string, sections []ReportSection, outputPath string) (string, error) {
|
|
return "", fmt.Errorf(
|
|
"not implemented: pdf_simple_report requires go-pdf/fpdf. "+
|
|
"Add it with: go get github.com/go-pdf/fpdf. "+
|
|
"Alternatively use pdf_create_py_infra + pdf_add_table_py_infra + pdf_save_py_infra for Python",
|
|
)
|
|
}
|