AddLayerConfiguration Method

The AddLayerConfiguration method is used to insert a new layer configuration to a document. This method takes 1 string parameter, the unique layer configuration ID.

In case the layer configuration ID is not unique the method will internally generate a unique ID and return it. This returned layer configuration ID (might be identical to input) should be used for all layer configuration operations.

 

Syntax

VB:

Sub AddLayerConfiguration(ByRef configID As String)

C#:

void AddLayerConfiguration(ref string configID)

C++:

void AddLayerConfiguration([in, out] BSTR *configID)

 

Parameters

configID

This is the unique ID for this layer configuration. It is important that this ID be saved by the caller.

 

Remarks

Before creating a LayerConfig object, we need to check if the document already has a layer config and use it, rather than adding a new one.  Otherwise, it could corrupt the final PDF file.

 

If developer wants to add layers to existent PDF file, it is mandatory to delete any existent layer using the method DeleteAllLayers before adding the new layers.

 

For the moment, it is not possible to modify or append layers to existent layers.

 

The Layer and LayerConfiguration Attributes contains the details information for configure the layers.

 

Example 1

Checking if the PDF file has Layer Configuration

Sub Sample()

 

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"

    Const strActivationCode As String = "07EFCDAB010001004282943FD8F19A88F332D9E7816403607A6D79A42847A1BDE06DB61C1BE94E2D90424BF8762389335F9D3084E9FC"

 

    ' Initializing PDFCreativeX Object

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

 

    ' Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Open an existent PDF file

    Dim fileName As String = "c:\temp\PDFdocument.pdf"

    Dim password As String = ""

    pdf.Open(fileName, password)

 

    ' Create Layer Configuration Object

    Dim oLayerConfig As ACPDFCREACTIVEX.IacObject

 

    ' Get ArrayList of LayerConfigs in the document

    Dim arList() As System.Object = pdf.ObjectAttribute("Document", "LayerConfigs")

    If arList.Count = 0 Then

        Dim configID As String = ""

        pdf.AddLayerConfiguration(configID)

        oLayerConfig = pdf.GetObjectByName("LayerConfigs[" + configID + "]")

    Else

        oLayerConfig = arList(0)

    End If

 

    ' Create the layer

    Dim layerId As String = ""

    pdf.AddLayer("Layer 1", layerId)

 

    ' Define configuration

    oLayerConfig("ConfigOrder") = "[(Main Document)" + layerId + "]"

 

    ' Set CurrentPage

    pdf.CurrentPage = 1

 

    ' Adding a image in first page

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1")

    Dim oPic As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Picture1")

    ' Set-up the Picture

    oPic("Left") = 1000

    oPic("Right") = 5000

    oPic("Top") = 1000

    oPic("Bottom") = 8500

    oPic("BorderColor") = &HFFFFFF

    oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple

    ' Picture Attributes

    oPic("Filename") = "c:\temp\photo1.png"

    oPic("LayerID") = layerId

 

    ' Save PDF

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

 

 

    oLayerConfig = Nothing

    oPic = Nothing

End Sub

