SavePage Method

The SavePage method is used to save a single page during page by page saving.  This method can also be used to extract pages from existent PDF file.

 

Syntax

VB:

Sub SavePage(PageNumber As Integer)

C#:

void SavePage(int PageNumber)

C++:

HRESULT SavePage(long PageNumber)

 

Parameters

PageNumber

Page number of the document to save.

 

Remarks

See also the Open, OpenEx, Save, SavePageEx, StartSave , StartSaveEx, EndSave, EndSaveEx sections.

 

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)

 

    ' Create 4 additional pages

    For page = 2 To 5

        pdf.AddPage(page)

    Next

 

    ' Create object in each Page

    For page = 1 To 5

        ' Set the current page

        pdf.CurrentPage = page

 

        ' Create a Text in the current Page

        pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text" + page.ToString)

        Dim oText As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Text" + page.ToString)

        oText("Left") = 1000

        oText("Right") = 5000

        oText("Top") = 0

        oText("Bottom") = 4000

        oText("BorderColor") = &HFF00FF

        oText("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble

        oText("Text") = "Amyuni Technologies " + page.ToString 

    Next

 

    ' Save PDF using StartSave, SavePage and EndSave

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

    For page = 1 To 5

        ' Save page

        pdf.SavePage(page)

 

        ' clear the page contents to save memory

        pdf.ClearPage(page)

    Next

    pdf.EndSave()

 

 

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);

 

    // Create 4 additional pages

    for (int page = 2; page < 6; page++)

    {

        pdf.AddPage(page);

    }

 

    // Create object in each Page

    for (int page = 1; page < 6; page++)

    {

        // Set the current page

        pdf.CurrentPage = page;

 

        // Create a Text in the current Page

        pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text" + page.ToString());

        ACPDFCREACTIVEX.IacObject oText = pdf.GetObjectByName("Text" + page.ToString());

        oText["Left"] = 1000;

        oText["Right"] = 5000; 

        oText["Top"] = 0;

        oText["Bottom"] = 4000;

        oText["BorderColor"] = 0xFF00FF;

        oText["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble;

        oText["Text"] = "Amyuni Technologies " + page.ToString();

    }

 

    // Save PDF using StartSave, SavePage and EndSave

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

    for (int page = 1; page < 6; page++)

    {

        // Save page

        pdf.SavePage(page);

 

        // clear the page contents to save memory

        pdf.ClearPage(page);        

    }

    pdf.EndSave();

 

 

}

#include "windows.h"

#include "comutil.h"

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

 

using namespace std;

 

int main()

{

    // 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));

 

    // Create 4 additional pages

    for (int page = 2; page < 6; page++)

    {

        pdf->AddPage(page);

    }

 

    // Create object in each Page

    for (int page = 1; page < 6; page++)

    {

        // Set the current page

        pdf->CurrentPage = page;

 

        // Set-up variables for attributes

        _variant_t varAttribute;

        varAttribute.vt = VT_I4;  // integers

 

        // Create a text in the current Page

        pdf->CreateObject(acObjectTypeText, "Text" + bstr_t(page));

        IacObjectPtr oText = pdf->GetObjectByName("Text" + bstr_t(page));

        oText->Attribute["Left"] = 1000;

        oText->Attribute["Right"] = 5000;

        oText->Attribute["Top"] = 0;

        oText->Attribute["Bottom"] = 4000;

        varAttribute.lVal = 0xFF00FF;

        oText->Attribute["BorderColor"] = varAttribute;

        varAttribute.lVal = acBorderWidthDouble;

        oText->Attribute["BorderWidth"] = varAttribute;

        oText->Attribute["Text"] = "Amyuni Technologies" + bstr_t(page);

    }

 

    // Save PDF using StartSave, SavePage and EndSave

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

    for (int page = 1; page < 6; page++)

    {

        // Save page

        pdf->SavePage(page);

 

        // clear the page contents to save memory

        pdf->ClearPage(page);

    }

    pdf->EndSave();

 

    // destroy objects

    pdf = NULL;

 

    return 0;

}

' ObjectTypeConstants

Const acObjectTypeArrow = 36

Const acObjectTypeBarcode = 45

Const acObjectTypeCell = 33

Const acObjectTypeCheckBox = 21

