Hi Tilman, Thanks for your reply!
It doesn't happen with *Helvetica*, for example, but these don't need to be embedded because they are already embedded (HelloWorld.java example works, of course). I was not able to try with Type 1 fonts because the ones I have are pfa not pfb (PDFBox can't read pfa), since I only use them in PostScript. Somehow, sites offering Type 1 fonts completely disappeared from the web, since Adobe is not supporting them any more. We shouldn't use Type 1 anymore, but PDFBox can't read PostScript Opentype, only if they are Truetype (I had already isolated the parser in another project and it doesn't even read them). Actually the only way I was able to read PostScript Opentype was with Opentype.js. It is incredible, but I couldn't find any decent Java parser that could handle those. In theory, PostScript Opentype should be read in PDFbox, since Type 1 fonts are not supported anymore. This is already a problem in itself, but another subject. If you meant if I tried several Truetype fonts, yes I did. I tried *verdana.ttf*, *Comfortaa-Bold.ttf* and *Roboto-Black.ttf*. They all give the same error. I have the impression that *embedding Truetype fonts is not working*. Has anybody here already done this? The tests are a *great idea*. I didn't integrate them in my PDFBox project to make it slimmer, but you are definitely right, I will do that. I am not quite sure what you mean with *"Also check that your class path has only one version of pdfbox and fontbox"*. I downloaded the whole source supplied for pdfbox-2.0.23. Is it possible to have a different version for *pdfbox *and *fontbox *in the same release of the source code? But in any case I have no way to see if they are from different versions because that's the way they were released. I compiled the whole block of source code with no libraries. I was forced to search sources for LOG and bouncycastle because they are not included in the source code of PDFBox. LOG I had already used for the parser previously and it works. It seems to work in pdfbox-2.0.23 too. The second is version 1.68.99, and I am not sure it works with this version of PDFBox. I have no clue if this version of bouncycastle could influence pdfbox-2.0.23 for embedding Truetype fonts. Could it do this? Thanks for your help. Best regards, Jack On Fri, Mar 26, 2021 at 6:52 AM Tilman Hausherr <[email protected]> wrote: > does it also happen with a different font? The CreatePDFA example is > covered by a test, the other one isn't. > > Also check that your class path has only one version of pdfbox and fontbox. > > Tilman > > > > --- Original-Nachricht --- > Von: Jack London > Betreff: *** Possible bug in PDFBox Creating PDFwith TTF *** > Datum: 26. März 2021, 11:20 > An: [email protected] > > > > > Hi! > > I compiled the version pdfbox-2.0.23 source code and the following examples > are not working: > > 1) HelloWorldTTF.java > 2) CreatePDFA.java > > I have the following dump after trying to call the function > "getExternalCMap(name);" in line 99 of file CMapParser.java (package > <http://org.apache.fontbox.cmap> > ), where name = "Identity-H", : > > Exception in thread "main"<http://java.io.IOException> : Stream closed > at > < > http://java.base/java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:157 > > > ) > at > < > http://java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244> > > ) > at > < > http://java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:263> > > ) > at > <http://java.base/java.io.FilterInputStream.read(FilterInputStream.java:82> > > ) > at > < > http://java.base/java.io.PushbackInputStream.read(PushbackInputStream.java:135> > > ) > at > <http://org.apache.fontbox.cmap.CMapParser.parseNextToken(CMapParser.java:479> > > ) > at<http://org.apache.fontbox.cmap.CMapParser.parse(CMapParser.java:126> ) > at > <http://org.apache.fontbox.cmap.CMapParser.parsePredefined(CMapParser.java:102> > > ) > at > <http://org.apache.pdfbox.pdmodel.font.CMapManager.getPredefinedCMap > (CMapManager.java:55> > ) > at > <http://org.apache.pdfbox.pdmodel.font.PDType0Font.readEncoding > (PDType0Font.java:280> > ) > at org.apache.pdfbox.pdmodel.font.PDType0Font.<init>(PDType0Font.java:222) > at > <http://org.apache.pdfbox.pdmodel.font.PDType0Font.load(PDType0Font.java:67> > > ) > at > <http://org.apache.pdfbox.examples.pdmodel.HelloWorldTTF.main > (HelloWorldTTF.java:79> > ) > > Exception in thread "main"<http://java.io.IOException> : Stream closed > at > < > http://java.base/java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:157 > > > ) > at > < > http://java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244> > > ) > at > < > http://java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:263> > > ) > at > <http://java.base/java.io.FilterInputStream.read(FilterInputStream.java:82> > > ) > at > < > http://java.base/java.io.PushbackInputStream.read(PushbackInputStream.java:135> > > ) > at > <http://org.apache.fontbox.cmap.CMapParser.parseNextToken(CMapParser.java:479> > > ) > at<http://org.apache.fontbox.cmap.CMapParser.parse(CMapParser.java:126> ) > at > <http://org.apache.fontbox.cmap.CMapParser.parsePredefined(CMapParser.java:102> > > ) > at > <http://org.apache.pdfbox.pdmodel.font.CMapManager.getPredefinedCMap > (CMapManager.java:55> > ) > at > <http://org.apache.pdfbox.pdmodel.font.PDType0Font.readEncoding > (PDType0Font.java:280> > ) > at org.apache.pdfbox.pdmodel.font.PDType0Font.<init>(PDType0Font.java:222) > at > <http://org.apache.pdfbox.pdmodel.font.PDType0Font.load(PDType0Font.java:67> > > ) > at > <http://org.apache.pdfbox.examples.pdmodel.CreatePDFA.main(CreatePDFA.java:88> > > ) > > Hope someone can help me with this one. > > Jack >
