Set PDF Version with iTextSharp – C# and VB.NET

Changing the PDF version with iTextSharp is fairly easy, all you have to do is create a stamper and pass an extra parameter with the PDF version you want. Below is the code snippet to accomplish this in C# and VB.NET.

[topads][/topads]

C# Code

PdfReader reader = new PdfReader(fileBytes);
MemoryStream ms = new MemoryStream();
PdfStamper stamper = new PdfStamper(reader, ms, "4"); //The number 4 changes the PDF version to 1.4 (or Acrobat 5)
stamper.Close();
fileBytes = ms.ToArray();
ms.Flush();
reader.Close();

VB.Net Code

Dim reader As PdfReader = New PdfReader(fileBytes)
Dim ms As MemoryStream = New MemoryStream()
Dim stamper As PdfStamper = New PdfStamper(reader, ms, "4") 'The number 4 changes the PDF version to 1.4 (or Acrobat 5)
stamper.Close()
fileBytes = ms.ToArray()
ms.Flush()
reader.Close()

Here is a nice table showing the different versions

Acrobat Product VersionPDF
Version
New Features Affecting
Backwards Compatibility
Acrobat 8PDF 1.7
  • Reader Enabled Forms
  • PDF Packages
  • PDF 1.7 XML Forms
Acrobat 7PDF 1.6
  • Reader Enabled Review
  • Security Envelopes
  • XML Forms
  • Embedded multimedia including 3D content
  • Bookmark Compression
Acrobat 6PDF 1.5
  • Linked multimedia
Acrobat 5PDF 1.4
  • OCR Text Layer

Table came from this Adobe blog.

[bottomads][/bottomads]

Spread the love

One thought on “Set PDF Version with iTextSharp – C# and VB.NET

  1. lorretadt says:

    You can download and try this interesting high quality software on rasteredge page for c# accessible links in pdf http://www.rasteredge.com/how-to/csharp-imaging/pdf-edit-bookmark-outline/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.