You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Luiz F Estivalet (JIRA)" <ji...@apache.org> on 2016/02/26 16:32:18 UTC

[jira] [Created] (PDFBOX-3252) java.lang.ExceptionInInitializerError in PDFBox

Luiz F Estivalet created PDFBOX-3252:
----------------------------------------

             Summary: java.lang.ExceptionInInitializerError in PDFBox
                 Key: PDFBOX-3252
                 URL: https://issues.apache.org/jira/browse/PDFBOX-3252
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 2.0.0
         Environment: Windows 7 64 bit
PDFBox 2.0.0-RC3
            Reporter: Luiz F Estivalet


import java.io.IOException;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

public class TestPDF {

    private void createPDF() throws IOException {

        // Create a document and add a page to it
        PDDocument document = new PDDocument();
        PDPage page = new PDPage();
        document.addPage(page);

        // Create a new font object selecting one of the PDF base fonts
        PDFont font = PDType1Font.HELVETICA_BOLD;

        // Start a new content stream which will "hold" the to be created content
        PDPageContentStream contentStream = new PDPageContentStream(document, page);

        // Define a text content stream using the selected font, moving the cursor and drawing the text "Hello World"
        contentStream.beginText();
        contentStream.setFont(font, 12);
        contentStream.moveTextPositionByAmount(100, 700);
        contentStream.drawString("Hello World");
        contentStream.endText();

        // Make sure that the content stream is closed:
        contentStream.close();

        // Save the results and ensure that the document is properly closed:
        document.save("Hello World.pdf");
        document.close();

    }

    public static void main(String[] args) throws Exception {

        TestPDF t = new TestPDF();
        t.createPDF();
    }

}

And I don't know I'm getting:

Exception in thread "main" java.lang.ExceptionInInitializerError
    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:114)
    at org.apache.pdfbox.pdmodel.font.PDType1Font.<clinit>(PDType1Font.java:76)
    at br.jus.trt4.TestPDF.createPDF(TestPDF.java:21)
    at br.jus.trt4.TestPDF.main(TestPDF.java:45)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.loadDiskCache(FileSystemFontProvider.java:387)
    at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.<init>(FileSystemFontProvider.java:218)
    at org.apache.pdfbox.pdmodel.font.FontMapperImpl$DefaultFontProvider.<clinit>(FontMapperImpl.java:132)
    ... 8 more



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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