Stefan Ziegler created PDFBOX-6192:
--------------------------------------

             Summary: PDIndexed() no-arg constructor, setBaseColorSpace(), and 
setHighValue() all deprecated in 3.x with no usable replacement for incremental 
construction
                 Key: PDFBOX-6192
                 URL: https://issues.apache.org/jira/browse/PDFBOX-6192
             Project: PDFBox
          Issue Type: Wish
    Affects Versions: 3.0.7 PDFBox
            Reporter: Stefan Ziegler


We are converting PostScript to PDF using PDFBox 3.x. PostScript's Indexed 
color space is defined as:
{code:java}
[/Indexed base hival lookup]
{code}
where base, hival, and lookup arrive as separate, independently parsed 
PostScript values. We need to construct a PDIndexed object incrementally: first 
set the base color space, then set the high value, and later (optionally) 
supply the lookup table.

The current 3.x API offers exactly one approach for this:
{code:java}
PDIndexed indexed = new PDIndexed();          // @Deprecated
indexed.setBaseColorSpace(base);              // @Deprecated
indexed.setHighValue(hival);                  //  @Deprecated{code}
All three of these are now marked {{@Deprecated}} with the note _"This will be 
removed in 4.0. If you need it, please contact us."_ — but {*}no replacement is 
suggested{*}.

The only non-deprecated constructor is:
{code:java}
public PDIndexed(COSArray indexedArray) throws IOException{code}
This constructor immediately calls {{readColorTable()}} and 
{{initRgbColorTable()}} in its body, which require a fully assembled 
{{COSArray}} including a valid lookup table at slot index 3. This makes it 
{*}impossible to use for incremental construction{*}: we cannot assemble the 
complete {{COSArray}} up front because the base color space, hival, and lookup 
data are parsed from separate PostScript operands at different points in the 
execution.

Attempting to pass a partially built {{COSArray}} (e.g. with {{COSNull}} as the 
lookup entry, as the deprecated default constructor does internally) to the 
non-deprecated constructor would either throw an {{IOException}} during table 
initialization or produce a broken object.

 

*Request:*

Please provide one of the following:
 # A *builder or factory method* such as {{PDIndexed.create(PDColorSpace base, 
int hival, byte[] lookupData)}} that accepts the fully resolved components and 
handles internal construction — allowing callers to avoid piecemeal mutation 
without requiring a pre-built {{{}COSArray{}}}.
 # Or *retain the no-arg constructor and the three setters as non-deprecated* 
(or re-deprecate only after a builder is in place), since there is currently no 
way to construct a {{PDIndexed}} from dynamically parsed components without 
them.

The deprecation of all mutation entry points simultaneously, without providing 
an incremental-construction alternative, leaves consumers of PostScript/PDF 
generation pipelines with no supported path forward.



*PDFBox version:* 3.0.7 *Affected class:* 
{{org.apache.pdfbox.pdmodel.graphics.color.PDIndexed}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to