You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Clark, Raymond C" <Ra...@ehi.com> on 2017/05/10 21:38:26 UTC

Exception using PDFBox

I was making some changes to try and improve performance and I started getting this exception:

[log4j][ServiceQueueSyncProcessThread: '0' for queue ProductsStmtService][2017-05-10 16:24:25,354] org.apache.pdfbox.pdmodel.font.FileSystemFontProvider ERROR Could not write to font cache
java.io.FileNotFoundException: /opt/tomcat/.pdfbox.cache (Permission denied)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
        at java.io.FileWriter.<init>(FileWriter.java:90)
        at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.saveDiskCache(FileSystemFontProvider.java:288)
        at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.<init>(FileSystemFontProvider.java:226)
        at org.apache.pdfbox.pdmodel.font.FontMapperImpl$DefaultFontProvider.<clinit>(FontMapperImpl.java:132)
        at org.apache.pdfbox.pdmodel.font.FontMapperImpl.getProvider(FontMapperImpl.java:151)
        at org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFont(FontMapperImpl.java:415)
        at org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFontBoxFont(FontMapperImpl.java:378)
        at org.apache.pdfbox.pdmodel.font.FontMapperImpl.getFontBoxFont(FontMapperImpl.java:352)
        at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:115)
        at org.apache.pdfbox.pdmodel.font.PDType1Font.<clinit>(PDType1Font.java:76)
        at com.erac.bds.listener.products.pdf.PDFGenerator.buildFontMap(PDFGenerator.java:885)
        at com.erac.bds.listener.products.pdf.PDFGenerator.initializeFile(PDFGenerator.java:100)
        at com.erac.bds.listener.products.Products.processTemplate(Products.java:140)
        at com.erac.bds.listener.products.Products.processOtherTypeFileTemplate(Products.java:132)
        at com.erac.bds.listener.products.Products.processMessage(Products.java:98)
        at com.erac.bds.listener.BaseListener.process(BaseListener.java:78)
        at com.erac.servicequeue.ServiceMessageProcessor.processASync(ServiceMessageProcessor.java:81)
        at com.erac.servicequeue.sync.ServiceQueueSyncProcess.run(ServiceQueueSyncProcess.java:216)

The PDFGenerator.java:885 line is the line that sets up the HELVETICA font:

             try {
                    font = PDType1Font.HELVETICA;
                    fontBold = PDType1Font.HELVETICA_BOLD;
             } catch(Exception e) {
                    throw new ProductRequestException("Unable to find Fonts/arial.ttf", e);
             }

I wasn't getting this before, what would be causing pdfbox to try and write out a cache file?

Thank you,
Ray


________________________________

CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.



Re: Exception using PDFBox

Posted by Tilman Hausherr <TH...@t-online.de>.
The error is harmless, the cache won't be saved. How to avoid it? See this:

     private File getDiskCacheFile()
     {
         String path = System.getProperty("pdfbox.fontcache");
         if (path == null)
         {
             path = System.getProperty("user.home");
             if (path == null)
             {
                 path = System.getProperty("java.io.tmpdir");
             }
         }
         return new File(path, ".pdfbox.cache");
     }


So set one of these properties, and the problem is solved.

Tilman

Am 10.05.2017 um 23:38 schrieb Clark, Raymond C:
> I was making some changes to try and improve performance and I started getting this exception:
>
> [log4j][ServiceQueueSyncProcessThread: '0' for queue ProductsStmtService][2017-05-10 16:24:25,354] org.apache.pdfbox.pdmodel.font.FileSystemFontProvider ERROR Could not write to font cache
> java.io.FileNotFoundException: /opt/tomcat/.pdfbox.cache (Permission denied)
>          at java.io.FileOutputStream.open(Native Method)
>          at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
>          at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
>          at java.io.FileWriter.<init>(FileWriter.java:90)
>          at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.saveDiskCache(FileSystemFontProvider.java:288)
>          at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.<init>(FileSystemFontProvider.java:226)
>          at org.apache.pdfbox.pdmodel.font.FontMapperImpl$DefaultFontProvider.<clinit>(FontMapperImpl.java:132)
>          at org.apache.pdfbox.pdmodel.font.FontMapperImpl.getProvider(FontMapperImpl.java:151)
>          at org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFont(FontMapperImpl.java:415)
>          at org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFontBoxFont(FontMapperImpl.java:378)
>          at org.apache.pdfbox.pdmodel.font.FontMapperImpl.getFontBoxFont(FontMapperImpl.java:352)
>          at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:115)
>          at org.apache.pdfbox.pdmodel.font.PDType1Font.<clinit>(PDType1Font.java:76)
>          at com.erac.bds.listener.products.pdf.PDFGenerator.buildFontMap(PDFGenerator.java:885)
>          at com.erac.bds.listener.products.pdf.PDFGenerator.initializeFile(PDFGenerator.java:100)
>          at com.erac.bds.listener.products.Products.processTemplate(Products.java:140)
>          at com.erac.bds.listener.products.Products.processOtherTypeFileTemplate(Products.java:132)
>          at com.erac.bds.listener.products.Products.processMessage(Products.java:98)
>          at com.erac.bds.listener.BaseListener.process(BaseListener.java:78)
>          at com.erac.servicequeue.ServiceMessageProcessor.processASync(ServiceMessageProcessor.java:81)
>          at com.erac.servicequeue.sync.ServiceQueueSyncProcess.run(ServiceQueueSyncProcess.java:216)
>
> The PDFGenerator.java:885 line is the line that sets up the HELVETICA font:
>
>               try {
>                      font = PDType1Font.HELVETICA;
>                      fontBold = PDType1Font.HELVETICA_BOLD;
>               } catch(Exception e) {
>                      throw new ProductRequestException("Unable to find Fonts/arial.ttf", e);
>               }
>
> I wasn't getting this before, what would be causing pdfbox to try and write out a cache file?
>
> Thank you,
> Ray
>
>
> ________________________________
>
> CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org