The PaperWidth and PaperLength properties are used to define custom output paper sizes.
System.Int32 PaperLength
System.Int32 PaperWidth
long GetPaperWidth(HANDLE hPrinter)
long SetPaperWidth(HANDLE hPrinter, long nPaperWidth)
long GetPaperLength(HANDLE hPrinter)
long SetPaperLength(HANDLE hPrinter, long nPaperHeight)
PaperWidth, nPaperWidth
[in, out] Paper width in 10th of a millimeter. The default value is 1000 or 10 centimeters.
PaperLength, nPaperLength
[in, out] Paper length in 10th of a millimeter. The default value is 1000 or 10 centimeters.
hPrinter
Handle to printer returned by any of the DriverInit function calls.
SetPaperWidth and SetPaperLength return 1 if successful, 0 otherwise. PaperLength, PaperWidth, GetPaperWidth and GetPaperLength return the current value for each property.
These functions can be used in two situations:
The developer needs to modify the default values for the printer; in this case SetDefaultConfig should be called after modifying these settings to set the value as default for all applications. Application developers should not call this function for every printout but only after printer initialization.
The printer device context is created using the function CDICreateDC. This function uses the settings provided by these functions and there is no need to call SetDefaultConfig.
These functions automatically modify the PaperSize value to 256 for "Custom".
Member of CDIntfEx.CDIntfEx.
<Flags()>
Public Enum PAPERSIZE As Integer
Letter = 1
Legal = 5
A4 = 9
A3 = 8
CustomSize = 256
End Enum
<Flags()>
Public Enum acFileNameOptions As Integer
' Please check FileNameOptions for the complete flags version
NoPrompt = &H1
UseFileName = &H2
Concatenate = &H4
DisableCompression = &H8
EmbedFonts = &H10
BroadcastMessages = &H20
PrintWatermark = &H40
End Enum
Public Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME As String = "Amyuni PDF Converter"
' Declare a new cdintfex object if it does not exist in the form.
Dim PDF As New CDIntfEx.CDIntfEx
' 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
PDF.DriverInit(AMYUNIPRINTERNAME)
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter()
' 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
PDF.EnablePrinter(strLicenseTo, strActivationCode)
' Resulting PDF document stored here
PDF.DefaultDirectory = "C:\Temp"
' Set Printer options
PDF.FileNameOptionsEx = acFileNameOptions.NoPrompt
' Set PaperLength
PDF.PaperLength = 1000 ' in mm
' Set PaperWidth
PDF.PaperWidth = 1000 ' in mm
' Set PaperSize in CustomSize
PDF.PaperSize = PAPERSIZE.CustomSize
' Apply Settings
PDF.SetDefaultConfig()
' The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert("C:\Temp\*.docx")
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter()
' This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd()
' Destroy PDF object
PDF = Nothing
End Sub
[Flags]
public enum PAPERSIZE
{
Letter = 1,
Legal = 5,
A4 = 9,
A3 = 8,
CustomSize = 256
}
[Flags]
public enum acFileNameOptions
{
// Please check FileNameOptions for the complete flags version
NoPrompt = 0x00000001,
UseFileName = 0x00000002,
Concatenate = 0x00000004,
DisableCompression = 0x00000008,
EmbedFonts = 0x00000010,
BroadcastMessages = 0x00000020,
PrintWatermark = 0x00000040
}
public void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Converter Evaluation";
const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
const string AMYUNIPRINTERNAME = "Amyuni PDF Converter";
// Declare a new cdintfex object if it does not exist in the form.
CDIntfEx.CDIntfEx PDF = new CDIntfEx.CDIntfEx();
// 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
PDF.DriverInit(AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
PDF.SetDefaultPrinter();
// 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
PDF.EnablePrinter(strLicenseTo, strActivationCode);
// Resulting PDF document stored here
PDF.DefaultDirectory = @"C:\Temp";
// Set Printer options
PDF.FileNameOptionsEx = (int)acFileNameOptions5.NoPrompt;
// Set PaperLength
PDF.PaperLength = 1000; // in mm
// Set PaperWidth
PDF.PaperWidth = 1000; // in mm
// Set PaperSize in CustomSize
PDF.PaperSize = (int)PAPERSIZE.CustomSize;
// Apply Settings
PDF.SetDefaultConfig();
// The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert(@"C:\Temp\*.docx");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter();
// This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd();
}
// 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;
enum PAPERSIZE {
Letter = 1,
Legal = 5,
A4 = 9,
A3 = 8,
CustomSize = 256
};
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);
// Set PaperLength
SetPaperLength(PDF, 1000); // in mm
// Set PaperWidth
SetPaperWidth(PDF, 1000); // in mm
// Set PaperSize in CustomSize
SetPaperSize(PDF, PAPERSIZE::Legal);
// Apply Settings
SetDefaultConfig(PDF);
// 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;
public class PaperLength {
public enum PAPERSIZE
{
Letter(1),
Legal(5),
A4(9),
A2(8),
CustomSize(256);
public int value;
public PAPERSIZE(int value)
{
this.value = value;
}
public Object value(){
return value;
}
}
public enum acFileNameOptions
{
// Please check FileNameOptions for the complete version of the flags
NoPrompt(0x00000001),
UseFileName(0x00000002),
Concatenate(0x00000004),
DisableCompression(0x00000008),
EmbedFonts(0x00000010),
BroadcastMessages(0x00000020),
PrintWatermark(0x00000040),
MultilingualSupport(0x00000080),
EncryptDocument(0x00000100),
EmbedStandardFonts(0x00200000),
EmbedLicensedFonts(0x00400000),
Jpeg2000Compression(0x01000000),
EncryptDocument128(0x40000000);
public int value;
public acFileNameOptions(int value)
{
this.value = value;
}
public Object value(){
return value;
} }
public static void main(String[] args)
{
// Constants for Activation codes
String strLicenseTo = "Amyuni PDF Converter Evaluation";
String strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
String AMYUNIPRINTERNAME = "Amyuni PDF Converter";
// Declare a new cdintfex object if it does not exist in the form.
ActiveXComponent pdf = new ActiveXComponent("CDIntfEx.CDIntfEx.6.5");
// 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
Dispatch.call(pdf,"DriverInit",AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
Dispatch.call(pdf,"SetDefaultPrinter");
// 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
Dispatch.call(pdf,"EnablePrinter", strLicenseTo, strActivationCode);
// Resulting PDF document stored here
Dispatch.put(pdf,"DefaultDirectory","c:\\Temp");
// Set Printer options
Dispatch.put(pdf,"FileNameOptionsEx",acFileNameOptions.NoPrompt.value);
// Set PaperLength
Dispatch.put(pdf, "PaperLength", 1000); // in mm
// Set PaperWidth
Dispatch.put(pdf, "PaperWidth", 1000); // in mm
// Set PaperSize in CustomSize
Dispatch.put(pdf, "PaperSize", PAPERSIZE.Legal.value);
// Apply Settings
Dispatch.call(pdf, "SetDefaultConfig");
// The BatchConvert method converts a number of files to PDF.
Dispatch.call(pdf,"BatchConvert","c:\\Temp\\*.docx");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
Dispatch.call(pdf,"RestoreDefaultPrinter");
// Close Printer
Dispatch.call(pdf,"DriverEnd");
// Destroy PDF object
pdf = null;
}
}
$PAPERSIZE = @{
Letter = 1
Legal = 5
A4 = 9
A3 = 8
CustomSize = 256
}
$acFileNameOptions = @{
NoPrompt = 0x00000001
UseFileName = 0x00000002
Concatenate = 0x00000004
DisableCompression = 0x00000008
EmbedFonts = 0x00000010
BroadcastMessages = 0x00000020
PrintWatermark = 0x00000040
}
#Please check FileNameOptions for the complete flags version
# Constants for Activation codes
$strLicenseTo = "Amyuni PDF Converter Evaluation"
$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
$AMYUNIPRINTERNAME = "Amyuni PDF Converter"
#Declare a new cdintfex object if it does not exist in the form.
$PDF = New-Object -ComObject CDIntfEx.CDIntfEx.6.5
#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
[System.__ComObject].InvokeMember('DriverInit', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$AMYUNIPRINTERNAME)
#The SetDefaultPrinter function sets the system default printer to the one
#initialized by the DriverInit functions.
[System.__ComObject].InvokeMember('SetDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
#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
[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @($strLicenseTo, $strActivationCode))
#Resulting PDF document stored here
[System.__ComObject].InvokeMember('DefaultDirectory', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,"C:\Temp")
#Set Printer options
[System.__ComObject].InvokeMember('FileNameOptionsEx', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,$acFileNameOptions::NoPrompt)
#Set PaperLength
[System.__ComObject].InvokeMember('PaperLength', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,1000) # in mm
#Set PaperWidth
[System.__ComObject].InvokeMember('PaperWidth', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,1000) # in mm
#Set PaperSize in CustomSize
[System.__ComObject].InvokeMember('PaperSize', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,$PAPERSIZE::CustomSize)
#Apply Settings
[System.__ComObject].InvokeMember('SetDefaultConfig', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, $null)
#The BatchConvert method converts a number of files to PDF.
[System.__ComObject].InvokeMember('BatchConvert', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "C:\Temp\*.docx")
#The RestoreDefaultPrinter function resets the system default printer
#to the printer that was the default before the call to SetDefaultPrinter.
[System.__ComObject].InvokeMember('RestoreDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
#This function will simply detach from an existing printer because the handle was created using DriverInit
[System.__ComObject].InvokeMember('DriverEnd', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
#Destroy PDF object
$PDF = $null
' PaperSize constants
Const Letter = 1
Const Legal = 5
Const A4 = 9
Const A3 = 8
Const CustomSize = 256
' FileNameOptions constants
' Please check FileNameOptions for the complete flags version
Const NoPrompt = &H1
Const UseFileName = &H2
Const Concatenate = &H4
Const DisableCompression = &H8
Const EmbedFonts = &H10
Const BroadcastMessages = &H20
Const PrintWatermark = &H40
Const MultilingualSupport = &H80
Const EncryptDocument = &H100
Const FullEmbed = &H200
' Constants for Activation codes
Const strLicenseTo = "Amyuni PDF Converter Evaluation"
Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME = "Amyuni PDF Converter"
' Declare a new cdintfex object
Dim PDF
Set PDF = CreateObject("CDIntfEx.CDIntfEx.6.5")
' 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
PDF.DriverInit AMYUNIPRINTERNAME
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter
' 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
PDF.EnablePrinter strLicenseTo, strActivationCode
' Resulting PDF document stored here
PDF.DefaultDirectory = "C:\Temp"
' Set Printer options
PDF.FileNameOptionsEx = NoPrompt
' Set PaperLength
PDF.PaperLength = 1000 ' in mm
' Set PaperWidth
PDF.PaperWidth = 1000 ' in mm
' Set PaperSize in CustomSize
PDF.PaperSize = CustomSize
' Apply Settings
PDF.SetDefaultConfig
' The BatchConvert method converts a number of files to PDF.
PDF.BatchConvert "C:\Temp\*.docx"
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter
' This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd
' Destroy PDF object
Set PDF = Nothing