Const acObjectTypeEllipse = 4

Const acObjectTypeExcel = 17

Const acObjectTypeField = 6

Const acObjectTypeGraph = 19

Const acObjectTypeHighlight = 23

Const acObjectTypeLine = 1

Const acObjectTypePicture = 7

Const acObjectTypePolygon = 8

Const acObjectTypeRoundFrame = 3

Const acObjectTypeRow = 32

Const acObjectTypeSelection = 24

Const acObjectTypeSignature = 39

Const acObjectTypeStickyNote = 22

Const acObjectTypeTable = 16

Const acObjectTypeText = 5

 

' acBorderWidth

Const acBorderWidthNone = 0

Const acBorderWidthSimple = 1

Const acBorderWidthDouble = 2

Const acBorderWidthTriple = 3

Const acBorderWidthQuadruple = 4

 

' FileSaveOptionConstants

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 PDF Creator Evaluation"

Const strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"

 

' Initializing PDFCreativeX Object

Dim pdf

Set pdf = CreateObject("PDFCreactiveX.PDFCreactiveX.6.5")

 

' Set license key

pdf.SetLicenseKey strLicenseTo, strActivationCode

 

' Create 4 additional pages

For page = 2 To 5

    pdf.AddPage page

Next

 

' Create object in each Page

For page = 1 To 5

    ' Set the current page

    pdf.CurrentPage = page

 

    ' Create a Text in the current Page

    pdf.CreateObject acObjectTypeText, "Text" & page

    Dim oText 

    Set oText = pdf.GetObjectByName("Text" & page)

    oText("Left") = 1000

    oText("Right") = 5000

    oText("Top") = 0

    oText("Bottom") = 4000

    oText("BorderColor") = &HFF00FF

    oText("BorderWidth") = acBorderWidthDouble

    oText("Text") = "Amyuni Technologies" & page

Next

 

' Save PDF using StartSave, SavePage and EndSave

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

For page = 1 To 5

    ' Save page

    pdf.SavePage page

 

    ' clear the page contents to save memory

    pdf.ClearPage page

Next

pdf.EndSave

 

' destroy Objects

Set pdf = Nothing

Set oText = Nothing

 

Example Extracting Page

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)

 

    ' Create 4 additional pages

    For page = 2 To 5

        pdf.AddPage(page)

    Next

 

    ' Create object in each Page

    For page = 1 To 5

        ' Set the current page

        pdf.CurrentPage = page

 

        ' Create a Text in the current Page

        pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text" + page.ToString)

 

        ' Define obj as Text1

        Dim oText As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Text" + page.ToString)

 

        ' Set-up the Text

        oText("Left") = 1000

        oText("Right") = 5000

        oText("Top") = 0

        oText("Bottom") = 4000

        oText("BorderColor") = &HFF00FF

        oText("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble

 

        ' Text Attributes

        oText("Text") = "Amyuni Technologies " + page.ToString

 

    Next

    ' Extracting page 2 and 5

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

    pdf.SavePage(2)

    pdf.SavePage(5)

    pdf.EndSave()

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);

 

    // Create 4 additional pages

    for (int page = 2; page < 6; page++)

    {

        pdf.AddPage(page);

    }

 

    // Create object in each Page

    for (int page = 1; page < 6; page++)

    {

        // Set the current page

        pdf.CurrentPage = page;

 

        // Create a Text in the current Page

        pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text" + page.ToString());

 

        // Define obj as Text1

        ACPDFCREACTIVEX.IacObject oText = pdf.GetObjectByName("Text" + page.ToString());

 

        // Set-up the Text

        oText["Left"] = 1000;

        oText["Right"] = 5000;

 

        oText["Top"] = 0;

        oText["Bottom"] = 4000;

        oText["BorderColor"] = 0xFF00FF;

        oText["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble;

 

        // Text Attributes

        oText["Text"] = "Amyuni Technologies " + page.ToString();

    }

 

    // Extracting page 2 and 5

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

    pdf.SavePage(2);

    pdf.SavePage(5);

    pdf.EndSave();

 

 

}

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

 

using namespace std;

 

int main()

