danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.86k stars 348 forks source link

Support for attachment files #974

Closed osnard closed 1 day ago

osnard commented 2 days ago

Is there a way to include arbitrary files as attachment? In IText, this could by done using com.lowagie.text.pdf.PdfFileSpecification.fileEmbedded. Does anyone know if this can be done with PDFBOX as well?

osnard commented 2 days ago

Apparently yes:

  1. https://github.com/apache/pdfbox/blob/bf0395200722bcaf3b910aebb6e3c972235a2a16/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java#L44
  2. https://github.com/danfickle/openhtmltopdf/blob/780ba564839f1ad5abfa5df12e4aebb9dd6782d2/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxFastLinkManager.java#L301
osnard commented 2 days ago

https://github.com/danfickle/openhtmltopdf/blob/780ba564839f1ad5abfa5df12e4aebb9dd6782d2/openhtmltopdf-pdfa-testing/src/test/resources/html/file-embed.html#L24-L32