-
PdfBox and barcode fonts
Hello,
We are using Pdfbox to send the PDF file to client printer when printing from Oracle Reports 11g
When I am adding alias mapping for barcode font C39P24DmTt = "V100025_.TTF" I am getting the following error:
Java code:
while (setInt.hasNext()) {
String val = (String)setInt.next();
write_message("Before cast");
PDType1Font pdt = (PDType1Font)map.get(val); //error is here
write_message("After cast");
write_message("'"+val+" "+pdt.getFontDescriptor().getFontName()+"'");
PDFont currFont = this.loadFontByName(document,pdt.getFontDescriptor ().getFontName(),val);
if(currFont != null)
{
currentPage.findResources().getFonts().put(val,cur rFont);
}
}
Error
DEBUG MESSAGE DirectPrint24: Map is: {F1=org.pdfbox.pdmodel.font.PDType0Font@91d7c, F0=org.pdfbox.pdmodel.font.PDType0Font@6ee404, F2=org.pdfbox.pdmodel.font.PDType0Font@3bfc47}
DEBUG MESSAGE DirectPrint24: org.pdfbox.pdmodel.font.PDType0Font cannot be cast to org.pdfbox.pdmodel.font.PDType1Font
It looks like this font is not recognizable.
Any help will be much appreciated.
Thanks,
Alex
-
you say that PDType1Font pdt = (PDType1Font)map.get(val); //error is here is a pdtype1font but its a pdtype0font
-
Interestingly, PDType0Font is a child class of PDType1Font, so I'm not sure why the cast doesn't work. PDType0Font (pdfbox-0.8.0-incubating API)
-
Thanks for your reply.
Sorry for my misunderstanding:
Do you mean line
PDType1Font pdt = (PDType1Font)map.get(val);
must be replaced by
PDType1Font pdt = (PDType0Font)map.get(val);
Thanks
-
You haven't got two versions of PDFBox lying around have you?
As Fubarable says, according to the API (and the src code for that matter) that cast should work.
-
Thank you for your reply. I have compiled my program only against PDFBox-0.7.3.jar