[
https://issues.apache.org/jira/browse/PDFBOX-5281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17418572#comment-17418572
]
Fernando commented on PDFBOX-5281:
----------------------------------
Thanks for the quick response [~tilman], much appreciated.
It works now with the pdfbox-app snapshot, one thing I noticed is that it's
missing ToUnicode mapping. In my case I only need the png but still I wonder
why the unicode mapping is missing.
!orig.png!
When converting to PS from the original and back to pdf, ToUnicode is available
in the Font, though the unicode mapping is incorrect as it doesn't correspond
to the glyphs, it might be something wrong with the original pdf. Anyway I'm
not seeing this problem with other pdfs.
!origps.png!
> Error rendering png from PDF - Error at Type1Parser parseBinary for Type 1
> Font
> -------------------------------------------------------------------------------
>
> Key: PDFBOX-5281
> URL: https://issues.apache.org/jira/browse/PDFBOX-5281
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox
> Affects Versions: 2.0.23
> Environment: Component: Type1Parser
> Environment: Java 8
> Reporter: Fernando
> Priority: Major
> Fix For: 2.0.25, 3.0.0 PDFBox
>
> Attachments: orig.png, origps.png
>
>
> When I try to convert a pdf page using "pdfRenderer.renderImageWithDPI" to a
> png image using pdfbox version 2.0.23 I get the following error. The pdf is a
> customer specific one, I can't share the original file here.
>
> {code:java}
> Error [PDType1Font] Can't read the embedded Type1 font
> AAAAAB+NimbusMonoPS-Regular_00
> java.io.IOException: Found Token[kind=NAME, text=readonly] but expected def
> at org.apache.fontbox.type1.Type1Parser.read(Type1Parser.java:867)
> at org.apache.fontbox.type1.Type1Parser.parseBinary(Type1Parser.java:610)
> at org.apache.fontbox.type1.Type1Parser.parse(Type1Parser.java:64)
> at org.apache.fontbox.type1.Type1Font.createWithSegments(Type1Font.java:85)
> at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:263)
> at
> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:76)
> at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:146)
> {code}
>
> Using the PDFDebugger to have access to the FontFile of the page throwing the
> error, "Save the Stream as PFB", and using the t1utils t1disasm to obtain
> the readable equivalent of the binary private dictionary, which contains:
> {code:java}
> /Private 10 dict dup begin
> /RD {string currentfile exch readstring pop} readonly def ←
> /ND {noaccess def} readonly def
> /NP {noaccess put} readonly def
> /MinFeature {16 16} readonly def
> {code}
> And following the trace in PDFBox I can see it blowing up at "Type1Parser" in
> the "parseBinary" method at line 602 they have the check for
> ""RD".equals(key)", where key is "readonly" and the last check from that list
> "read(Token.NAME, "def");" has to be def, and because the key is "readonly"
> it throws the error, even if it makes it pass "RD" it will have the same
> results when parsing the contents for "ND" and "NP".
> I have seen most of the Type 1 Font files have "executeonly" instead of
> "readonly" in the /Private dict section, even this same file if I convert it
> first to PS and back to PDF, extracting the font again I can see that the
> instructions for RD, ND, and NP are rearranged to be "executeonly" using Mac
> Preview or GS ps2pdf., and the PNG is generated without issue using the
> PDFRenderer, I don't see a way to do this step programmatically at the moment.
> {code:java}
> dup /Private 20 dict dup begin
> /-| {string currentfile exch readstring pop} executeonly def ←
> /|- {noaccess def} executeonly def
> /| {noaccess put} executeonly def
> {code}
> From the Type 1 Font Spec, they don't provide a must follow receipt on what
> instructions can be appended after RD, ND, or NP, they state: "The RD, NP,
> and ND functions must be implemented by PostScript language procedures" , If
> we take a look to the PostScript Language Reference Manual:
> ??readonly: When an object is read-only, its value cannot be modified by
> PostScript operators (an invalidaccess error will result), but it can still
> be read by operators or executed by the PostScript interpreter.??
> ??executeonly: When an object is execute-only, its value cannot be read or
> modified explicitly by PostScript operators (an invalidaccess error will
> result), but it can still be executed by the PostScript interpreter—for
> example, by invoking it with exec??
>
> Both "readonly" and "executeonly" allows the instructions to be executed.
> Suggestion:
> # Would it be possible to add an optional "readMaybe(Token.NAME,
> "readonly");" to the "parseBinary" RD, "ND", and "NP" keywords similar to
> how it was done at PDFBOX-2202.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]