PageNumbers Object

Page numbering is handled by the PageNumbers object that is part of the Document object. All the page numbering options can be set or retrieved using the PageNumbers object.

 

PageNumbers object attributes:

 

Attribute

Description

Type

Values

Default Value

Position

Position of the page numbers.

enum acPageNumbersPositions

0: acNoPageNumbers.

1: acPageNumbersPositionTopLeft.

2: acPageNumbersPositionTopCenter.

3: acPageNumbersPositionTopRight.

4: acPageNumbersPositionBottomLeft.

5: acPageNumbersPositionBottomCenter.

6: acPageNumbersPositionBottomRight.

acNoPageNumbers (0)

Font

Font used to draw the page numbers.

Font

 

Courier New, 10, 400, 0, 0

ExtraMarginHorz

Left or right margin in Twips.

Integer

 

0

ExtraMarginVert

Top or bottom margin in Twips.

Integer

 

0

Color

RGB color used to draw the page numbers.

Color

 

000000 (Solid black)

StartWithPage

Page number where to start adding page numbers.

Integer

If this value is positive, page numbers will start with 1. If this value is negative, page numbers will start with the actual page number.

1

Format

Formatting for the page numbers.

String

Two formatting keywords are currently supported: #page and #pages. All other keywords are output as is.

 

 

Remarks

Once the document is saved in View Only mode, page numbers become static text part of the main document and cannot be modified anymore using this object. To be able to modify the page numbers after saving and loading a document, the document needs to be saved in "Design" or "View and Design" mode.

Example

