[ 
https://issues.apache.org/jira/browse/PDFBOX-3598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15704552#comment-15704552
 ] 

Yan Bing commented on PDFBOX-3598:
----------------------------------

Thank you very much for your reply.

My request:
Get PDF’s color property to decide which printer the file should be sent to.
If it contains colorful texts or images, it is sent to Color printer.
If it is black, it will be sent to Monochrome Only printer.
My algorithm is very simple, as follows.
1. Scan text, get color space of text.
If contains DeviceRGB or DeviceCMYK, mark it color and exit.
2. If the PDF is a image PDF(raster PDF)
scan the images, get color space of images.
If contains DeviceRGB or DeviceCMYK, mark it color and exit.
By now, I can get the color space of text, using the sample code.
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextColors.java
But I have not found a way to get the color space of image inside a PDF.

The sample 
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java
can help me to get image's location, but I failed to get color space of the 
images.

Can you help me? Any help or suggestion is highly appreciated.
Regards
Yan

> EmptyStackException in PDFStreamEngine.getGraphicsState
> -------------------------------------------------------
>
>                 Key: PDFBOX-3598
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3598
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.3
>            Reporter: Yan Bing
>            Priority: Critical
>         Attachments: pdfbox-test-data1.pdf, pdfbox-test-data2.pdf
>
>
> I try to get a PDF's Colorspace by PDFBox2.0.3.
> But it throws this exception.
> java.util.EmptyStackException
>          at java.util.Stack.peek(Stack.java:102)
>          at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.getGraphicsState(PDFStreamEngine.java:918)
>          at 
> org.apache.pdfbox.examples.util.PrintTextColors.getColors(PrintTextColors.java:118)
>          at 
> org.apache.pdfbox.examples.util.PrintTextColors.main(PrintTextColors.java:103)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to