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

On pdf.flatten() check mark getting removed from flattened pdf #1574

Open
2 tasks done
satyajitnayk opened this issue Dec 19, 2023 · 1 comment
Open
2 tasks done

On pdf.flatten() check mark getting removed from flattened pdf #1574

satyajitnayk opened this issue Dec 19, 2023 · 1 comment

Comments

@satyajitnayk
Copy link

satyajitnayk commented Dec 19, 2023

What were you trying to do?

Trying to flatten the pdf!

How did you attempt to do it?

form_to_flatten.pdf

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
image image

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

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

@satyajitnayk
Copy link
Author

referenced in cantoo-scribe#41

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

No branches or pull requests

1 participant