Open wasims1 opened 1 year ago
Did you ever come across a solution for this?
I did not... if you come across any please share...
I just converted my checkbox to a text field and added an "X". Not sure if this work around will apply to your project.
I came across the same issue, and it fixed it with the following:
form.getCheckBox('check18').check();
form.getCheckBox('check18').defaultUpdateAppearances()
Hope this helps someone else
I came across the same issue, and it fixed it with the following:
form.getCheckBox('check18').check(); form.getCheckBox('check18').defaultUpdateAppearances()
Hope this helps someone else
That unfortunately changes the check style from x to tick, so not ideal
I have came across a fix by updating at least one of the check box/radio box border from thin
to medium
as shown in attached image.
I'm seeing the same issue with a checkbox with a custom appearance (circular and etc.). When I flatten the form all the checkboxes appear unchecked. If I manually call updateAppearance
or defaultUpdateAppearance
on one of the checked ones, it does get a check mark (which is not the desired appearance) and also a slight rectangular border around the whole thing. So that doesn't work for me (in particular the border); I'd rather draw my own content over top of the widget.
FWIW I tried older versions back to when form flattening was introduced and this seems to have been an issue all along.
I think the problem is in PDFForm.ts#findWidgetAppearanceRef
where it only handles checkboxes and radio buttons if the normal appearance is a dictionary instead of a reference... in my file I think it's a reference. Therefore I think it skips the logic to look for the checked or unchecked appearance corresponding to the current field setting, and just supplies whatever the unmodified default appearance of the field is (for me, always unchecked).
I could try to patch this, but to be honest I can't get pdf-lib to build for me -- all the dependencies seem dated and it seems to run into a variety of TypeScript errors on the build step... if somebody could walk me through setting up an environment to get yarn install && yarn build
to complete successfully, I could work on a fix.
The border of check boxes are transparent as shown in the image below. Just unchecked transparent border & now it works with flatten too.
What were you trying to do?
First thank you so much for the great library! We're using it to process pdf. We draw text, set radio groups and checkboxes. Everything is working great. The only issue is when using
form.flatten()
, then checkboxes and radio groups do NOT show up in the flattened pdf.Here's a summary psuedo-code:
I tried everything:
form.flatten({ updateFieldAppearances: true });
(which i believe is the default behaviour anyways)form.updatefieldappearances()
Any ideas on why checkboxes and radiogroups are disappearing when form.flatten() is called?
How did you attempt to do it?
see above
What actually happened?
see above
What did you expect to happen?
see above
How can we reproduce the issue?
Flattening a pdf
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response