-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Additional support for factur-x (PDF-A3) #508
Conversation
Hello @DkDavid! I'm not familiar with the details of the ZUGFeRD standard. I don't know anything about the |
Hi Hopding, sorry for my late reply. The specification can be downloaded here: https://www.ferd-net.de/standards/zugferd-versionsarchiv/zugferd-2.1.html |
@DkDavid Would it be possible to add specific options to the embedded file options? I would prefer that approach as it is easier to document and use than allowing users to pass arbitrary values. Note that I haven't had a chance to familiarize myself with the ZUGFeRD specification, so just let me know if there's a specific reason this wouldn't work. |
@Hopding Yes, that would be possible. The "additional param" needed for factur-x is: additionalParams: {'AFRelationship': 'Alternative'} for the xml attachment. This as well as the proposed change in PDFEmbeddedFile.ts, and the addition of the CIDToGIDMap would be necessary to fulfill compliance. Everything else is easily possible with the current api. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DkDavid Thanks for working on this! I certainly appreciate your desire to make the API extensible. It might alleviate the need to add specific new options in the future. However, I'm concerned that it could also result in a more obscure and less well-documented API that would be more difficult to understand, use, and maintain. So I've requested some changes to implement this feature more in-line with existing API options.
In addition to my other comments, we'll need to add an assertion to the following method for the new option it accepts:
pdf-lib/src/api/PDFDocument.ts
Lines 810 to 822 in 30d2aa2
async attach( | |
attachment: string | Uint8Array | ArrayBuffer, | |
name: string, | |
options: AttachmentOptions = {}, | |
): Promise<void> { | |
assertIs(attachment, 'attachment', ['string', Uint8Array, ArrayBuffer]); | |
assertIs(name, 'name', ['string']); | |
assertOrUndefined(options.mimeType, 'mimeType', ['string']); | |
assertOrUndefined(options.description, 'description', ['string']); | |
assertOrUndefined(options.creationDate, 'options.creationDate', [Date]); | |
assertOrUndefined(options.modificationDate, 'options.modificationDate', [ | |
Date, | |
]); |
The assertion should be:
assertIsOneOfOrUndefined(options.afRelationship, 'options.afRelationship', AFRelationship);
(see this assertion for reference).
…dd embedded files to AF tag, make PDFRawStram available.
@Hopding I digged into the Factur-X (european harmonized name of ZugFERD) and the PDF-A3 specification. Nearly all of the changes can be led back to the PDF-A3 specification. Therefore I changed the references accordingly and implemented your comments. To reach PDF-A3 compliance three additional things have to be done by the user. All of them are reachable by the current API.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DkDavid This is perfect! Thanks for working on this and figuring out what is necessary to achieve PDF-A3 compliance. This feature will go out in the next release of pdf-lib 🎉
The changes in this PR were just released in |
* Added support for factur-x, additional metadata for embedded files, add embedded files to AF tag, make PDFRawStram available. * Add PDFRawStram to lookup function * Added CIDToGIDMap to achieve PDF-A3 compliance * implement requested changes, update reference to PDF-A3 * cleanup from previous implementation Co-authored-by: David Dillkötter <dillkoetter@kampundkoetter.de> Co-authored-by: David Dillkötter <david.dillkoetter@gmail.com>
Hello everyone. |
for PDF-A3 follow this #230 |
The factur-x (ZUGFeRD) standard needs the attached files listed in the AF-tag.
Furthermore, additional metadata is necessary for the embedded files.
Easy solution: Allow users to supply additionalParams.
To access the attached files of factur-x invoices, access to the PDFRawStream is needed.