Andreas,
indeed - a downgrade to version 1.1.0 fixed the problem with the
"/Widths is wrong"-error. Acrobat Reader opens the file without message
and shows the site correctly. Also in "Apple Preview" the problem is solved.
I generated the same PDF with 1.1.0 and 1.2.1 and could spot the
difference with PDFDebugger in the stream:
In the Font:Dictionary the "LastChar"-Value in version 1.1.0 is 255,
which seems to be ok. In version 1.2.1 the value is 260.
In the PDF-code the difference itself looks like this:
------Version 1.1.0------
605 583 608 608 608 608 608 833 608 583
583 583 583 512 644 512]
/FirstChar 0
/LastChar 255
------/Version 1.1.0------
------Version 1.2.1------
605 583 608 608 608 608 608 833 608 583
583 583 583 512 644 512 250 250 250 250
250]
/FirstChar 0
/LastChar 260
------/Version 1.2.1------
I'll try to invest some time the next days to provide a bugfix. To mee
it looks like the TTF-Load method has a bug.
Greetings,
Erik
On 21.07.10 13:25, Andreas Lehmkühler wrote:
Hi,
at the moment I'm trying to build a new pdf file with pdfbox (Vers.
1.2.1 / JVM 1.6.0) from the scratch. Unfortunatly, I'm getting errors
when trying to embed fonts: The generated document does not look correct
under "Apple Preview", when opening with "Acrobat" an error ("value for
/Widths is wrong") is shown, but the look of the file is as expected [1].
I tried with several TTFs - all time the same error. I think the fonts
are ok and it must be a mistake by my own.
Can anyone please point me an example where to see how multiple TTFs are
used correctly?
I'm using PDFBox in a similar way and it works fine for me. But I'm still
using version 1.1.0, so that it might be a regression with one of the newer
versions.
Probably this issues is related to [1].
BR
Andreas Lehmkühler
[1] https://issues.apache.org/jira/browse/PDFBOX-696
Here is the code I'm using:
------------------------------------------------------------------------
PDDocument document = new PDDocument();
PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
document.addPage( page );
PDTrueTypeFont fontBold = PDTrueTypeFont.loadTTF(document,
"DroidSans-Bold.ttf");
PDTrueTypeFont fontRegular = PDTrueTypeFont.loadTTF(document,
"DroidSans.ttf");
PDPageContentStream contentStream = new PDPageContentStream(document,
page);
contentStream.drawLine(18, 747, 580, 747);
contentStream.setFont(fontRegular, 14);
contentStream.beginText();
contentStream.setTextTranslation(20, 750);
contentStream.drawString("Ihr Vorteil durch");
contentStream.setFont(fontBold, 12);
contentStream.setTextTranslation(20, 725);
contentStream.drawString("Pers\u00F6nliche Berechnung f\u00FCr:");
contentStream.setTextTranslation(20, 710);
contentStream.drawString("Bernd Mustermann");
contentStream.endText();
contentStream.close();
document.save(file);
document.close();
------------------------------------------------------------------------
Thanks for all your help,
Greetings,
Erik
[1] http://blog.elitecoderz.net/wp-content/uploads/screen.png
--- original Nachricht Ende ----