Fill PDF checkbox with iText7

Asked

Viewed 55 times

0

Hello!
I’m trying to check a checbox of my PDF, but I’m not getting it right. Instead of just checking one of the checkboxes, he’s always checking all 3

What I would like:
img

What I am getting:
img

PDF in Adobe Reader editor. All 3 checkbox has the same name, this is giving the problem:
img

From what I’ve been doing, it seems that this export value has something to do with it. img

My code:

private static void CreatePdf(string output)
{
    using var pdfDoc = new PdfDocument(new PdfReader("CheckTest.pdf"), new PdfWriter(output));
    var form = PdfAcroForm.GetAcroForm(pdfDoc, true);
    var check = form.GetField("Check");
    check.SetValue("01");
}

PDF link I used in the example: Link

Can someone help me mark the checkbox correctly?

Thank you!

  • maybe because everyone has the memo name/id? tried form.GetField("Check#1");? Verified what is being assigned to var check , is not a collection?

  • It’s not a collection, it’s a collection PdfButtonFormField. I tried to take with form.GetField("Check#1") Yes, hands don’t return anything.

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.