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.93k stars 359 forks source link

Support for attachment files #974

Closed osnard closed 4 months ago

osnard commented 4 months 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 4 months 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 4 months ago

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