Troubleshooting PDF Parsing Errors in IronPDF

When attempting to parse a PDF document using IronPDF, you might encounter the following exception:

Unhandled exception. System.IO.IOException: PDF can not be opened as a PDF.  May be an incorrect file type or a password is required.
Please check file for corruption or validity by a 3rd party at: https://www.pdf-online.com/osa/validate.aspx

This error typically occurs when loading a PDF document into a PdfDocumentobject using the following code:

var pdf  = PdfDocument.FromFile("Test.pdf");
var pdf  = PdfDocument.FromFile("Test.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

Possible Causes

  1. Password-Protected PDF
  • Owner Password: The most common reason for this exception is that the PDF is protected by an Owner Password. When a PDF has an owner password, it restricts certain actions, such as editing or copying. To load such a document, you must supply the password.
  1. Corrupted PDF
  • The PDF file may be corrupted or not a valid PDF format. A corrupted file can cause IronPDF to fail during parsing.

Solutions

  1. Handling Password-Protected PDFs

If you know the password for the PDF, you can pass it to the PdfDocument.FromFile() method:

var pdf = PdfDocument.FromFile("test.pdf", "ownerpassword");
var pdf = PdfDocument.FromFile("test.pdf", "ownerpassword");
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

You can also verify if the file is password-protected by checking its properties in Adobe Acrobat. For more information on identifying the security status of a PDF, refer to this article.

  1. Dealing with Corrupted PDFs

To check if the PDF file is corrupted, use a third-party validation tool. If the file is corrupted, IronPDF will not be able to parse it.

If these troubleshooting steps don't resolve the issue, please submit an Engineering Support Request for further assistance from our support engineers.