{

    // 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));

 

    // Create 4 additional pages

    for (int page = 2; page < 6; page++)

    {

        pdf->AddPage(page);

    }

 

    // Create object in each Page

    for (int page = 1; page < 6; page++)

    {

        // Set the current page

        pdf->CurrentPage = page;

 

        // Create a Text in the current Page

        pdf->CreateObject(acObjectTypeText, "Text" + page);

 

        // Set-up variables for attributes

        _variant_t varAttribute;

 

        // Set-up the Text

        varAttribute.vt = VT_I4;  // integers

        varAttribute.lVal = 1000;

        pdf->put_ObjectAttribute(_bstr_t("Text" + page), _bstr_t(L"Left"), varAttribute);

 

        varAttribute.lVal = 5000;

        pdf->put_ObjectAttribute(_bstr_t("Text" + page), _bstr_t(L"Right"), varAttribute);

 

        varAttribute.lVal = 0;

        pdf->put_ObjectAttribute(_bstr_t("Text" + page), _bstr_t(L"Top"), varAttribute);

 

        varAttribute.lVal = 4000;

        pdf->put_ObjectAttribute(_bstr_t("Text" + page), _bstr_t(L"Bottom"), varAttribute);

 

        varAttribute.lVal = 0xFF00FF;

        pdf->put_ObjectAttribute(_bstr_t("Text" + page), _bstr_t(L"BorderColor"), varAttribute);

 

        varAttribute.lVal = 1;

        pdf->put_ObjectAttribute(_bstr_t("Text" + page), _bstr_t(L"BorderWidth"), varAttribute);

 

        // Text Attributes

        pdf->ObjectAttributeStr(_bstr_t("Text" + page), _bstr_t("Text"), _bstr_t("Amyuni Technologies" + page));;

    }

 

    // Extracting page 2 and 5

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

    pdf->SavePage(2);

    pdf->SavePage(5);

    pdf->EndSave();

 

    // destroy objects

    pdf = NULL;

 

    return 0;

}

' ObjectTypeConstants

Const acObjectTypeArrow = 36

Const acObjectTypeBarcode = 45

Const acObjectTypeCell = 33

Const acObjectTypeCheckBox = 21

Const acObjectTypeEllipse = 4

Const acObjectTypeExcel = 17

Const acObjectTypeField = 6

Const acObjectTypeGraph = 19

Const acObjectTypeHighlight = 23

Const acObjectTypeLine = 1

Const acObjectTypePicture = 7

Const acObjectTypePolygon = 8

Const acObjectTypeRoundFrame = 3

Const acObjectTypeRow = 32

Const acObjectTypeSelection = 24

Const acObjectTypeSignature = 39

Const acObjectTypeStickyNote = 22

Const acObjectTypeTable = 16

Const acObjectTypeText = 5

 

' acBorderWidth

Const acBorderWidthNone = 0

Const acBorderWidthSimple = 1

Const acBorderWidthDouble = 2

Const acBorderWidthTriple = 3

Const acBorderWidthQuadruple = 4

 

' FileSaveOptionConstants

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 PDF Creator Evaluation"

Const strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"

 

' Initializing PDFCreativeX Object

Dim pdf

Set pdf = CreateObject("PDFCreactiveX.PDFCreactiveX.6.5")

 

' Set license key

pdf.SetLicenseKey strLicenseTo, strActivationCode

 

' Create 4 additional pages

For page = 2 To 5

    pdf.AddPage page

Next

 

' Create object in each Page

For page = 1 To 5

    ' Set the current page

    pdf.CurrentPage = page

 

    ' Create a Text in the current Page

    pdf.CreateObject acObjectTypeText, "Text" & page

 

    ' Define Object

    Dim oText 

    Set oText = pdf.GetObjectByName("Text" & page)

 

    ' General Attributes

    oText("Left") = 1000

    oText("Right") = 5000

    oText("Top") = 0

    oText("Bottom") = 4000

    oText("BorderColor") = &HFF00FF

 

    oText("BorderWidth") = acBorderWidthDouble

 

    ' Text Attributes

    oText("Text") = "Amyuni Technologies" & page

Next

 

' Extracting page 2 and 5

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

pdf.SavePage 2

pdf.SavePage 5

pdf.EndSave

 

' destroy Objects

Set pdf = Nothing

Set oText = Nothing