static void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Creator Evaluation";

    const string strActivationCode = "07EFCDAB010001004282943FD8F19A88F332D9E7816403607A6D79A42847A1BDE06DB61C1BE94E2D90424BF8762389335F9D3084E9FC";

 

    // Initializing PDFCreativeX Object

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

 

    // Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Open an existent PDF file

    string fileName = @"c:\temp\PDFdocument.pdf";

    string password = "";

    pdf.Open(fileName, password);

 

    // Create Layer Configuration Object

    ACPDFCREACTIVEX.IacObject oLayerConfig;

 

    // Get ArrayList of LayerConfigs in the document

    System.Object[] arList = pdf.ObjectAttribute["Document", "LayerConfigs"];

    if (arList.Length == 0)

    {

        string configID = "";

        pdf.AddLayerConfiguration(ref configID);

        oLayerConfig = pdf.GetObjectByName("LayerConfigs[" + configID + "]");

    }

    else

    {

        oLayerConfig = (ACPDFCREACTIVEX.IacObject)arList[0];

    }

 

    // Create the layer

    string layerId = "";

    pdf.AddLayer("Layer 1", ref layerId);

 

    // Define configuration

    oLayerConfig["ConfigOrder"] = "[(Main Document)" + layerId + "]";

 

    // Set CurrentPage

    pdf.CurrentPage = 1;

 

    // Adding a image in first page

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1");

    ACPDFCREACTIVEX.IacObject oPic = pdf.GetObjectByName("Picture1");

    // Set-up the Picture

    oPic["Left"] = 1000;

    oPic["Right"] = 5000;

    oPic["Top"] = 1000;

    oPic["Bottom"] = 8500;

    oPic["BorderColor"] = 0xFFFFFF;

    oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple;

    // Picture Attributes

    oPic["Filename"] = @"c:\temp\photo1.png";

    oPic["LayerID"] = layerId;

 

    // Save PDF

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

 

 

    oLayerConfig = null;

    oPic = null;

}

#include <iostream>

#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 = "07EFCDAB010001004282943FD8F19A88F332D9E7816403607A6D79A42847A1BDE06DB61C1BE94E2D90424BF8762389335F9D3084E9FC";

 

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

 

    // Open an existent PDF file

    _bstr_t fileName = "c:\\temp\\PDFdocument.pdf";

    _bstr_t password = "";

    pdf->Open(fileName, password);

 

    // Hresult

    HRESULT hr;

 

    // Create Layer Configuration Object

    IacObjectPtr oLayerConfig;

 

    // Get ArrayList of LayerConfigs in the document

    _variant_t arList;

    pdf->get_ObjectAttribute(bstr_t("Document"), bstr_t("LayerConfigs"), &arList);

    assert(arList.vt & (VT_ARRAY | VT_DISPATCH));

    SAFEARRAY *psa = arList.parray;

 

    long lowerBound, upperBound;  // get array bounds

    SafeArrayGetLBound(psa, 1, &lowerBound);

    SafeArrayGetUBound(psa, 1, &upperBound);

    long cnt_elements = upperBound - lowerBound + 1;

 

    if (cnt_elements == 0)

    {

        _bstr_t configID = "";

        hr = pdf->AddLayerConfiguration(&configID.GetBSTR());

        oLayerConfig = pdf->GetObjectByName("LayerConfigs[" + configID + "]");

    }

    else

    {

        oLayerConfig = ((LPDISPATCH*)(psa->pvData))[0];

    }

 

    // Create the layer

    _bstr_t layerId;

    hr = pdf->AddLayer("Layer 1", &layerId.GetBSTR());

 

    // Define configuration

    oLayerConfig->Attribute["ConfigOrder"] = "[(Main Document)" + layerId + "]";

 

    // Set CurrentPage

    pdf->CurrentPage = 1;

 

    // Variable for Attributes

    _variant_t varAttribute;

    varAttribute.vt = VT_I4;

 

    // Adding a image in first page

    hr = pdf->CreateObject(acObjectTypePicture, "Picture1");

    IacObjectPtr oPic = pdf->GetObjectByName("Picture1");

    // Set-up the Picture

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

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

    oPic->Attribute["Top"] = 1000;

    oPic->Attribute["Bottom"] = 8500;

    varAttribute.lVal = 0xFFFFFF;

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

    varAttribute.lVal = acBorderWidthSimple;

    // Picture Attributes

    oPic->Attribute["Filename"] = "c:\\temp\\photo1.png";

    oPic->Attribute["LayerID"] = layerId;

 

    // Save PDF

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

 

    // destroy objects

    pdf = NULL;

    oLayerConfig = NULL;

    oPic = NULL;

 

    return 0;

}

 

