pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Reichman" <alex.reich...@syncreon.com>
Subject RE: PDFBox and barcode fonts
Date Mon, 07 Dec 2009 18:15:28 GMT
Hello Andreas,

 

Thanks for your reply!

 

I signed up to mailing list but when I am trying to sign in it freeze my screen.

 

I have downloaded the latest versions of PdfBox and FontBox. There is no error message (org.pdfbox.pdmodel.font.PDType0Font
cannot 

> be cast to org.pdfbox.pdmodel.font.PDType1Font) but I am still getting the exception
NULL and report is not printed. I can print easily the report without barcodes.

 

while (setInt.hasNext()) {

                        String val = (String) setInt.next();

 

                        PDType1Font pdt = (PDType1Font) map.get(val);   // Error is here

                        write_message("'" + val + " " + pdt.getFontDescriptor().getFontName()
+

                            "'");

                        

                        // Load the Fonts into the Fx Location in the PDF.

                        write_message("Attemting to loadFontsByName");

                        PDFont currFont = this.loadFontByName(document,

                                pdt.getFontDescriptor().getFontName(), val);

 

                        if (currFont != null) {

                            currentPage.findResources().getFonts().put(val, currFont);

                        }

                    }

DEBUG MESSAGE DirectPrint0: Font org.apache.pdfbox.pdmodel.font.PDTrueTypeFont@10ebe18   --
this is the font "V100025_.TTF"

DEBUG MESSAGE DirectPrint0: Pages list is NOT empty

DEBUG MESSAGE DirectPrint0: Map is: {F1=org.apache.pdfbox.pdmodel.font.PDType1Font@161f39e,
F0=org.apache.pdfbox.pdmodel.font.PDType1Font@1c13d0b, F2=org.apache.pdfbox.pdmodel.font.PDType0Font@18eb7b8}

DEBUG MESSAGE DirectPrint0: Map KeySet

DEBUG MESSAGE DirectPrint0: Map iterator inited

DEBUG MESSAGE DirectPrint0: 'F1 Arial,Bold'

DEBUG MESSAGE DirectPrint0: Attemting to loadFontsByName

DEBUG MESSAGE DirectPrint0: Running loadFontByName

DEBUG MESSAGE DirectPrint0: Font not loaded: Arial,Bold

DEBUG MESSAGE DirectPrint0: Font not loaded: Arial,Bold

DEBUG MESSAGE DirectPrint0: 'F0 Arial'

DEBUG MESSAGE DirectPrint0: Attemting to loadFontsByName

DEBUG MESSAGE DirectPrint0: Running loadFontByName

DEBUG MESSAGE DirectPrint0: Font not loaded: Arial

DEBUG MESSAGE DirectPrint0: Font not loaded: Arial

DEBUG MESSAGE DirectPrint0: Exception in sendPDFURLToPrinter: null

DEBUG MESSAGE DirectPrint0: Document Closed

 

I have also tried to load the font as it explained http://pdfbox.apache.org/userguide/fonts.html
(see the code below) but this is not working either and its giving the exception null as well.

 

int index1 = val.indexOf("F2") ;

write_message (" index " + index1 ) ;

write_message("Val " + val) ;

                  if ( index1 != -1 ) {

                        PDFont currFont = PDTrueTypeFont.loadTTF(document, new File( "C:\\Windows\\Fonts\\V100025_.TTF"));

                        write_message("font " + currFont ) ;

                        if (currFont != null) 

                           currentPage.findResources().getFonts().put(val, currFont) ;   


                  }

 

Any help will be much appreciated

Thanks

 

s y n c r e o n automotive

Alex Reichman

 

Software Development Lead

Direct NA

   +1 (905) 755-6136

Mobile NA

   +1 (416) 209-2047 

Email

alex.reichman@syncreon.com

 

 

www.syncreon.com

-----Original Message-----
From: Andreas Lehmkühler [mailto:andreas@lehmi.de] 
Sent: Monday, December 07, 2009 2:10 AM
To: Alex Reichman
Cc: users@pdfbox.apache.org
Subject: Re: PDFBox and barcode fonts

 

Hi Alex,

 

Alex Reichman wrote:

>  

> 

> Dear Andreas,

> 

> I saw your thread on markmail.org and I have one question to ask you 

> regarding PdfBox.

> 

> We are using Pdfbox.-0.7.4 for sending 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()+"'");

> 

>                         // write_message("Printing after cast " + 

> "'"+val+" "+pdt.getFontDescriptor().getFontName()+"'");

> 

>                         PDFont currFont = 

> this.loadFontByName(document,pdt.getFontDescriptor().getFontName(),val);

> 

>                         if(currFont != null)

> 

>                         {

> currentPage.findResources().getFonts().put(val,currFont);

>                         }

> 

>                     }

> 

> 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 or advice  will be much appreciated.

You're obviously expecting a type1 font but your pdf contains type0 fonts. 

Consequently your PDType1Font-cast has to throw an exception.

I suggest to upgrade pdfbox to the 0.8-version [1]. It includes a lot of 

improvements and fixes, probably your alias mapping will not be needed anymore.

 

> Thanks,

> Alex * <http://www.syncreon.com/>*

Please use our mailinglist [2] for further questions. I've cc'd my answer to the 

users list.

 

BR

Andreas Lehmkühler

 

[1] http://pdfbox.apache.org/download.html

[2] http://pdfbox.apache.org/mailing-list.html

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message