Click here to Skip to main content
15,118,573 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi! all,
I am integrating PDF file in my project using ASP.Net c#.
If it's an older version of PDF it doesn't open....
using c# how can i check for different versions of .Pdf , If it's an older version it can prompt to update?
Updated 11-Mar-11 2:23am
Sunasara Imdadhusen 11-Mar-11 6:54am
Did you try Google?
Nischal Bhatt 11-Mar-11 7:22am
yes i googled it...but couldn't come up wid a solution. :(

The quick and dirty way to determine the version of a PDF file is parsing the first line from PDF Document File Header (See PDF reference[^], '7.5.2 File Header', p.39).

According to specification:
'The first line of a PDF file shall be a header consisting of the 5 characters %PDF– followed by a version number of the form 1.N, where N is a digit between 0 and 7.'

You can check out this by simply opening the content of a PDF file in text editor (f.e. I use Notepad++) and see the first line. The version numbers should be there, right after '%PDF–'.
This method is very simple and does not require additional libraries and SDKs, you can easily read and parse the first line of a PDF file using C#. But keep in mind that not all of the PDF documents are standard conforming and Adobe Reader often opens these documents too. So if you need a stable version check for all PDF files better use an additional PDF library. For such libraries you can check out this[^].

P.S. You say:
'If it's an older version of PDF it doesn't open....'

This is not very clear. What is this program that could not open older PDF versions. Is it Adobe Reader?
And also which versions you determine as 'older': VER < 1.2, VER < 1.5 or VER < 1.7?
It is better to elaborate a bit about this issues.


After reading your question for second time I realized that you didn't clarified what your phrase 'version of PDF' exactly means. First I thought that it refers to the version of the PDF file. Now I think that you could also want to check the PDF Reader version of your clients. If this is the case, have a look here[^] for determining if Adobe Reader is installed and if yes, which version is.

Sorry your question is not very clear to me and I've tried to cover both PDF file version and PDF reader version.

Nischal Bhatt 14-Mar-11 5:42am
Hey! Nuri Ismail,
Thanks alot and your help is really appreciated.
Nuri Ismail 14-Mar-11 6:02am
You're welcome Nischal! :)
Nischal Bhatt 11-Mar-11 7:32am
i have to check using ASP.Net with C# as my code behind....hpw can Adobe SDK help??
Piccadilly Yum Yum 11-Mar-11 8:12am
i see, in the sdk, xml rendering tools for pdf documents, you can use xml from c# then exact desired information

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900