Forum How do I...?

java.io.IOException: PDF header signature not found.

PrinceRecentClient
I'm getting the following exception when the convert method in Prince is being invoked...

Prince.convert(xmlInput, pdfOutput);

Here, the input is actually HTML and hence I have used the property setHTML(true) to instruct the Prince to consider the input stream as HTML.

It runs perfectly in my local Windows machine, but the below error appears in the (Linux server)Distributed environment only. Though I could see no reason for this failure with the environment... I'm still not sure of the problem...

java.io.IOException: PDF header signature not found.
at com.lowagie.text.pdf.PRTokeniser.checkPdfHeader(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readPdf(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)

Has anyone come across this issue? How to overcome this...?. Thanks...
mikeday
This exception is not coming from Prince, it is coming from whatever tool you are using to try to read the generated PDF file. Is convert() returning false? Can you call setLog() to specify a log file to see if Prince is producing any error or warning messages?
PrinceRecentClient
Mike,

As you said, I verified the IsConvert method - It does returns False. Moreover I added the setLog() file and I could see the following error;

Fri Nov 11 15:42:09 2011: Converting document...
Fri Nov 11 15:42:09 2011: warning: no glyphs for character U+0043, fallback to '?'
Fri Nov 11 15:42:09 2011: internal error: no available fonts
Fri Nov 11 15:42:09 2011: ---- end

We are using UTF-8 for HTML encoding, Does it have something to do with this error?
If so, What type of Encoding is supported for PRINCE in Linux ? Thanks in advance for your help...
mikeday
The "no available fonts" error is the main problem: you need to install some fonts on your Linux server, such as the Microsoft Core Fonts (msttcorefonts) or DejaVu fonts, as described here.
PrinceRecentClient
Mike,
We installed the required fonts and its Working now!!! Thanks for your timely support...
Dharani
I'm getting the following exception While generating PDF

It happens some times only Can You Please give me solution

2016-09-21 12:02:38,966 ERROR [STDERR] (http-0.0.0.0-8180-46) java.io.IOException: PDF header signature not found.

2016-09-21 12:02:38,968 ERROR [STDERR] (http-0.0.0.0-8180-46) at com.lowagie.text.pdf.PRTokeniser.checkPdfHeader(Unknown Source)

2016-09-21 12:02:38,968 ERROR [STDERR] (http-0.0.0.0-8180-46) at com.lowagie.text.pdf.PdfReader.readPdf(Unknown Source)

2016-09-21 12:02:38,969 ERROR [STDERR] (http-0.0.0.0-8180-46) at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)

2016-09-21 12:02:38,970 ERROR [STDERR] (http-0.0.0.0-8180-46) at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)

2016-09-21 12:02:38,970 ERROR [STDERR] (http-0.0.0.0-8180-46) at com.cgsl.neura.clinical.LabInterFacePrintAction.getLabPrintwithHeader(LabInterFacePrintAction.java:13794)

2016-09-21 12:02:38,971 ERROR [STDERR] (http-0.0.0.0-8180-46) at com.cgsl.neura.clinical.LabInterFaceDBAction.labPrintwithheader(LabInterFaceDBAction.java:5215)

2016-09-21 12:02:38,972 ERROR [STDERR] (http-0.0.0.0-8180-46) at sun.reflect.GeneratedMethodAccessor6674.invoke(Unknown Source)

2016-09-21 12:02:38,973 ERROR [STDERR] (http-0.0.0.0-8180-46) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

2016-09-21 12:02:38,973 ERROR [STDERR] (http-0.0.0.0-8180-46) at java.lang.reflect.Method.invoke(Method.java:597)

2016-09-21 12:02:38,974 ERROR [STDERR] (http-0.0.0.0-8180-46) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:266)

2016-09-21 12:02:38,975 ERROR [STDERR] (http-0.0.0.0-8180-46) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:167)

2016-09-21 12:02:38,975 ERROR [STDERR] (http-0.0.0.0-8180-46) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:413)

2016-09-21 12:02:38,976 ERROR [STDERR] (http-0.0.0.0-8180-46) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:225)
mikeday
Are you getting any errors from Prince?