-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fillable PDF Forms #44
Comments
Also ran into this problem...not sure yet what's going on. |
I've found that you need to flatten the PDF first in order to capture any annotations made to a pdf. This can be done manually with the PDF file or through a different npm package. I use the pdf-lib npm package to flatten the pdf first, and then convert it into an image. Hope this helps!!!! EDIT: Actually using a different package. See reply below. |
@aaron-md maybe you can help me understand what I'm doing wrong. I'm using that library and flattening the pdf but the resulting png file doesn't have the text field. my minimal code example: import { convert } from "pdf-img-convert";
import { PDFDocument } from "pdf-lib";
PDFDocument.load(file).then((pdf) => {
const form = pdf.getForm();
const textField = form.getTextField("TextBox1");
textField.setText("Hey, please work.");
form.flatten();
pdf.save().then((pdfUint8Array) => {
const buffer = Buffer.from(pdfUint8Array);
convert(buffer).then((converted) => {
writeFileSync("minimal.png", converted[0]);
});
});
}); |
@thomas-robinpowered My apologies - I had looked over my old code a bit too quickly and gave you a misleading response. I actually am using the pdf2pic npm package for converting pdf's to images. I believe this package automatically flattens the pdf before converting, so this should solve any annotation issues. Let me know if this helps!! |
@aaron-md thank you for getting back to me, I'll give that library a try! |
Running into this problem too - is fixing this on the roadmap at all? |
Loving the package - the only issue I've ran into so far is form fields that are filled out in a PDF are converted into blank fields after the PDF is converted into an image.
I was wondering if anyone knows of any fixes or work arounds for this - or if I'm just doing something wrong lol - thanks in advance!
The text was updated successfully, but these errors were encountered: