0

I'm trying to convert java faces page to pdf. For Example: //localhost/DataApp/Display.faces using wkhtmltopdf.

Java faces page has an Iframe which contains HTML page. In faces page I do data extraction from the database and populate the data into html form.

For the following cases wkhtmltopdf command generates the desired PDF file.

For Testing I done these executions.

When I pass google Ulr to wkhtmltopdf command generates PDF file.

When I pass HTML file path to wkhtmltopdf command (Ex: c:dataStore1/test.pdf) will generates PDF file.

But it will not work in the following scenario.(It is what actually required in my application)

When I pass the localhost url to wkhtmltopdf command (For Ex://localhost/DataApp/Display.faces) generates empty PDF file and throws null pointer exception after going out of method.

Please help me to find the workaround for the given statement.

Or else suggest any other approaches to meet the requirement.

Thank you.

UPDATE:

public String doGenerateAction() {
    try {
       String command = "F:\\HTMLTOPDF\\wkhtmltopdf\\bin\\wkhtmltopdf http://localhost:9080/DataApp/Display.faces E:\\pdfFileStore\\fileName.pdf";
        java.lang.Process p = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
        System.out.println("IO exception");
    } catch (NullPointerException e) {
        System.out.println("null pointer exception");
    }catch(IllegalArgumentException e) {
        System.out.println("illegal argumnet exception");
    }catch (Exception e) {
        System.out.println("Exception");
    }
    return "";
}

Above code doesn't throws any exception, but creates Empty PDf file.

When I Run the same wkhtmltopdf from CMD PROMPT I get null pointer exception in web server console.

nagesh
  • 307
  • 2
  • 10
  • 22

0 Answers0