You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Timo Boehme <ti...@ontochem.com> on 2018/09/05 09:00:06 UTC

[DISCUSS] Document specific processing properties

Hi,

my last (proposed) addition of a system property controlling rendering 
(PDFBOX-4309) adds to other already existing properties (e.g. 
org.apache.pdfbox.rendering.UsePureJavaCMYKConversion, possible more?).

These settings are important for specific use cases/environments. Even 
more they are often only needed for specific PDF documents - e.g. the 
mentioned properties especially cure a problem with excessive calls to 
Java color management implementation, without them some documents are 
practically not processable. In other cases the settings also could have 
negative effects like slower processing or wrong colors.

Thus it would be good to have the possibility to adjust settings on a 
per-document basis (either directly by user or based on 
checking/collecting document features like number of images etc.).
The problem is how these document specific settings can be provided to 
the relevant classes, e.g. PDICCBased.

Providing a settings object through the call-chain is probably not an 
option as a lot of constructors/methods would have to be changed for 
only a few places where the settings are really needed.

One viable solution which came to my mind is using a ThreadLocal 
ProcessingProperties map (String,String). In order to not get unwanted 
side-effects using these properties should be initiated by the user
and it should be clearly documented to do it in a try-finally block in 
order to remove the settings after processing (and also to not get 
memory leaks etc.), like:

try {
   LocalProcessingProperties.activate();  // creates a map object
   ... // PDF processing
} finally {
   LocalProcessingProperties.clear();  // removed map object
}

A call to LocalProcessingProperties.getProperty( KEY ) would return 
value from ThreadLocal map - if map exists and contains this key, 
otherwise fall back to return System.getProperty( KEY ).

As PDFBOX (currently) doen't use multiple threads this should work fine 
- for multi-threaded usage an initialization/clear would be needed for 
each thread which could get the reference to the map object of the main 
processing thread.

WDYT?


Best regards,
Timo


-- 
Timo Boehme
OntoChem IT Solutions GmbH
Blücherstraße 24
06120 Halle (Saale)
Germany

phone: +49 345 478 047 4        | fax: +49 345 478 047 1
email: timo.boehme@ontochem.com | web: www.ontochem.com
HRB 21962 Amtsgericht Stendal   | USt-IdNr.: DE815563824
managing director : Lutz Weber


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org