Example

Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"

    Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"

 

    ' Initializing PDFCreativeX Object

    Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX()

 

    ' Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Using Document Object

    Dim doc = pdf.Document

 

    ' PageNumbers Object

    Dim oPageNumber As ACPDFCREACTIVEX.IacObject = doc("PageNumbers")

    oPageNumber("Font") = "Verdana,11,700,0,0"

    oPageNumber("Position") = ACPDFCREACTIVEX.acPageNumbersPositions.acPageNumbersPositionBottomCenter

    oPageNumber("Color") = &HFF0000

    oPageNumber("StartWithPage") = 1

    oPageNumber("Format") = "- Page #page of #pages -"

    oPageNumber("ExtraMarginHorz") = 0

    oPageNumber("ExtraMarginVert") = 0

 

    ' Save PDF

    pdf.Save("c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView)

 

    ' destroy objects

    pdf = Nothing

    doc = Nothing

    oPageNumber = Nothing

End Sub

static void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Creator Evaluation";

    const string strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";

 

    // Initializing PDFCreativeX Object

    ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX();

 

    // Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Using Document Object

    dynamic doc = pdf.Document;

 

    // PageNumbers Object

    ACPDFCREACTIVEX.IacObject oPageNumber = doc["PageNumbers"];

    oPageNumber["Font"] = "Verdana,11,700,0,0";

    oPageNumber["Position"] = ACPDFCREACTIVEX.acPageNumbersPositions.acPageNumbersPositionBottomCenter;

    oPageNumber["Color"] = 0xFF0000;

    oPageNumber["StartWithPage"] = 1;

    oPageNumber["Format"] = "- Page #page of #pages -";

    oPageNumber["ExtraMarginHorz"] = 0;

    oPageNumber["ExtraMarginVert"] = 0;

 

    // Save PDF

    pdf.Save(@"c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView);

 

    // destroy objects

    pdf = null;

    doc = null;

    oPageNumber = null;

}

#include <iostream>

#import "c:\users\amyuni\pdfcreactivex.dll" no_namespace

 

using namespace std;

 

int main()

{

    // OptimizeDocument level Values

    const int NO_OPTIMIZATION = 0;

    const int LINE_OPTIMIZATION = 1;

    const int PARAGRAPH_OPTIMIZATION = 2;

    const int TABLE_OPTIMIZATION = 3;

 

    // Constants for Activation codes

    bstr_t strLicenseTo = "Amyuni PDF Creator Evaluation";

    bstr_t strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";

 

    // Initialize the COM subsystem

    CoInitialize(0);

 

    // IPDFCreactiveXPtr is a smart pointer type defined in pdfcreactivex.tlh,

    // the type library header file generated by the #import instruction above

    IPDFCreactiveXPtr pdf;

 

    // Create the PDFCreactiveX instance

    pdf.CreateInstance(__uuidof(PDFCreactiveX));

 

    // set license key

    pdf->SetLicenseKey(_bstr_t(strLicenseTo), _bstr_t(strActivationCode));

 

    // Using Document Object

    IacObjectPtr doc = pdf->Document;

 

    // variant

    _variant_t varAttribute;

    varAttribute.vt = VT_I4;  // integers

 

    // PageNumbers Object

    IacObjectPtr oPageNumber = doc->Attribute["PageNumbers"];

    oPageNumber->Attribute["Font"] = "Verdana,11,700,0,0";

    varAttribute.lVal = acPageNumbersPositionBottomCenter;

    oPageNumber->Attribute["Position"] = varAttribute;

    varAttribute.lVal = 0xFF0000;

    oPageNumber->Attribute["Color"] = varAttribute;

    oPageNumber->Attribute["StartWithPage"] = 1;

    oPageNumber->Attribute["Format"] = "- Page #page of #pages -";

    oPageNumber->Attribute["ExtraMarginHorz"] = 0;

    oPageNumber->Attribute["ExtraMarginVert"] = 0;

 

    // Save PDF

    pdf->Save("c:\\temp\\CreatePDFDocument_resulting.pdf", acFileSaveView);

 

    // destroy Objects

    pdf = NULL;

    doc = NULL;

    oPageNumber = NULL;

 

    return 0;

}

' acPageNumbersPositions

Const acNoPageNumbers = 0

Const acPageNumbersPositionTopLeft = 1

Const acPageNumbersPositionTopCenter = 2

Const acPageNumbersPositionTopRight = 3

Const acPageNumbersPositionBottomLeft = 4

Const acPageNumbersPositionBottomCenter = 5

Const acPageNumbersPositionBottomRight = 6

 

' FileSave Constants

Const acFileSaveAll = 0

Const acFileSaveDefault = -1

Const acFileSaveView = 1

Const acFileSaveDesign = 2

Const acFileSavePDFA_7 = 3

Const acFileSavePDFA = 4

Const acFileSavePDF14 = 5

 

' Constants for Activation codes

Const strLicenseTo = "Amyuni Tech. Evaluation"

Const strActivationCode = "07EFCDAB01000100DF6EFC86A6518CC902BADA9A6CD601748A03C78B8804C4D09ECA8C769C8178480245B08FAE6CD0692C541472F082AA3BE6"

 

' Initializing PDFCreativeX Object

Dim pdf

Set pdf = CreateObject("PDFCreactiveX.PDFCreactiveX")

 

' Set license key

pdf.SetLicenseKey strLicenseTo, strActivationCode

 

' Using Document Object

Dim doc

Set doc = pdf.Document

 

' PageNumbers Object

Dim oPageNumber

Set oPageNumber= doc("PageNumbers")

oPageNumber("Font") = "Verdana,11,700,0,0"

oPageNumber("Position") = acPageNumbersPositionBottomCenter

oPageNumber("Color") = &HFF0000

oPageNumber("StartWithPage") = 1

oPageNumber("Format") = "- Page #page of #pages -"

oPageNumber("ExtraMarginHorz") = 0

oPageNumber("ExtraMarginVert") = 0

 

' Save PDF

pdf.Save "c:\temp\CreatePDFDocument_resulting.pdf", acFileSaveView

 

' destroy pdf object

Set pdf = Nothing

Set doc = Nothing

Set oPageNumber = Nothing