SetFlateCompression, GetCompression, SetCompression

The FlateCompression method sets the flate compression level for all pages.

 

Syntax

ActiveX:

void SetFlateCompression(System.Int16 Ratio)

DLL:

long GetCompression(HANDLE hPrinter)
long SetCompression(HANDLE hPrinter, long bCompression)

 

Parameters

Ratio, bCompression

It is between 0 and 9.

0: no compression and 9: maximum compression.

hPrinter

Handle to printer returned by any of the DriverInit function calls.

 

Remarks

The DLL version does not affect a particular document (it is not a document level function). It affects all PDF files created by the DLL.

 

Remarks

 

Member of CDIntfEx.Document.

 

Example

Public Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"

    Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

    ' Declare a new cdintfex document if it does not exist in the form.

    Dim pdfDoc As New CDIntfEx.Document

 

    ' Open the document

    pdfDoc.Open("c:\temp\test.pdf")

 

    ' The SetLicenseKey method should be called after creating an object of type 

    ' CDIntfEx.Document to activate the advanced methods that require the object 

    ' activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Set Minimum Compression

    pdfDoc.SetFlateCompression(0)

 

    ' Save the document

    pdfDoc.Save("c:\temp\Without_Compression.pdf")

 

    ' Set Maximum Compression

    pdfDoc.SetFlateCompression(9)

 

    ' Save the document

    pdfDoc.Save("c:\temp\Maximum_Compression.pdf")

End Sub

public void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Converter Evaluation";

    const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

 

    // Declare a new cdintfex document if it does not exist in the form.

    CDIntfEx.Document pdfDoc = new CDIntfEx.Document();

 

    // Open the document

    pdfDoc.Open(@"c:\temp\test.pdf");

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Set Minimum Compression

    pdfDoc.SetFlateCompression(0);

 

    // Save the document

    pdfDoc.Save(@"c:\temp\Without_Compression.pdf");

 

    // Set Maximum Compression

    pdfDoc.SetFlateCompression(9);

 

    // Save the document

    pdfDoc.Save("C:\temp\\Maximum_Compression.pdf");

}

 

 // PDF Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment (lib, "CDIntf.lib")

 

using namespace std;

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "Amyuni PDF Converter Evaluation"

    #define strActivationCode "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

    #define AMYUNIPRINTERNAME "Amyuni PDF Converter"

 

    // Get a reference to the installed printer.

    // This will fail if the printer name passed to the DriverInit method is 

    // not found in the printer’s folder

    HANDLE PDF = DriverInit(AMYUNIPRINTERNAME);

 

    // The CDISetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    CDISetDefaultPrinter(PDF);

 

    // The EnablePrinter() method needs to be called right before each print job.

    // and before the configuration

    // Calling the EnablePrinter() method will start a 20 second time-out value

    EnablePrinter(PDF, strLicenseTo, strActivationCode);

 

    // Resulting PDF document stored here

    SetDefaultDirectory(PDF, "C:\temp");

 

    // Set Printer options

    SetFileNameOptions(PDF, NoPrompt);

 

    // The EnablePrinter()method needs to be called right before each print job. 

    // Calling the EnablePrinter()method will start a 20 second time-out value

    EnablePrinter(PDF, strLicenseTo, strActivationCode);

 

    // Set Compression Minimum

    SetCompression(PDF, 0);

 

    // The BatchConvert method converts a number of files to PDF.

    BatchConvertEx(PDF, "C:\temp\\*.docx");

 

 // The RestoreDefaultPrinter function resets the system default printer 

    // to the printer that was the default before the call to SetDefaultPrinter.

    RestoreDefaultPrinter(PDF);

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DriverEnd(PDF);

 

    // Destroy PDF object

    PDF = nullptr;    

 

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

import com.jacob.com.Variant;

 

public class SetCompressionFlat {

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "Amyuni PDF Converter Evaluation";

        String strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";

 

        // Declare a new cdintfex document if it does not exist in the form.

        ActiveXComponent pdfDoc = new ActiveXComponent("CDIntfEx.Document.6.5"); 

 

        // Open the document

        Dispatch.call(pdfDoc, "Open", "C:\temp\\test.pdf");

 

        // The SetLicenseKey method should be called after creating an object of type 

        // CDIntfEx.Document to activate the advanced methods that require the object 

        // activation code to work properly

        Dispatch.call(pdfDoc, "SetLicenseKey", strLicenseTo, strActivationCode);

 

        // Set Minimum Compression

        Dispatch.call(pdfDoc, "SetFlateCompression", 0);

 

        // Save the document

        Dispatch.call(pdfDoc, "Save", "C:\temp\\Without_Compression.pdf");

 

        // Set Maximum Compression

        Dispatch.call(pdfDoc, "SetFlateCompression", 9);

 

        // Save the document

        Dispatch.call(pdfDoc, "Save", "C:\temp\\Maximum_Compression.pdf");

 

        // Destroy pdfDoc object

        pdfDoc = null;

    }

}

# Constants for Activation codes

$strLicenseTo  =  "Amyuni PDF Converter Evaluation"

$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

#Declare a new cdintfex document if it does not exist in the form.

$pdfDoc = New-Object -ComObject CDIntfEx.Document.6.5

 

#Open the document

[System.__ComObject].InvokeMember('Open', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\test.pdf") 

 

#The SetLicenseKey method should be called after creating an object of type 

#CDIntfEx.Document to activate the advanced methods that require the object 

#activation code to work properly

[System.__ComObject].InvokeMember('SetLicenseKey', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, @($strLicenseTo, $strActivationCode))

 

#Set Minimum Compression

[System.__ComObject].InvokeMember('SetFlateCompression', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,0)

 

#Save the document

[System.__ComObject].InvokeMember('Save', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\Without_Compression.pdf") 

 

#Set Maximum Compression

[System.__ComObject].InvokeMember('SetFlateCompression', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,9)

 

#Save the document

[System.__ComObject].InvokeMember('Save', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\Maximum_Compression.pdf")

 

#Destroy pdfDoc object

$pdfDoc = $null 

' Constants for Activation codes

Const strLicenseTo = "Amyuni PDF Converter Evaluation"

Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

' Declare a new Document object

Dim pdfDoc

Set pdfDoc = CreateObject("CDIntfEx.Document.6.5")

 

' Open the document

pdfDoc.Open "c:\temp\test.pdf"

 

' The SetLicenseKey method should be called after creating an object of type 

' CDIntfEx.Document to activate the advanced methods that require the object 

' activation code to work properly

pdfDoc.SetLicenseKey strLicenseTo, strActivationCode

 

' Set Minimum Compression

pdfDoc.SetFlateCompression 0

 

' Save the document

pdfDoc.Save "c:\temp\Without_Compression.pdf"

 

' Set Maximum Compression

pdfDoc.SetFlateCompression 9

 

' Save the document

pdfDoc.Save "c:\temp\Maximum_Compression.pdf"

 

' Destroy pdfDoc object

Set pdfDoc = Nothing