Hello
I use the PdfContentEditor to copy viewer preferences from a source pdf to a cloned pdf with this code using the last library aspose-pdf-22.2.jar :
try (PdfContentEditor sourceprefs = new PdfContentEditor( docreader );
PdfContentEditor destprefs = new PdfContentEditor( doccopy )) {
destprefs.changeViewerPreference( sourceprefs.getViewerPreference() );
}
But after the “try” the documents docreader and doccopy are closed.
They shoul not since PdfContentEditor (like any class) should not close an instance that it has not itself created, so I considre this as a bug.
Please could you fix it or do you think this would break to much existing software ?
In any case would you please show me a workaround to get and set the viewer preferences of a document without closing the document ? Or using an other class ? I searched but did not find.
I ask because the documents instances are used also for other things and it is not a solution to close/open them several times in the processing.
Thank you very much
jmf
@everteamjmf
To ensure a timely and accurate response, please attach the following resources here for testing:
- Your input PDF file.
- Please share how are you checking documents
docreader
and doccopy
are closed.
- Please create a sample application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip and upload them.
Hello
Thanks for your quick answer, I did a small eclipse project to reproduce : TestAspose.zip (47.8 KB)
Before running the test, please :
- in the main() method, replace “D:/src/workspace/TestAspose/” with your own project directory
- add aspose-pdf-22.2.jar in the /lib directory. (too big to put in the zip)
- add Aspose.Total.Product.Family.lic in the root directory
The input “pdf/test.pdf” file is read by the program in the directory. It does the same with any pdf file I used.
One can check that the document is closed (in fact “disposed”) by reading the exception message, here is the message and callstack : callstack.png (11.1 KB)
class com.aspose.pdf.internal.ms.System.l8l: Cannot access a disposed object.
Object name: ‘Document’.
If I comment the line 49 “contenteditor.close();” there is no error.
But of course do not call close() would be bad practice.
Best regards
jmf
@everteamjmf
We have logged this problem in our issue tracking system as PDFJAVA-41440. You will be notified via this forum thread once this issue is resolved.
We apologize for your inconvenience.
Thank you very much for that.
In order to hope to have the fix earlier, perhaps should I add that we, Everteam, have a paid support for a global license ?
We cannot post message on the helpdesk because we reached the max 6 messages per year, but maybe I can send you a proof, for example by sending you our license in private?
Best regards
jmf
@everteamjmf
Your query is more related to our sales team. Please post your query in Aspose.purchase forum where you will be guided appropriately.
The issues you have found earlier (filed as PDFJAVA-41440) have been fixed in Aspose.PDF for Java 22.5.