Tech Specs
How-to VB.NET
How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

VB.NET PDF - How to Compress PDF in VB.NET

VB.NET PDF Document Compression and Decompression Control SDK

Look for HTML5 PDF Editor?

EdgePDF: ASP.NET PDF Editor is the best HTML5 PDF Editor and ASP.NET PDF Viewer based on XDoc.PDF, JQuery, HTML5. It supports ASP.NET MVC and WebForms projects.

A standalone VB.NET PDF document compressing SDK that can perform PDF compression without any Adobe product

A high PDF compressing ratio control, built on .NET Framework 2.0

Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint

Support large 1000 + page PDF document compression in VB.NET WinForms application

Compress & decompress PDF document file while maintaining original content of target PDF document file

Remove bookmarks, annotations, watermark, page labels and article threads from PDF while compressing

Also a preview component enables compressing and decompressing in preview in ASP.NET class

Also able to uncompress PDF file in VB.NET programs

Support PDF encryption in VB.NET class applications

A professional PDF compression and decompression library, which compatible with Windows 32-bit or 64-bit operating system

Offer flexible and royalty-free developing library license for VB.NET programmers to compress PDF file

VB.NET PDF Document Optimization

PDF document optimization is mainly to reduce or minimize original PDF document size, mainly methods are given below:

Reduce image resources: Since images are usually or large size, images size reducing can help to reduce PDF file size effectively. The disadvantage is that image resources pixel point might be lost.

Reduce font resources: Font resources will also take up too much space, glyph file unreferenced can be deleted. But it's too complicated to implement this work.

Delete unimportant contents:

  Flatten form fields

  JavaScript actions

  Alternate images

  Embedded page thumbnails

  Document tags

  Embedded print settings

  Embedded search index


  Comments, forms and multimedia

  Document and metadata

  All object data

  File attachment

  External cross references

  Private data of other applications

  Hidden layer content

  Convert smooth lines to curves

  Detect and merge image fragments

  Flatten visible layers

VB.NET Demo Code to Optimize An Exist PDF File in Visual C#.NET Project

Sample Code list below is mainly to optimize PDF file with multiple ways in VB.NET Class.

String inputFilePath = Program.RootPath + "\\" + "3.pdf";
String outputFilePath = Program.RootPath + "\\" + "3_optimized.pdf";

'create optimizing options
Dim ops As PDFOptimizeOptions = New PDFOptimizeOptions()

'--Options for Monochrome Image
'to enable dowmsampling for those images with resolution higher than 300 dpi to 150 dpi
ops.MonochromeImageOptions.DownsampleMode = ImageDownsampleMode.Bicubic
ops.MonochromeImageOptions.MaxResolutionLimit = 300.0F
ops.MonochromeImageOptions.TargetResolution = 150.0F
'to change image compression mode to JBIG2
ops.MonochromeImageOptions.KeepCompressionMode = False
ops.MonochromeImageOptions.Compression = PDFCompression.JBIG2Decode

'--Options for Grayscale Image--
'to enable downsampling for those images with resolution higher than 120 dip to 96dpi
ops.GrayscaleImageOptions.DownsampleMode = ImageDownsampleMode.Bilinear
ops.GrayscaleImageOptions.MaxResolutionLimit = 120.0F
ops.GrayscaleImageOptions.TargetResolution = 96.0F
'to change image compression mode to DCT
ops.GrayscaleImageOptions.KeepCompressionMode = False
ops.GrayscaleImageOptions.Compression = PDFCompression.DCTDecode
'set quality level, only available for compression mode DCT
ops.GrayscaleImageOptions.JPEGImageQualityLevel = JPEGImageQualityLevel.High

'--Options for Color Image
'to enable downsampling for those images with resolution higher than 120 dpi to 96dpi
ops.ColorImageOptions.DownsampleMode = ImageDownsampleMode.Bicubic
ops.ColorImageOptions.MaxResolutionLimit = 120.0F
ops.ColorImageOptions.TargetResolution = 96.0F
'to change image compression mode to DCT
ops.ColorImageOptions.KeepCompressionMode = False
ops.ColorImageOptions.Compression = PDFCompression.DCTDecode
'set quality level, only available for compression mode DCT
ops.ColorImageOptions.JPEGImageQualityLevel = JPEGImageQualityLevel.Highest

'apply optimizing
PDFOptimizer.Optimize(inputFilePath, outputFilePath, ops)