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

Issue with PDF Checkbox Behavior in Library #83

Open
microshine opened this issue Jun 14, 2023 · 0 comments
Open

Issue with PDF Checkbox Behavior in Library #83

microshine opened this issue Jun 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@microshine
Copy link
Contributor

microshine commented Jun 14, 2023

The PDF document provided in Issue #74 can currently be read by our library. However, we have encountered a new problem with the document. Specifically, the document uses checkboxes with radio button behavior, which is causing an error since our library does not implement this mechanism for checkboxes.

const data = fs.readFileSync("Washington.Vehicle_Vessel.Bill.of.Sale.Form.1.pdf");
const doc = await PDFDocument.load(data);

const checkBox = doc.getComponentById(119, 0, CheckBox);
const textBox = doc.getComponentById(114, 0, TextEditor);

const isHybrid = doc.hasHybridReference();
assert.equal(isHybrid, true);

const clone = await doc.clone({
  useXRefTable: true,
  disableAscii85Encoding: true,
  disableCompressedStreams: true,
});

const cloneCheckBox = clone.getComponentByName(checkBox.name, CheckBox); // TypeError: Cannot get PDF Component from the Document. Component doesn't require to the requested type.
cloneCheckBox.checked = true;

const cloneTextBox = clone.getComponentByName(textBox.name, TextEditor);
cloneTextBox.text = "123456789";

writeFile(await clone.save());

To address the described issue, it would be necessary to implement a CheckBoxGroup component similar to the RadioButtonGroup or create a common class for them. The only difference between these components lies in their rendering and the presence of a flag indicating that the RadioButton is a circular button.

@microshine microshine added the enhancement New feature or request label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant