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.
Attribute |
Description |
Type |
Values |
Default Value |
---|---|---|---|---|
Position |
Position of the page numbers. |
enum IacPageNumbersPosition |
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. |
|
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.
Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"
' Initialize library
' This should be done once
acPDFCreatorLib.Initialize()
' set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)
' Create a new PDF document
Dim doc As New Amyuni.PDFCreator.IacDocument()
Dim oPageNumber As Amyuni.PDFCreator.IacObject = doc.Attribute("PageNumbers").Value
oPageNumber.Attribute("Font").Value = "Verdana,11,700,0,0"
oPageNumber.Attribute("Position").Value = Amyuni.PDFCreator.IacPageNumbersPosition.acPageNumbersPositionBottomCenter
oPageNumber.Attribute("Color").Value = &HFF0000
oPageNumber.Attribute("StartWithPage").Value = 1
oPageNumber.Attribute("Format").Value = "- Page #page of #pages -"
oPageNumber.Attribute("ExtraMarginHorz").Value = 0
oPageNumber.Attribute("ExtraMarginVert").Value = 0
' Create new stream object
Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("C:\temp\CreatePDFDocument_resulting.pdf.pdf")
' Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileWrite.Close()
' terminate library to free resources
acPDFCreatorLib.Terminate()
End Sub
static void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";
const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";
// Initialize library
// This should be done once
acPDFCreatorLib.Initialize();
// set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);
// Create a new PDF document
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();
Amyuni.PDFCreator.IacObject oPageNumber = (Amyuni.PDFCreator.IacObject)doc.Attribute("PageNumbers").Value;
oPageNumber.Attribute("Font").Value = "Verdana,11,700,0,0";
oPageNumber.Attribute("Position").Value = Amyuni.PDFCreator.IacPageNumbersPosition.acPageNumbersPositionBottomCenter;
oPageNumber.Attribute("Color").Value = 0xFF0000;
oPageNumber.Attribute("StartWithPage").Value = 1;
oPageNumber.Attribute("Format").Value = "- Page #page of #pages -";
oPageNumber.Attribute("ExtraMarginHorz").Value = 0;
oPageNumber.Attribute("ExtraMarginVert").Value = 0;
// Create new stream object
System.IO.FileStream fileWrite = new System.IO.FileStream(@"C:\temp\CreatePDFDocument_resulting.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Close the stream
fileWrite.Close();
// terminate library to free resources
acPDFCreatorLib.Terminate();
}