Example 2

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 all the Layers

    Dim layerID1 As String = ""

    Dim layerID2 As String = ""

    pdf.AddLayer("Layer 1", layerID1)

    pdf.AddLayer("Layer 2", layerID2)

 

    ' Define the layer configuration as it will appear in a PDF Viewer, e.g.the order And visibility of layers

    Dim configID As String = ""

    pdf.AddLayerConfiguration(configID)

 

    ' order of appearance in the tree

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOrder") = "[(Main Document)[" + layerID2 + " " + layerID1 + "]]"

 

    ' set one of the layers visibility to off by default

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOFF") = "[" + layerID2 + "]"

 

    ' Set CurrentPage

    pdf.CurrentPage = 1

 

    ' Adding Photo 1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1")

    Dim oPic As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Picture1")

    ' Set-up the Picture

    oPic("Left") = 1000

    oPic("Right") = 5000

    oPic("Top") = 1000

    oPic("Bottom") = 8500

    oPic("BorderColor") = &HFFFFFF

    oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple

    ' Picture Attributes

    oPic("Filename") = "c:\temp\photo1.jpg"

    oPic("LayerID") = layerID1

 

    ' Adding Photo 2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture2")

    oPic = pdf.GetObjectByName("Picture2")

    ' Set-up the Picture

    oPic("Left") = 6000

    oPic("Right") = 10000

    oPic("Top") = 1000

    oPic("Bottom") = 8500

    oPic("BorderColor") = &HFFFFFF

    oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple

    ' Picture Attributes

    oPic("Filename") = "c:\temp\photo2.jpg"

    oPic("LayerID") = layerID1

 

    ' Adding Photo 3

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture3")

    oPic = pdf.GetObjectByName("Picture3")

    ' Set-up the Picture

    oPic("Left") = 1000

    oPic("Right") = 5000

    oPic("Top") = 9000

    oPic("Bottom") = 17500

    oPic("BorderColor") = &HFFFFFF

    oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple

    ' Picture Attributes

    oPic("Filename") = "c:\temp\photo3.jpg"

    oPic("LayerID") = layerID2

 

    ' Adding Photo 4

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture4")

    oPic = pdf.GetObjectByName("Picture4")

    ' Set-up the Picture

    oPic("Left") = 6000

    oPic("Right") = 10000

    oPic("Top") = 9000

    oPic("Bottom") = 17500

    oPic("BorderColor") = &HFFFFFF

    oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple

    ' Picture Attributes

    oPic("Filename") = "c:\temp\photo4.jpg"

    oPic("LayerID") = layerID2

 

    ' Save PDF

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

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 all the Layers

    string layerID1 = "";

    string layerID2 = "";

    pdf.AddLayer("Layer 1", ref layerID1);

    pdf.AddLayer("Layer 2", ref layerID2);

 

    // Define the layer configuration as it will appear in a PDF Viewer, e.g.the order and visibility of layers

    string configID = "";

    pdf.AddLayerConfiguration(ref configID);

 

    // order of appearance in the tree

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigOrder"] = "[(Main Document)[" + layerID2 + " " + layerID1 + "]]";

 

    // set one of the layers visibility to off by default

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigOFF"] = "[" + layerID2 + "]";

 

    // Set CurrentPage

    pdf.CurrentPage = 1;

 

    // Adding Photo 1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1");

    ACPDFCREACTIVEX.IacObject oPic = pdf.GetObjectByName("Picture1");

    // Set-up the Picture

    oPic["Left"] = 1000;

    oPic["Right"] = 5000;

    oPic["Top"] = 1000;

    oPic["Bottom"] = 8500;

    oPic["BorderColor"] = 0xFFFFFF;

    oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple;

    // Picture Attributes

    oPic["Filename"] = @"c:\temp\photo1.jpg";

    oPic["LayerID"] = layerID1;

 

    // Adding Photo 2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture2");

    oPic = pdf.GetObjectByName("Picture2");

    // Set-up the Picture

    oPic["Left"] = 6000;

    oPic["Right"] = 10000;

    oPic["Top"] = 1000;

    oPic["Bottom"] = 8500;

    oPic["BorderColor"] = 0xFFFFFF;

    oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple;

    // Picture Attributes

    oPic["Filename"] = @"c:\temp\photo2.jpg";

    oPic["LayerID"] = layerID1;

 

    // Adding Photo 3

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture3");

    oPic = pdf.GetObjectByName("Picture3");

    // Set-up the Picture

    oPic["Left"] = 1000;

    oPic["Right"] = 5000;

    oPic["Top"] = 9000;

    oPic["Bottom"] = 17500;

    oPic["BorderColor"] = 0xFFFFFF;

    oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple;

    // Picture Attributes

    oPic["Filename"] = @"c:\temp\photo3.jpg";

    oPic["LayerID"] = layerID2;

 

    // Adding Photo 4

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture4");

    oPic = pdf.GetObjectByName("Picture4");

    // Set-up the Picture

    oPic["Left"] = 6000;

    oPic["Right"] = 10000;

    oPic["Top"] = 9000;

    oPic["Bottom"] = 17500;

    oPic["BorderColor"] = 0xFFFFFF;

    oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple;

    // Picture Attributes

    oPic["Filename"] = @"c:\temp\photo4.jpg";

    oPic["LayerID"] = layerID2;

 

    // Save PDF

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

}

