Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /AFRelationship and /Subtype to embedded files #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jenskutilek
Copy link

I'm working towards adding XML attachments with electronic invoices to PDFs in my rails app.

Trying to validate the generated PDFs, I found out I needed two things:

  • The /AFRelationship entry describing the relationship of the attachment to the PDF (/Alternative, /Data, /Source, /Supplement, /Unspecified)
  • The MIME type of the attachment, via the entry /Subtype, e.g. /text#2Fxml (representation of text/xml; default is application/octet-stream)

I just added those to the options:

attach "factur-x.xml", File.open("./factur-x.xml"),
               {
                 description: "Factur-X/ZUGFeRD-Rechnung",
                 relationship: :Alternative,
                 mime_type: "text/xml",
               }

The mime_type string is automatically converted to a symbol.

@jenskutilek
Copy link
Author

There are more things missing to make the resulting files PDF/A-3 compliant.

PDF/A-3 requires the /AF entry for all embedded files. I've not yet looked into how to add that.

https://www.loc.gov/preservation/digital/formats/fdd/fdd000360.shtml:

Relationship links are established from the document or parts of the document by use of the AF key, which contains an array of file specification dictionaries (as described above). Files associated with the entire document are represented by an AF key in the Catalog for the PDF file.

Also, there needs to be some specific metadata in PDF/A-3 files.

But this PR is a first step with two additions that seem useful to have in any case.

@timokleemann
Copy link

@jenskutilek, have you managed to achieve PDF/A-3 compatibility? I am still struggling...

Attaching the XML to the PDF works like a charm. But converting the PDF into a PDF/A-3 file has so far proved difficult...

@jenskutilek
Copy link
Author

@timokleemann, no, I didn't manage to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants