working with xfa forms #129
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
First attempt at adding support for preserving XFA (XML Forms) forms and extracting/modifying JavaScript embedded in XFA templates.
Why?
pdf-lib strips by default XFA data when loading and saving PDFs, causing these forms to lose all functionality. Additionally, there was no way to programmatically access or modify the JavaScript code embedded in XFA templates
How?
**Preserv XFA forms **
preserveXFAoption toPDFDocument.load()andPDFDocument.save()XFA JavaScript Extraction (
getXFAJavaScripts()){field: string, event: string, script: string}objects</script\n>)XFA JavaScript Modification (
setXFAJavaScript(field, event, script))Technical details:
<script>elements<\/script\s*>instead of<\/script>)decodePDFRawStreamto handle compressed streamsTesting?
Unit Tests (7 tests in
PDFDocumentXFA.spec.ts)assets/pdfs/with_xfa_fields.pdf(included in repo)Integration Testing
New Dependencies?
No new production dependencies. The implementation uses existing dependencies:
pako(already in dependencies) - for stream compression/decompressionScreenshots
Suggested Reading?
Anything Else?
Documentation updates