#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 all the Layers

    HRESULT hr;

    _bstr_t layerID1;

    _bstr_t layerID2;

    hr = pdf->AddLayer("Layer 1", &layerID1.GetBSTR());

    hr = pdf->AddLayer("Layer 2", &layerID2.GetBSTR());

 

    // Define the layer configuration as it will appear in a PDF Viewer, e.g.the order and visibility of layers

    _bstr_t configID = "";

    hr = pdf->AddLayerConfiguration(&configID.GetBSTR());

 

    // order of appearance in the tree

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigOrder", "[(Main Document)[" + layerID2 + " " + layerID1 + "]]");

 

    // set one of the layers visibility to off by default

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigOFF", "[" + layerID2 + "]");

 

    // Set CurrentPage

    pdf->CurrentPage = 1;

 

    // Variable for Attributes

    _variant_t varAttribute;

    varAttribute.vt = VT_I4;  // integers

 

    // Adding Photo 1

    hr = pdf->CreateObject(acObjectTypePicture, "Picture1");

    IacObjectPtr oPic = pdf->GetObjectByName("Picture1");

    // Set-up the Picture

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

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

    oPic->Attribute["Top"] = 1000;

    oPic->Attribute["Bottom"] = 8500;

    varAttribute.lVal = 0xFFFFFF;

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

    varAttribute.lVal = acBorderWidthSimple;

    // Picture Attributes

    oPic->Attribute["Filename"] = "c:\\temp\\photo1.jpg";

    oPic->Attribute["LayerID"] = layerID1;

 

    // Adding Photo 2

    hr = pdf->CreateObject(acObjectTypePicture, "Picture2");

    oPic = pdf->GetObjectByName("Picture2");

    // Set-up the Picture

    oPic->Attribute["Left"] = 6000;

    oPic->Attribute["Right"] = 10000;

    oPic->Attribute["Top"] = 1000;

    oPic->Attribute["Bottom"] = 8500;

    varAttribute.lVal = 0xFFFFFF;

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

    varAttribute.lVal = acBorderWidthSimple;

    // Picture Attributes

    oPic->Attribute["Filename"] = "c:\\temp\\photo2.jpg";

    oPic->Attribute["LayerID"] = layerID1;

 

    // Adding Photo 3

    hr = pdf->CreateObject(acObjectTypePicture, "Picture3");

    oPic = pdf->GetObjectByName("Picture3");

    // Set-up the Picture

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

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

    oPic->Attribute["Top"] = 9000;

    oPic->Attribute["Bottom"] = 17500;

    varAttribute.lVal = 0xFFFFFF;

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

    varAttribute.lVal = acBorderWidthSimple;

    // Picture Attributes

    oPic->Attribute["Filename"] = "c:\\temp\\photo3.jpg";

    oPic->Attribute["LayerID"] = layerID2;

 

    // Adding Photo 1

    hr = pdf->CreateObject(acObjectTypePicture, "Picture4");

    oPic = pdf->GetObjectByName("Picture4");

    // Set-up the Picture

    oPic->Attribute["Left"] = 6000;

    oPic->Attribute["Right"] = 10000;

    oPic->Attribute["Top"] = 9000;

    oPic->Attribute["Bottom"] = 17500;

    varAttribute.lVal = 0xFFFFFF;

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

    varAttribute.lVal = acBorderWidthSimple;

    // Picture Attributes

    oPic->Attribute["Filename"] = "c:\\temp\\photo4.jpg";

    oPic->Attribute["LayerID"] = layerID2;

 

 

    // Save PDF

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

 

    return 0;

}

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

 

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 all the Layers

