Discussion:
[iText-questions] PDF Header signature not found
tmiddlebrook
2010-08-18 17:34:31 UTC
Permalink
I am getting the PDF header signature not found error. I seen in some posts I
need to add "%PDF-1." and some post say I need to subtract "%PDF-1". What do
I need to do to get rid this error? Either on the code side or on the pdf
side. The file I am using works sometimes but sometimes it throws this
error. Any suggestions?

Thanks in Advance.
--
View this message in context: http://itext-general.2136553.n4.nabble.com/PDF-Header-signature-not-found-tp2330180p2330180.html
Sent from the iText - General mailing list archive at Nabble.com.
1T3XT info
2010-08-19 09:40:34 UTC
Permalink
Post by tmiddlebrook
I am getting the PDF header signature not found error. I seen in some posts I
need to add "%PDF-1." and some post say I need to subtract "%PDF-1". What do
I need to do to get rid this error? Either on the code side or on the pdf
side. The file I am using works sometimes but sometimes it throws this
error. Any suggestions?
When you get such an error, you are trying to open a file that IS NOT A
PDF. You may think you have created a PDF, you may even have created a
PDF, but you are not opening a PDF.

Please explain the context.

For instance: if you are creating a PDF in a web application, the PDF
may have been created on the server, but the server is definitely
sending something else to the browser.

Most likely the server is sending a HTML page, for instance with a 500
error message. Please read chapter 9 in the 2nd edition of iText in
Action and go over all the rules of thumb to see what could have gone wrong.
tmiddlebrook
2010-08-19 11:59:25 UTC
Permalink
This is what I am trying to do. I want to upload a pdf to a database, but it
needs be inserted into different tables based on different conditions. For
example if the pdf is password protected it goes into one table, or if the
page count is greater than 5 pages it goes into another. Currently I am
still testing the app, and sometimes the app accepts the pdf and other times
I am getting the PDF header not found issue. So to repond back to your
comment, yes it is a pdf, I can open it in adobe. I am not creating a pdfs
just trying to read its contents, and attributes of the pdf.

Any Suggestions?

Thanks.
--
View this message in context: http://itext-general.2136553.n4.nabble.com/PDF-Header-signature-not-found-tp2330180p2331059.html
Sent from the iText - General mailing list archive at Nabble.com.
1T3XT info
2010-08-19 13:12:57 UTC
Permalink
This is what I am trying to do. I want to upload a pdf to a database, but it
needs be inserted into different tables based on different conditions. For
example if the pdf is password protected it goes into one table, or if the
page count is greater than 5 pages it goes into another.
OK, so the end user has an HTML field for file upload and can upload a
PDF. You get the byte[] on the server side and you feed it to PdfReader,
but PdfReader complains that the file doesn't start with "%PDF-".

If the file doesn't start with "%PDF-", it's either NOT a PDF file, or
you aren't extracting the PDF correctly from the InputStream received by
the HttpRequest.
Currently I am
still testing the app, and sometimes the app accepts the pdf and other times
I am getting the PDF header not found issue. So to repond back to your
comment, yes it is a pdf, I can open it in adobe.
You can't open it in Adobe, unless you go to San José, California. Adobe
is a company, not a product ;-)

You can open it in Adobe Reader, but what if you open it in a text
editor such as Wordpad, Notepad++, vi,...? Does it start with "%PDF-" or
does it have other characters? Maybe Adobe Reader ignores rubbish that
is added at the start of the file.
I am not creating a pdfs
just trying to read its contents, and attributes of the pdf.
Any Suggestions?
Save the faulty PDFs.
Look at them in a plain text editor to check if they start with "%PDF-".
Try opening them with PdfReader in a simple standalone application.
If the standalone application produces an error, post the PDF and the
standalone application.
tmiddlebrook
2010-08-19 14:03:50 UTC
Permalink
I opened the file in notepadd++ and the first line is %PDF-1.7. I will check
to make sure I am pulling out the correct variabels from the input stream.
But do I understand it correctly do I need to remove %PDF-1.7 or do I need
to add something to that string?
Post by 1T3XT info
You can't open it in Adobe, unless you go to San José, California. Adobe
is a company, not a product ;-)
HAHAHA, I guess I should have expected that one.

Thanks :)
--
View this message in context: http://itext-general.2136553.n4.nabble.com/PDF-Header-signature-not-found-tp2330180p2331234.html
Sent from the iText - General mailing list archive at Nabble.com.
1T3XT info
2010-08-19 14:56:41 UTC
Permalink
Post by tmiddlebrook
I opened the file in notepadd++ and the first line is %PDF-1.7. I will check
to make sure I am pulling out the correct variabels from the input stream.
But do I understand it correctly do I need to remove %PDF-1.7 or do I need
to add something to that string?
If it starts with "%PDF-1.7" then you have a correct PDF, and the
exception "PDF header signature not found error" shouldn't occur.

What if you use that PDF in a standalone example?
Does the error occur then? (If so, send us the PDF.)
tmiddlebrook
2010-08-19 14:59:22 UTC
Permalink
I will try that solution.

Thanks for everything.
--
View this message in context: http://itext-general.2136553.n4.nabble.com/PDF-Header-signature-not-found-tp2330180p2331344.html
Sent from the iText - General mailing list archive at Nabble.com.
tmiddlebrook
2010-08-23 13:51:47 UTC
Permalink
Let me first say thank you for all your help. I wasn't using the correct
variable within the IO Stream. I was checking the sizes and thought I was
using the correct variable but I wasn't. Again Thanks for all your help. As
thanks I will purchase another copy of your itext book (the ebook version).
--
View this message in context: http://itext-general.2136553.n4.nabble.com/PDF-Header-signature-not-found-tp2330180p2335140.html
Sent from the iText - General mailing list archive at Nabble.com.
itext2012
2012-05-14 21:10:43 UTC
Permalink
Hi

I am also getting this error. Let me explain what i am doing.

I need to merge 100 pdf files into single pdf file and that single pdf is
created dynamically. when there is no single pdf file present in the folder
it will get created. But if there is already one then i am deleting it and
creating another with same name.This is where i am getting this error.

An Error occurred while merging the PDF files PDF header signature not
found.
An Error occurred while closing the Document The document has no pages.


thanks in advance.




--
View this message in context: http://itext-general.2136553.n4.nabble.com/PDF-Header-signature-not-found-tp2330180p4633140.html
Sent from the iText - General mailing list archive at Nabble.com.
Alexis Pigeon
2012-05-15 07:41:05 UTC
Permalink
Hi itext2012,
Post by itext2012
Hi
I am also getting this error. Let me explain what i am doing.
I need to merge 100 pdf files into single pdf file and that single pdf is
created dynamically. when there is no single pdf file present in the folder
it will get created. But if there is already one then i am deleting it and
creating another with same name.This is where i am getting this error.
An Error occurred while merging the PDF files PDF header signature not
found.
An Error occurred while closing the Document The document has no pages.
Please don't hijack an old thread, create your own, and if needed, make a
reference to this one.
In your new thread, remember to add standalone code sample so that we can
reproduce the error.
As you already know, crystal balls are broken.

Cheers,
alexis

Loading...