question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to fill form radio fields

See original GitHub issue

Can pdf-lib be used to programmatically fill out radio fields in a template PDF? Analog to #48

PDF source looks like:

...
148 0 obj
<</BC[]/BG[0.952896 0.952896 0.952896]>>
endobj
149 0 obj
<</Count 0/Type/Outlines>>
endobj
150 0 obj
[214 0 R 171 0 R 184 0 R 202 0 R 176 0 R 186 0 R 180 0 R 192 0 R 188 0 R 178 0 R 196 0 R 198 0 R 200 0 R 194 0 R 190 0 R 182 0 R 151 0 R 152 0 R 153 0 R 18 0 R 70 0 R 19 0 R 24 0 R 79 0 R 71 0 R 17 0 R 75 0 R 68 0 R 67 0 R 59 0 R 74 0 R 37 0 R 86 0 R 38 0 R 90 0 R 94 0 R 88 0 R 40 0 R 89 0 R 30 0 R 28 0 R 34 0 R 26 0 R 105 0 R 113 0 R 99 0 R 127 0 R 104 0 R 142 0 R 98 0 R 143 0 R 115 0 R 110 0 R 147 0 R 117 0 R 141 0 R 130 0 R 103 0 R]
endobj
151 0 obj
<</FT/Btn/Ff 49152/Kids[211 0 R]/Opt 156 0 R/T(Radio 1)>>
endobj
152 0 obj
<</FT/Btn/Ff 49152/Kids[208 0 R]/Opt 155 0 R/T(Radio 2)>>
endobj
153 0 obj
<</FT/Btn/Ff 49152/Kids[204 0 R]/Opt 154 0 R/T(Radio 3)>>
endobj
154 0 obj
[(Choice1)]
endobj
155 0 obj
[(Choice1)]
endobj
156 0 obj
[(Choice1)]
endobj
157 0 obj
...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Hopdingcommented, Sep 16, 2020

pdf-lib now has form creation and filling APIs that should be used instead of the above example(s). See the form filling JSFiddle for a working example. Additional information is available in the README and API docs. The PDFRadioGroup.select method is of particular relevance to this issue.

0reactions
Hopdingcommented, Dec 28, 2019

@astanet Thanks for updating the example!

I agree that it’s rather difficult to understand the structure of PDF files. I still don’t understand everything about them, and I’ve been working on pdf-lib for a little over 2 years now! (see the first commit)

If you want to better understand the structure of PDF files, I’d advise reading through some key sections of the PDF specification. There really is no substitute for it. There is also a book by a fellow named John Whitington that might be useful, though I haven’t read it myself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<input type="radio"> - HTML: HyperText Markup Language
When the above form is submitted with a radio button selected, the form's data includes an entry in the form contact=value . For...
Read more >
HTML input type="radio" - W3Schools
Radio buttons let a user select only one of a limited number of choices: <input type="radio" id="html" name="fav_language" value="HTML">
Read more >
How to Create Radio Buttons in HTML [+ Examples]
To make a basic form with radio buttons in it, wrap your radio button grouping(s) in a <form> tag, and include a <button>...
Read more >
PDF Forms: Working with Radio Buttons | UW-Eau Claire
From the Add New Field pull-down menu, select Show Tools on Toolbar. The Forms toolbar appears. forms toolbar · Click Radio Button Tool....
Read more >
I want to have fields automatically fill in depending on what ...
I want to have fields automatically fill in depending on what which radio button is selected. I need to have a user select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found