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?

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

Reply via email to