Lỗi could not sign document pdf header signature not found năm 2024

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Discussion:

[iText-questions] PDF Header signature not found

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.

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.

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.

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.

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?

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.

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.)

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.

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.

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.

Hi 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...