Hi All,
I need to write on an existing PDF some text. On
top and on the bottom of the page I need to write a code using an OCR-A Font.
Creating a new PDF with the code gave with the
example all works fine:
try
{
PdfWriter.getInstance(document, new
FileOutputStream("truetype.pdf"));
document.open();
BaseFont bfComic =
BaseFont.createFont("C:\\usr\\max\\Java\\netBeans\\OCR\\font\\OCRAEXT.TTF",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
Font font = new Font(bfComic,
12);
String text1 =
"ABCDEFGHILMNOPQRSTUVZ";
String text2 =
"1234567890";
document.add(new Paragraph(text1,
font));
document.add(new Paragraph(text2,
font));
}
catch(DocumentException de)
{
System.err.println(de.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
Whn I try to write on the existing PDF the code
gives no error but when I open the PDF Acrobat return an error that say :"Unable
to find or create the Font 'YQZMBV+OCRAExtended'" and instead of the printed
char I obatain a list of points.
Here an extract of my code:
.....
try {
PdfReader
reader = new PdfReader(Configuration.TEMPLATE_FILE);
PdfStamper stamp = new PdfStamper(reader, new
FileOutputStream(absoluteDestPath + absoluteDestFile));
PdfContentByte
content = stamp.getUnderContent(1);
content.beginText
();
BaseFont ocr =
BaseFont.createFont("C:\\usr\\max\\Java\\netBeans\\OCR\\font\\OCRAEXT.TTF",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
content.setFontAndSize (ocr, 20);
content.showTextAligned
(PdfContentByte.ALIGN_LEFT, "1234567890", 450, 20,
0);
stamp.close();
reader.close();
} catch
(IOException iOE) {
throw new
WorkSheetCreationException("Template File non accedibile");
}
Please could someone help me on this issue?
Thanks in advance.
Max