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 #41

Open
2 tasks done
satyajitnayk opened this issue Dec 15, 2023 · 6 comments
Open
2 tasks done
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@satyajitnayk
Copy link

satyajitnayk commented Dec 15, 2023

What were you trying to do?

When I try to flatten a pdf with checked check box, the flattened pdf is missing check mark in check boxes.

Visuals

original pdf flattened pdf
image image

How did you attempt to do it?

Tried with simple script using the file 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.

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

Thoughts @Sharcoux @MatheusrdSantos !!

@satyajitnayk satyajitnayk added bug Something isn't working needs-triage labels Dec 15, 2023
@satyajitnayk
Copy link
Author

satyajitnayk commented Dec 19, 2023

This could be possibly happening

  1. mac preview & other pdf editing apps converts pdf version 1.7 to 1.3/other lower versions to make it backward compatible when we edit an PDF Apple Discussion Link
  2. Apps modify the metadata of pdf's which resulting in this behavior. (Refer to screenshot)
image

@Sharcoux
Copy link
Collaborator

@satyajitnayk We don't use this feature, so I'm not sure that we will take the time to work on this. If someone could have a look and make a PR, that would be great.

@Sharcoux
Copy link
Collaborator

Solved in #56 and released in v2.1.6

@satyajitnayk
Copy link
Author

@Sharcoux #56 does not fix the issue. Check marks & radio buttons still getting removed.
image

@Sharcoux Sharcoux reopened this Jun 14, 2024
@RippleRurigaki
Copy link

@satyajitnayk

My confirmation is that the check and radio buttons do show up.

image

mac preview & other pdf editing apps converts pdf version 1.7 to 1.3/other lower versions to make it backward compatible when we edit an PDF Apple Discussion Link

Are you on Version 1.3 as you commen?

I don't know what is causing this,
If you can provide us with the version 1.3 file,
I will try to find out.

@Sharcoux
Copy link
Collaborator

Without new information, I will close this Issue in a week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants