HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › getting NullPointerException when "Content-Type" is set

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26636

    Hello,
    I keep getting NPEs when I’m attempting to render an RTF doc.

    Below is the test.

    Thanks,
    Nathan

    package com.nwest.tests.pd4ml;
    
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.StringReader;
    
    import org.zefer.pd4ml.PD4Constants;
    import org.zefer.pd4ml.PD4ML;
    
    public class PDFConverterTest
    {
    private static String doesNotWork = "<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>blah</title></head><body><div>test</div></body></html>";
    private static String works = "<html xmlns="http://www.w3.org/1999/xhtml"><head><title>blah</title></head><body><div>test</div></body></html>";
    
    public static ByteArrayOutputStream createDocument(String pageOrientation, String documentContent, String format)
    throws IOException
    {
    PD4ML pd4ml = new PD4ML();
    
    if (format.equals(PD4Constants.PDF) || format.equals(PD4Constants.RTF))
    {
    pd4ml.outputFormat(format);
    }
    
    StringReader reader = new StringReader(documentContent);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    pd4ml.render(reader, baos);
    
    return baos;
    }
    
    public static void main(String args[]) {
    try {
    PDFConverterTest.createDocument("landscape", works, PD4Constants.RTF);
    System.out.println("no meta works");
    
    PDFConverterTest.createDocument("landscape", doesNotWork, PD4Constants.RTF);
    System.out.println("doesNotWork");
    
    } catch (IOException e) {
    
    }
    }
    }
    

    #28733

    Thank you for the report!

    We’ve just fixed the issue in the development build. The fix will be available with the next beta release.

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘Troubleshooting’ is closed to new topics and replies.