pdf-lib
pdf-lib copied to clipboard
On pdf.flatten() check mark getting removed from flattened pdf
What were you trying to do?
Trying to flatten the pdf!
How did you attempt to do it?
import fs from 'fs';
import { PDFDocument } from 'pdf-lib';
const flattenPDF = async () => {
const pdfDocument = await PDFDocument.load(
fs.readFileSync('form_to_flatten.pdf')
);
const pdfForm = pdfDocument.getForm();
pdfForm.flatten();
const pdfBytes = await pdfDocument.save();
fs.writeFileSync('flattened.pdf', pdfBytes);
};
flattenPDF();
What actually happened?
the flattened pdf is missing check mark in check boxes.
Visuals
| original pdf | flattened pdf |
|---|---|
What did you expect to happen?
the flattened pdf should not have missing check mark in check boxes. They should be intact.
How can we reproduce the issue?
we can reproduce this using pdf & script provided in How did you attempt to do it? section.
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
- [X] My report includes a Short, Self Contained, Correct (Compilable) Example.
- [X] I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
No response
referenced in https://github.com/cantoo-scribe/pdf-lib/issues/41