Dim layerID1

layerID1 = "Layer-1"

Dim layerID2

layerID2 = "Layer-2"

pdf.AddLayer "Layer 1", (layerID1)

pdf.AddLayer "Layer 2", (layerID2)

 

' Define the layer configuration as it will appear in a PDF Viewer, e.g.the order And visibility of layers

Dim configID

configID = "Cgf-1"

pdf.AddLayerConfiguration (configID)

 

' order of appearance in the tree

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOrder") = "[(Main Document)[" + layerID2 + " " + layerID1 + "]]"

 

' set one of the layers visibility to off by default

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOFF") = "[" + layerID2 + "]"

 

' Set CurrentPage

pdf.CurrentPage = 1

 

' Adding Photo 1

pdf.CreateObject acObjectTypePicture, "Picture1"

Dim oPic

Set oPic = pdf.GetObjectByName("Picture1")

' Set-up the Picture

oPic("Left") = 1000

oPic("Right") = 5000

oPic("Top") = 1000

oPic("Bottom") = 8500

oPic("BorderColor") = &HFFFFFF

oPic("BorderWidth") = 3

' Picture Attributes

oPic("Filename") = "c:\temp\photo1.jpg"

oPic("LayerID") = layerID1

 

' Adding Photo 2

pdf.CreateObject acObjectTypePicture, "Picture2"

Set oPic = pdf.GetObjectByName("Picture2")

' Set-up the Picture

oPic("Left") = 6000

oPic("Right") = 10000

oPic("Top") = 1000

oPic("Bottom") = 8500

oPic("BorderColor") = &HFFFFFF

oPic("BorderWidth") = 3

' Picture Attributes

oPic("Filename") = "c:\temp\photo2.jpg"

oPic("LayerID") = layerID1

 

' Adding Photo 3

pdf.CreateObject acObjectTypePicture, "Picture3"

Set oPic = pdf.GetObjectByName("Picture3")

' Set-up the Picture

oPic("Left") = 1000

oPic("Right") = 5000

oPic("Top") = 9000

oPic("Bottom") = 17500

oPic("BorderColor") = &HFFFFFF

oPic("BorderWidth") = 3

' Picture Attributes

oPic("Filename") = "c:\temp\photo3.jpg"

oPic("LayerID") = layerID2

 

' Adding Photo 4

pdf.CreateObject acObjectTypePicture, "Picture4"

Set oPic = pdf.GetObjectByName("Picture4")

' Set-up the Picture

oPic("Left") = 6000

oPic("Right") = 10000

oPic("Top") = 9000

oPic("Bottom") = 17500

oPic("BorderColor") = &HFFFFFF

oPic("BorderWidth") = 3

' Picture Attributes

oPic("Filename") = "c:\temp\photo4.jpg"

oPic("LayerID") = layerID2

 

' Save PDF

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