This is definitively a good idea. I'll create an issue later today...
Tilman
Am 13.07.2017 um 09:20 schrieb [email protected]:
Hi dear contributors to pdfbox,
I just would like to report that Splitter.createNewDocument() should be able to
consider different MemoryUsageSetting configurations.
In version 2.0.6 this method is implemented as
protected PDDocument createNewDocument() throws IOException
{
PDDocument document = new PDDocument();
document.getDocument().setVersion(getSourceDocument().getVersion());
document.setDocumentInformation(getSourceDocument().getDocumentInformation());
document.getDocumentCatalog().setViewerPreferences(
getSourceDocument().getDocumentCatalog().getViewerPreferences());
return document;
}
I would suggest to introduce a member variable "MemoryUsageSetting memSetting" that can
be set for each instance of "Splitter".
This way createNewDocument() could be implemented as
protected PDDocument createNewDocument() throws IOException
{
PDDocument document = new PDDocument(this. memSetting);
document.getDocument().setVersion(getSourceDocument().getVersion());
document.setDocumentInformation(getSourceDocument().getDocumentInformation());
document.getDocumentCatalog().setViewerPreferences(
getSourceDocument().getDocumentCatalog().getViewerPreferences());
return document;
}
Thankfully createNewDocument() is not private, so I could override this method in my
child class (as I did for "protected void processPage()", too... (just FYI - to
create process messages)
Please have a look at "PDFMergerUtility.mergeDocuments()" which is deprecated since
MemoryUsageSetting was introduced. Now, the usage of
"PDFMergerUtility.mergeDocuments(MemoryUsageSetting memUsageSetting)" is encouraged.
By the way: The utility "PDFSplit" would have to be updated to pass a configured
MemoryUsageSetting to "Splitter" - otherwise this tool relies on main memory only.
Perhaps it would be a good thing to be able to define a "pdfbox-wide" basic
MemoryUsageSetting which could be used everywhere as a fallback. This way the default
constructor of PDDocument could be changed from
its implementation in version 2.0.6
public PDDocument()
{
this(MemoryUsageSetting.setupMainMemoryOnly());
}
to something like
public PDDocument()
{
this(MemoryUsageSetting.asConfigured());
}
Regards,
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]