[ https://issues.apache.org/jira/browse/PDFBOX-5720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17790660#comment-17790660 ]
Andreas Lehmkühler commented on PDFBOX-5720: -------------------------------------------- The parser is aware if the source is already closed. Something like the following stacktrace occurs if one tries to access objects which aren't dereferenced before closing the pdf {code} 28.11.2023 17:36:49 ERROR cos.COSObject:126 - Can't dereference COSObject{51, 0} java.io.IOException: RandomAccessBuffer already closed at org.apache.pdfbox.io.RandomAccessReadBuffer.checkClosed(RandomAccessReadBuffer.java:346) ~[classes/:?] at org.apache.pdfbox.io.RandomAccessReadBuffer.getPosition(RandomAccessReadBuffer.java:196) ~[classes/:?] at org.apache.pdfbox.pdfparser.COSParser.dereferenceCOSObject(COSParser.java:622) ~[classes/:?] at org.apache.pdfbox.cos.COSObject.getObject(COSObject.java:121) ~[classes/:?] at org.apache.pdfbox.cos.COSDictionary.getDictionaryObject(COSDictionary.java:186) ~[classes/:?] at org.apache.pdfbox.cos.COSDictionary.getCOSDictionary(COSDictionary.java:551) ~[classes/:?] at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getAcroForm(PDDocumentCatalog.java:142) ~[classes/:?] at org.apache.pdfbox.pdmodel.fixup.processor.AcroFormDefaultsProcessor.process(AcroFormDefaultsProcessor.java:55) ~[classes/:?] at org.apache.pdfbox.pdmodel.fixup.AcroFormDefaultFixup.apply(AcroFormDefaultFixup.java:34) ~[classes/:?] at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getAcroForm(PDDocumentCatalog.java:132) ~[classes/:?] at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getAcroForm(PDDocumentCatalog.java:113) ~[classes/:?] at org.apache.pdfbox.pdmodel.interactive.form.PDAcroFormTest.testCheckedState(PDAcroFormTest.java:85) ~[test-classes/:?] ..... {code} > Checked state of PDCheckbox > --------------------------- > > Key: PDFBOX-5720 > URL: https://issues.apache.org/jira/browse/PDFBOX-5720 > Project: PDFBox > Issue Type: Bug > Components: AcroForm > Affects Versions: 3.0.0 PDFBox > Reporter: Michael Bädorf > Priority: Major > Attachments: ticket.pdf > > > Before v3.0.0 is was possible to get the selected state simply by using the > isChecked() function. After updating to v.3.0.0 the function always returns > false with the same input PDF that works well til v2.0.30. > There are no migration advices so I think this is a bug. > This is the code I use for filtering selected checkboxes. but now always > returns an empty list (in contrast to v2.0.30) > {{{color:#000080}private {color}List<PDField> > filterCheckedCheckboxes(List<PDField> fields) {}} > {{ {color:#000080}return {color}filterByType(fields, > PDCheckBox.{color:#000080}class{color})}} > {{ .stream()}} > {{ .filter(PDCheckBox::isChecked)}} > {{ .map(PDField.{color:#000080}class{color}::cast)}} > {{ .toList();}} > } > > I can also find no test for PDCheckBox.isChecked() -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org