ImageGear .NET - Updated
SaveCompressed(String,ImGearCompressOptions) Method
Example 




ImageGear24.Formats.Pdf Assembly > ImageGear.Formats.PDF Namespace > ImGearPDFDocument Class > SaveCompressed Method : SaveCompressed(String,ImGearCompressOptions) Method
File name of file to be saved.
Options used for compressing PDF document.
Save highly-compressed PDF document to a file on disk.
Syntax
'Declaration
 
Public Overloads Sub SaveCompressed( _
   ByVal fileName As String, _
   ByVal compressOptions As ImGearCompressOptions _
) 
'Usage
 
Dim instance As ImGearPDFDocument
Dim fileName As String
Dim compressOptions As ImGearCompressOptions
 
instance.SaveCompressed(fileName, compressOptions)
public void SaveCompressed( 
   string fileName,
   ImGearCompressOptions compressOptions
)
public: void SaveCompressed( 
   string* fileName,
   ImGearCompressOptions* compressOptions
) 
public:
void SaveCompressed( 
   String^ fileName,
   ImGearCompressOptions^ compressOptions
) 

Parameters

fileName
File name of file to be saved.
compressOptions
Options used for compressing PDF document.
Remarks

ImageGear .NET improves the overall size of saved PDF documents by reducing or removing data structures in the PDF document, specifically:

WARNING: Re-compressing Images with JBIG2 will invalidate PDF/X compliant documents.

WARNING: Removing embedded Standard Type 1 Fonts will invalidate PDF/X compliant documents.

WARNING: Removing embedded Standard Type 1 Fonts will invalidate PDF/A compliant documents when visible text is affected.

File size improvements will vary with each PDF file. In some cases, file size reduction is dramatic. Re-saving an optimized PDF file is not expected to further reduce its size. If saving a compressed PDF would result in an increase in file size, the original document is saved instead.

Example
using System;
using System.IO;
using System.Text;

using ImageGear.Core;
using ImageGear.Formats;
using ImageGear.Windows.Forms;
using ImageGear.Formats.PDF;

public String SaveCompressedPDFtoStream(String inputFileName, String outputFileName)
{
    // Load PDF document.
    ImGearPDFDocument pdfDocument = null;
    using (Stream fileStream = new FileStream(inputFileName, FileMode.Open,
       FileAccess.Read, FileShare.Read))
    {
        pdfDocument = (ImGearPDFDocument)ImGearFileFormats.LoadDocument(fileStream);
    }
 
    // Save compressed PDF document to stream.
    pdfDocument.SaveCompressed(outputFileName);
}
Imports System
Imports System.IO
Imports System.Text

Imports ImageGear.Core
Imports ImageGear.Formats
Imports ImageGear.Formats.PDF

Public Sub SaveCompressedPDFtoStream(inputFileName As String, outputFileName as String)
 
    ' Load PDF document.
    Dim pdfDocument As ImGearPDFDocument
    Using fileStream As New FileStream(inputFileName, FileMode.Open, FileAccess.Read,
            FileShare.Read)
        pdfDocument = DirectCast(ImGearFileFormats.LoadDocument(fileStream),
                ImGearPDFDocument)
    End Using

    ' Save compressed PDF document to stream.
    pdfDocument.SaveCompressed(outputFileName)

End Function
See Also

Reference

ImGearPDFDocument Class
ImGearPDFDocument Members
Overload List