The correct way to copy resources and preserve key names is to use:

// copy color space
for (COSName name: spotsPage.getResources().getColorSpaceNames()) {
    System.out.println("Copying color space name:"+name.getName());
    PDColorSpace pdcs = spotsPage.getResources().getColorSpace(name);
    docPage.getResources().put(name, pdcs);
}


On 18 Aug 2020, at 00:32, Rares Pop <r...@crane.com<mailto:r...@crane.com>> 
wrote:

Looks like re-adding the resources like this does not make an exact copy.
Comparing the two files in the Debugger shows that in the output file, the 
Color Space Names are lower case and the order is wrong: CS1 does not have the 
same colours inside as cs1.

<Screenshot 2020-08-18 at 00.25.55.png>
<Screenshot 2020-08-18 at 00.26.04.png>


Is this a BUG in pdfbox?







On 17 Aug 2020, at 21:57, Tilman Hausherr 
<thaush...@t-online.de<mailto:thaush...@t-online.de>> wrote:

Am 17.08.2020 um 20:30 schrieb Pop, Rares:
I’ve made a few more rounds, it is Acrobat Pro DC (Mac) that crashes.
I can open and see the spot colours in Acrobat 8 on Windows.

Send the file to Adobe support. Whatever the cause is, it shouldn't crash.

If you want to research this a bit, try adding only one, or only 10 
colorspaces. Just to see wether it makes a difference.

Tilman




On 17 Aug 2020, at 20:48, Tilman Hausherr 
<thaush...@t-online.de<mailto:thaush...@t-online.de><mailto:thaush...@t-online.de>>
 wrote:

Hi,

I looked at the file with PDFBox PDFDebugger and all looks like I expect, i.e. 
you copied 126 colorspaces. I can see them.

<cacacockanilbhdn.png>

I was able to open the print dialog of Adobe Viewer DC but I guess that's not 
the same than what you did (I don't have Acrobat professional)

<hbdbkmogbnhnkdgc.png>

I've surprised that any problems would happen - the 126 colorspaces are orphans.

Tilman

Am 17.08.2020 um 19:22 schrieb Pop, Rares:

https://s3.amazonaws.com/cdn.crane.com/pdfwork/breakingAdobe.pdf

On 17 Aug 2020, at 19:35, Pop, Rares 
<r...@crane.com<mailto:r...@crane.com><mailto:r...@crane.com><mailto:r...@crane.com><mailto:r...@crane.com>>
 wrote:

Hi guys,

I am trying to add the color space resources from a source document to another.


PDPage spotsPage = this.spotsDocument.getPage(0); // source document
PDPage docPage = newDocument.getPage(0); // target document

// copy color space
for (COSName name: spotsPage.getResources().getColorSpaceNames()) {
    PDColorSpace pdcs = spotsPage.getResources().getColorSpace(name);
    docPage.getResources().add(pdcs);

}
newDocument.save("out1.pdf");
newDocument.close();

However, when opening the out1.pdf with Acrobat, it crashes when looking at 
Print Output Preview to see the new colours.

What am I missing?

Thank you,
Ra







---------------------------------------------------------------------
To unsubscribe, e-mail: 
users-unsubscr...@pdfbox.apache.org<mailto:users-unsubscr...@pdfbox.apache.org>
For additional commands, e-mail: 
users-h...@pdfbox.apache.org<mailto:users-h...@pdfbox.apache.org>


Reply via email to