Layer and Configuration Attributes

Layer Attributes

Attribute

Description

Type

Default Value

LayerID (R)

Attribute cannot be changed by the user. It is only assigned through AddLayer.

String

0

DisplayName

The display name of the layer. This will be shown to the user when displaying the pdf.

String

 

Creator

Creator string. Describes the creator of the layer.

String

 

CreatorSubType

("Artwork" or "Technical")

String

 

ExportState

("ON", "OFF")

String

 

ViewState

("ON", "OFF")

String

 

Lang

 

String

 

PreferredLang

 

String

 

ZoomMin

Float type indicating the minimum zoom value to be visible(See remarks below).

Float

 

ZoomMax

Float type indicating the maximum zoom value  to be visible(See remarks below).

Float

 

SubTypePrint

("Trapping", "PrintersMarks", "Watermark", or "Print").

String

 

PrintState

("ON", "OFF")

String

 

UserType

("Ind", "Tl", "Org")

String

 

UserName

 

String

 

SubTypePageElement

("HF", "FG", "BG", "L")

String

 

 

 

 

Remarks

ZoomMin and ZoomMax are used whenever a layer visibility depends on the zoom level used by the viewer application. Example: if a layer has a minimum zoom attribute set to 10% and its maximum zoom attribute set to 50%, then that layer (and all objects belonging to that layer) will only be shown if the viewer application is displaying the document with a zoom level between 10% and 50%.

The end user (displaying the PDF) have no control on the layer except by modifying the zoom level of the application, but cannot set the layer visible to true (ON) when the zoom level is outside the indicated range (Same for PrintState).

 

Example 1

Sub Main()

    ' 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 = "Layer1"

    pdf.AddLayer("LayerA", layerID1)

 

    Dim layerID2 As String = "Layer2"

    pdf.AddLayer("LayerB-RB", layerID2)

 

    Dim layerID3 As String = "Layer3"

    pdf.AddLayer("LayerC-RB", layerID3)

 

    Dim layerID4 As String = "Layer4"

    pdf.AddLayer("LayerD", layerID4)

 

    Dim layerID5 As String = "Layer5"

    pdf.AddLayer("LayerE", layerID5)

 

    Dim layerID6 As String = "Layer6"

    pdf.AddLayer("Image Layer", layerID6)

 

    Dim layerID7 As String = "Zoom Level"

    pdf.AddLayer("Image Layer - 2", layerID7)

 

    Dim layerID8 As String = "Layer---8"

    pdf.AddLayer("Non Printable Layer", layerID8)

 

    ' Setting Layer usage options (print, zoom ... )

    pdf.ObjectAttribute("Layers[" + layerID7 + "]", "ZoomMin") = 0.2

    pdf.ObjectAttribute("Layers[" + layerID7 + "]", "ZoomMax") = 0.7

 

    ' Making Layer - --8 non - printable

    pdf.ObjectAttribute("Layers[" + layerID8 + "]", "SubTypePrint") = "Print"

    pdf.ObjectAttribute("Layers[" + layerID8 + "]", "PrintState") = "OFF"

 

    ' When setting ConfigAS attribute each block of Category/Event/layers must be separated by |

    Dim configID As String = ""

    pdf.AddLayerConfiguration(configID)

 

    ' Kind of configuration

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigAS") = "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";"

 

    ' set the layers visibility to ON by default

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigON") = "[" + layerID1 + " " + layerID4 + " " + layerID5 + "]"

 

    ' set the layers visibility to OFF by default

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

 

    ' set state of visibility by default

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigBaseState") = "ON"

 

    ' Set Order layers

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOrder") = "[" + layerID4 + " [" + layerID1 + " " + layerID5 + "] [(this is the text string) " + layerID2 + " " + layerID3 + "] [(Turn On Nicole) " + layerID6 + "]]"

 

    ' Set Groups

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

 

    ' set list of Layers

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigList") = "AllPages"

 

    ' set layers to be locked and the user cannot change

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigLocked") = "[" + layerID1 + "]"

 

    ' Set CurrentPage

    pdf.CurrentPage = 1

 

    ' Adding Line 1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeLine, "LineObject1")

    Dim oLine As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("LineObject1")

    oLine("Left") = 10

    oLine("Right") = 5010

    oLine("Top") = 10

    oLine("Bottom") = 5010

    oLine("StrokeColor") = &HFF0000

    ' Layer Attributes

    oLine("LayerID") = layerID1

 

    ' Adding Line 2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeLine, "LineObject2")

    oLine = pdf.GetObjectByName("LineObject2")

    oLine("Left") = 10

    oLine("Right") = 5010

    oLine("Top") = 5010

    oLine("Bottom") = 10

    oLine("StrokeColor") = &HFF00FF

    ' Layer Attributes

    oLine("LayerID") = layerID5

 

    ' Adding Text1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text1")

    Dim oText As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Text1")

    oText("Left") = 10

    oText("Right") = 1000

    oText("Top") = 10

    oText("Bottom") = 25

    oText("Text") = "----------This test should go into layer 2 ..."

    ' Layer Attributes

    oText("LayerID") = layerID2

 

    ' Adding Text2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text2")

    oText = pdf.GetObjectByName("Text2")

    oText("Left") = 2000

    oText("Right") = 5000

    oText("Top") = 0

    oText("Bottom") = 15

    oText("Text") = "This test should go into layer 3 (Radio button)"

    ' Layer Attributes

    oText("LayerID") = layerID3

 

    ' Create Picture1

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

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

    oPic("Left") = 850

    oPic("Right") = 10000

    oPic("Top") = 5050

    oPic("Bottom") = 10000

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

    ' Layer Attributes

    oPic("LayerID") = layerID6

 

    ' Create Picture2

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

    oPic = pdf.GetObjectByName("Picture2")

    oPic("Left") = 7000

    oPic("Right") = 10000

    oPic("Top") = 3800

    oPic("Bottom") = 10000

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

    ' Layer Attributes

    oPic("LayerID") = layerID7

 

    ' Create a "unprintable" text object

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text3")

    oText = pdf.GetObjectByName("Text3")

    oText("Left") = 1000

    oText("Right") = 10000

    oText("Top") = 1000

    oText("Bottom") = 1015

    oText("Text") = "This text should not be printed"

    ' Layer Attributes

    oText("LayerID") = layerID8

 

    ' 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 = "Layer1";

    pdf.AddLayer("LayerA", ref layerID1);

 

    string layerID2 = "Layer2";            

    pdf.AddLayer("LayerB-RB", ref layerID2);

 

    string layerID3 = "Layer3";

    pdf.AddLayer("LayerC-RB", ref layerID3);

 

    string layerID4 = "Layer4";

    pdf.AddLayer("LayerD", ref layerID4);

 

    string layerID5 = "Layer5";

    pdf.AddLayer("LayerE", ref layerID5);

 

    string layerID6 = "Layer6";

    pdf.AddLayer("Image Layer", ref layerID6);

 

    string layerID7 = "Zoom Level";

    pdf.AddLayer("Image Layer - 2", ref layerID7);

 

    string layerID8 = "Layer---8";

    pdf.AddLayer("Non Printable Layer", ref layerID8);

 

    // Setting Layer usage options (print, zoom ... )

    pdf.ObjectAttribute["Layers[" + layerID7 + "]", "ZoomMin"] = 0.2;

    pdf.ObjectAttribute["Layers[" + layerID7 + "]", "ZoomMax"] = 0.7;

 

    // Making Layer - --8 non - printable

    pdf.ObjectAttribute["Layers[" + layerID8 + "]", "SubTypePrint"] = "Print";

    pdf.ObjectAttribute["Layers[" + layerID8 + "]", "PrintState"] = "OFF";

 

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

 

    // Kind of configuration

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigAS"] = "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";";

 

    // set the layers visibility to ON by default

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigON"] = "[" + layerID1 + " " + layerID4 + " " + layerID5 + "]";

 

    // set the layers visibility to OFF by default

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

 

    // set state of visibility by default

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigBaseState"] = "ON";

 

    // Set Order layers

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigOrder"] = "[" + layerID4 + " [" + layerID1 + " " + layerID5 + "] [(this is the text string) " + layerID2 + " " + layerID3 + "] [(Turn On Nicole) " + layerID6 + "]]";

 

    // set Groups

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

 

    // set list of Layers

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigList"] = "AllPages";

 

    // set layers to be locked and the user cannot change

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigLocked"] = "[" + layerID1 + "]";

 

    // Set CurrentPage

    pdf.CurrentPage = 1;

 

    // Create Line 1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeLine, "LineObject1");

    ACPDFCREACTIVEX.IacObject oLine = pdf.GetObjectByName("LineObject1");

    oLine["Left"] = 10;

    oLine["Right"] = 5010;

    oLine["Top"] = 10;

    oLine["Bottom"] = 5010;

    oLine["StrokeColor"] = 0xFF0000;

    // Layer Attributes

    oLine["LayerID"] = layerID1;

 

    // Create Line 2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeLine, "LineObject2");

    oLine = pdf.GetObjectByName("LineObject2");

    oLine["Left"] = 10;

    oLine["Right"] = 5010;

    oLine["Top"] = 5010;

    oLine["Bottom"] = 10;

    oLine["StrokeColor"] = 0xFF00FF;

    // Layer Attributes

    oLine["LayerID"] = layerID5;

 

    // Create Text1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text1");

    ACPDFCREACTIVEX.IacObject oText = pdf.GetObjectByName("Text1");

    oText["Left"] = 10;

    oText["Right"] = 1000;

    oText["Top"] = 10;

    oText["Bottom"] = 25;

    oText["Text"] = "----------This test should go into layer 2 ...";

    // Layer Attributes

    oText["LayerID"] = layerID2;

 

    // Create Text2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text2");

    oText = pdf.GetObjectByName("Text2");

    oText["Left"] = 2000;

    oText["Right"] = 5000;

    oText["Top"] = 10;            

    oText["Bottom"] = 25;

    oText["Text"] = "This test should go into layer 3 (Radio button)";

    // Layer Attributes

    oText["LayerID"] = layerID3;

 

    // Adding Picture1

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

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

    // Set-up the Picture

    oPic["Left"] = 850;

    oPic["Right"] = 10000;

    oPic["Top"] = 5050;

    oPic["Bottom"] = 10000;

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

    // Layer Attributes

    oPic["LayerID"] = layerID6;

 

    // Adding Picture2

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

    oPic = pdf.GetObjectByName("Picture2");

    // Set-up the Picture

    oPic["Left"] = 7000;

    oPic["Right"] = 10000;

    oPic["Top"] = 5050;            

    oPic["Bottom"] = 10000;

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

    // Layer Attributes

    oPic["LayerID"] = layerID7;

 

    // Create a "unprintable" text object

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text3");

    oText = pdf.GetObjectByName("Text3");

    oText["Left"] = 1000;

    oText["Right"] = 10000;

    oText["Top"] = 1000;            

    oText["Bottom"] = 1015;

    oText["Text"] = "This text should not be printed";

    // Layer Attributes

    oText["LayerID"] = layerID8;

 

    // 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 = "Layer1";

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

 

    _bstr_t layerID2 = "Layer2";

    hr = pdf->AddLayer("LayerB-RB", &layerID2.GetBSTR());

 

    _bstr_t layerID3 = "Layer3";

    hr = pdf->AddLayer("LayerC-RB", &layerID3.GetBSTR());

 

    _bstr_t layerID4 = "Layer4";

    hr = pdf->AddLayer("LayerD", &layerID4.GetBSTR());

 

    _bstr_t layerID5 = "Layer5";

    hr = pdf->AddLayer("LayerE", &layerID5.GetBSTR());

 

    _bstr_t layerID6 = "Layer6";

    hr = pdf->AddLayer("Image Layer", &layerID6.GetBSTR());

 

    _bstr_t layerID7 = "Zoom Level";

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

 

    _bstr_t layerID8 = "Layer---8";

    hr = pdf->AddLayer("No Printable Layer", &layerID8.GetBSTR());

 

    // Setting Layer usage options (print, zoom ... )

    pdf->ObjectAttributeFloat("Layers[" + layerID7 + "]", "ZoomMin", 0.2);

    pdf->ObjectAttributeFloat("Layers[" + layerID7 + "]", "ZoomMax", 0.7);

 

    // Making Layer - --8 non - printable

    pdf->ObjectAttributeStr("Layers[" + layerID8 + "]", "SubTypePrint", "Print");

    pdf->ObjectAttributeStr("Layers[" + layerID8 + "]", "PrintState", "OFF");

 

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

 

    // Kind of configuration

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigAS", "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";");

 

    // set the layers visibility to ON by default

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigON", "[" + layerID1 + " " + layerID4 + " " + layerID5 + "]");

 

    // set the layers visibility to OFF by default

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

 

    // set state of visibility by default

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

 

    // Set Order layers

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigOrder", "[" + layerID4 + " [" + layerID1 + " " + layerID5 + "] [(this is the text string) " + layerID2 + " " + layerID3 + "] [(Turn On Nicole) " + layerID6 + "]]");

 

    // set Groups

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

 

    // set list of Layers

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

 

    // set layers to be locked and the user cannot change

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

 

    // Set CurrentPage

    pdf->CurrentPage = 1;

 

    // Variable for Attributes

    _variant_t varAttribute;

    varAttribute.vt = VT_I4;  // integers

 

    // Create Line 1

    hr = pdf->CreateObject(acObjectTypeLine, "LineObject1");

    IacObjectPtr oLine = pdf->GetObjectByName("LineObject1");

    oLine->Attribute["Left"] = 10;

    oLine->Attribute["Right"] = 5010;

    oLine->Attribute["Top"] = 10;

    oLine->Attribute["Bottom"] = 5010;

    varAttribute.lVal = 0xFF0000;

    oLine->Attribute["StrokeColor"] = varAttribute;

    // Layer Attributes

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

 

    // Create Line 2

    hr = pdf->CreateObject(acObjectTypeLine, "LineObject2");

    oLine = pdf->GetObjectByName("LineObject2");

    oLine->Attribute["Left"] = 10;

    oLine->Attribute["Right"] = 5010;

    oLine->Attribute["Top"] = 5010;

    oLine->Attribute["Bottom"] = 10;

    varAttribute.lVal = 0xFF00FF;

    oLine->Attribute["StrokeColor"] = varAttribute;

    // Layer Attributes

    oLine->Attribute["LayerID"] = layerID5;

 

    // Create Text1

    hr = pdf->CreateObject(acObjectTypeText, "Text1");

    IacObjectPtr oText = pdf->GetObjectByName("Text1");

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

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

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

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

    oText->Attribute["Text"] = "----------This test should go into layer 2 ...";

    // Layer Attributes

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

 

    // Create Text2

    hr = pdf->CreateObject(acObjectTypeText, "Text2");

    oText = pdf->GetObjectByName("Text2");

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

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

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

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

    oText->Attribute["Text"] = "This test should go into layer 3 (Radio button)";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID3;

 

    // Adding Picture1

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

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

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

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

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

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

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

    // Layer Attributes

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

 

    // Adding Picture2

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

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

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

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

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

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

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

    // Layer Attributes

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

 

    // Create a "unprintable" text object

    hr = pdf->CreateObject(acObjectTypeText, "Text3");

    oText = pdf->GetObjectByName("Text3");

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

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

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

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

    oText->Attribute["Text"] = "This text should not be printed";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID8;

 

    // 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 = "Layer1"

pdf.AddLayer "LayerA", (layerID1)

 

Dim layerID2

layerID2 = "Layer2"

pdf.AddLayer "LayerB-RB", (layerID2)

 

Dim layerID3

layerID3 = "Layer3"

pdf.AddLayer "LayerC-RB", (layerID3)

 

Dim layerID4

layerID4 = "Layer4"

pdf.AddLayer "LayerD", (layerID4)

 

Dim layerID5

layerID5 = "Layer5"

pdf.AddLayer "LayerE", (layerID5)

 

Dim layerID6

layerID6 = "Layer6"

pdf.AddLayer "Image Layer", (layerID6)

 

Dim layerID7

layerID7 = "Zoom Level"

pdf.AddLayer "Image Layer - 2", (layerID7)

 

Dim layerID8

layerID8 = "Layer---8"

pdf.AddLayer "Non Printable Layer", (layerID8)

 

' Setting Layer usage options (print, zoom ... )

pdf.ObjectAttribute("Layers[" + layerID7 + "]", "ZoomMin") = 0.2

pdf.ObjectAttribute("Layers[" + layerID7 + "]", "ZoomMax") = 0.7

 

' Making Layer - --8 non - printable

pdf.ObjectAttribute("Layers[" + layerID8 + "]", "SubTypePrint") = "Print"

pdf.ObjectAttribute("Layers[" + layerID8 + "]", "PrintState") = "OFF"

 

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

 

' Kind of configuration

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigAS") = "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";"

 

' set the layers visibility to ON by default

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigON") = "[" + layerID1 + " " + layerID4 + " " + layerID5 + "]"

 

' set the layers visibility to OFF by default

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

 

' set state of visibility by default

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigBaseState") = "ON"

 

' Set Order layers

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOrder") = "[" + layerID4 + " [" + layerID1 + " " + layerID5 + "] [(this is the text string) " + layerID2 + " " + layerID3 + "] [(Turn On Nicole) " + layerID6 + "]]"

 

' Set Groups

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

 

' set list of Layers

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigList") = "AllPages"

 

' set layers to be locked and the user cannot change

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigLocked") = "[" + layerID1 + "]"

 

' Set CurrentPage

pdf.CurrentPage = 1

 

' Create Line 1

pdf.CreateObject acObjectTypeLine, "LineObject1"

Dim oLine

Set oLine = pdf.GetObjectByName("LineObject1")

oLine("Left") = 10

oLine("Right") = 5010

oLine("Top") = 10

oLine("Bottom") = 5010

oLine("StrokeColor") = &HFF0000

' Layer Attributes

oLine("LayerID") = layerID1

 

' Create Line 2

pdf.CreateObject acObjectTypeLine, "LineObject2"

Set oLine = pdf.GetObjectByName("LineObject2")

oLine("Left") = 10

oLine("Right") = 5010

oLine("Top") = 5010

oLine("Bottom") = 10

oLine("StrokeColor") = &HFF00FF

' Layer Attributes

oLine("LayerID") = layerID5

 

' Adding Text1

pdf.CreateObject acObjectTypeText, "Text1"

Dim oText

Set oText = pdf.GetObjectByName("Text1")

oText("Left") = 10

oText("Right") = 1000

oText("Top") = 10

oText("Bottom") = 25

oText("Text") = "----------This test should go into layer 2 ..."

' Layer Attributes

oText("LayerID") = layerID2

 

' Adding Text2

pdf.CreateObject acObjectTypeText, "Text2"

Set oText = pdf.GetObjectByName("Text2")

oText("Left") = 2000

oText("Right") = 5000

oText("Top") = 0

oText("Bottom") = 15

oText("Text") = "This test should go into layer 3 (Radio button)"

' Layer Attributes

oText("LayerID") = layerID3

 

 

' Create Picture1

pdf.CreateObject acObjectTypePicture, "Picture1"

Dim oPic

Set oPic = pdf.GetObjectByName("Picture1")

oPic("Left") = 850

oPic("Right") = 10000

oPic("Top") = 5050

oPic("Bottom") = 10000

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

' Layer Attributes

oPic("LayerID") = layerID6

 

' Create Picture2

pdf.CreateObject acObjectTypePicture, "Picture2"

Set oPic = pdf.GetObjectByName("Picture2")

oPic("Left") = 7000

oPic("Right") = 10000

oPic("Top") = 3800

oPic("Bottom") = 10000

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

' Layer Attributes

oPic("LayerID") = layerID7

 

' Create a "unprintable" text object

pdf.CreateObject acObjectTypeText, "Text3"

Set oText = pdf.GetObjectByName("Text3")

oText("Left") = 1000

oText("Right") = 10000

oText("Top") = 1000

oText("Bottom") = 1015

oText("Text") = "This text should not be printed"

' Layer Attributes

oText("LayerID") = layerID8

 

' Save PDF

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

 

' destroy objects

Set oLine = Nothing

Set oText = Nothing

Set oPic = Nothing

Set pdf = Nothing

 

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 = "Layer-1"

    pdf.AddLayer("Layer 1", layerID1)

 

    Dim layerID2 As String = "Layer-2"

    pdf.AddLayer("Should not be visible", layerID2)

 

    Dim layerID3 As String = "Layer-3"

    pdf.AddLayer("Should be visible", layerID3)

 

    Dim layerID4 As String = "Layer-4"

    pdf.AddLayer("Parent Layer", layerID4)

 

    Dim layerID5 As String = "Layer-5"

    pdf.AddLayer("RB group element 1", layerID5)

 

    Dim layerID6 As String = "Layer-6"

    pdf.AddLayer("RB group element 2", layerID6)

 

    Dim layerID7 As String = "Layer-7"

    pdf.AddLayer("RB group element 3", layerID7)

 

    Dim layerID8 As String = "Layer-8"

    pdf.AddLayer("Zoom Layer", layerID8)

 

    Dim layerID9 As String = "Layer-9"

    pdf.AddLayer("Print Layer", layerID9)

 

    ' Setting Layer usage options (print, zoom ... )

    pdf.ObjectAttribute("Layers[" + layerID8 + "]", "ZoomMin") = 0.2

    pdf.ObjectAttribute("Layers[" + layerID8 + "]", "ZoomMax") = 0.7

 

    ' Making Layer-9 printable

    pdf.ObjectAttribute("Layers[" + layerID9 + "]", "SubTypePrint") = "Print"

    pdf.ObjectAttribute("Layers[" + layerID9 + "]", "PrintState") = "ON"

 

    ' When setting ConfigAS attribute each block of Category/Event/layers must be separated by |

    Dim configID As String = ""

    pdf.AddLayerConfiguration(configID)

 

    ' Kind of configuration

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigAS") = "Category:Print;Event:Print;layers:" + layerID9 + ";|Event:View;Category:Zoom;layers:" + layerID8 + ";"

 

    ' set state of visibility by default

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigBaseState") = "OFF"

 

    ' set the layers visibility to ON by default

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigON") = "[" + layerID1 + " " + layerID3 + "]"

 

    ' Set Order layers

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOrder") = "[" + layerID4 + " [" + layerID2 + " " + layerID3 + "] [" + layerID1 + " " + layerID5 + " " + layerID6 + " " + layerID7 + "]]"

 

    ' Set Groups

    pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigRBGroups") = "[[" + layerID5 + " " + layerID6 + " " + layerID7 + "]]"

 

    ' Set CurrentPage

    pdf.CurrentPage = 1

 

    ' Adding Text1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text1")

    Dim oText As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Text1")

    oText("Left") = 2000

    oText("Right") = 3000

    oText("Top") = 1500

    oText("Bottom") = 1515

    oText("Text") = "+++ Layer 1 +++"

    ' Layer Attributes

    oText("LayerID") = layerID1

 

    ' Adding Text2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text2")

    oText = pdf.GetObjectByName("Text2")

    oText("Left") = 2500

    oText("Right") = 3000

    oText("Top") = 2500

    oText("Bottom") = 2515

    oText("Text") = "+++ Child invisible +++"

    ' Layer Attributes

    oText("LayerID") = layerID2

 

    ' Adding Text3

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text3")

    oText = pdf.GetObjectByName("Text3")

    oText("Left") = 2500

    oText("Right") = 3000

    oText("Top") = 3500

    oText("Bottom") = 3515

    oText("Text") = "+++ Child visible +++"

    ' Layer Attributes

    oText("LayerID") = layerID3

 

    ' Adding Text4

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text4")

    oText = pdf.GetObjectByName("Text4")

    oText("Left") = 2500

    oText("Right") = 2500

    oText("Top") = 4500

    oText("Bottom") = 4515

    oText("Text") = "+++ Parent for both children +++"

    ' Layer Attributes

    oText("LayerID") = layerID4

 

    ' Adding Text5

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text5")

    oText = pdf.GetObjectByName("Text5")

    oText("Left") = 1950

    oText("Right") = 2450

    oText("Top") = 5500

    oText("Bottom") = 5515

    oText("Text") = "+++ RB group text 1 +++"

    ' Layer Attributes

    oText("LayerID") = layerID5

 

    ' Adding Text6

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text6")

    oText = pdf.GetObjectByName("Text6")

    oText("Left") = 1950

    oText("Right") = 2450

    oText("Top") = 6500

    oText("Bottom") = 6515

    oText("Text") = "+++ RB group text 2 +++"

    ' Layer Attributes

    oText("LayerID") = layerID6

 

    ' Adding Text7

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text7")

    oText = pdf.GetObjectByName("Text7")

    oText("Left") = 1950

    oText("Right") = 2450

    oText("Top") = 7500

    oText("Bottom") = 7515

    oText("Text") = "+++ RB group text 3 +++"

    ' Layer Attributes

    oText("LayerID") = layerID7

 

    ' Adding Text8

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text8")

    oText = pdf.GetObjectByName("Text8")

    oText("Left") = 1950

    oText("Right") = 2450

    oText("Top") = 8500

    oText("Bottom") = 8515

    oText("Text") = "+++ Zoom text (visible only when zoom is between 20% and 70%) +++"

    ' Layer Attributes

    oText("LayerID") = layerID8

 

    ' Adding Text9

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text9")

    oText = pdf.GetObjectByName("Text9")

    oText("Left") = 1950

    oText("Right") = 2450

    oText("Top") = 9500

    oText("Bottom") = 9515

    oText("Text") = "+++ Printable text\r(visible only on print) +++"

    ' Layer Attributes

    oText("LayerID") = layerID9

 

    ' 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 = "Layer-1";

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

 

    string layerID2 = "Layer-2";

    pdf.AddLayer("Should not be visible", ref layerID2);

 

    string layerID3 = "Layer-3";

    pdf.AddLayer("Should be visible", ref layerID3);

 

    string layerID4 = "Layer-4";

    pdf.AddLayer("Parent Layer", ref layerID4);

 

    string layerID5 = "Layer-5";

    pdf.AddLayer("RB group element 1", ref layerID5);

 

    string layerID6 = "Layer-6";

    pdf.AddLayer("RB group element 2", ref layerID6);

 

    string layerID7 = "Layer-7";

    pdf.AddLayer("RB group element 3", ref layerID7);

 

    string layerID8 = "Layer-8";

    pdf.AddLayer("Zoom Layer", ref layerID8);

 

    string layerID9 = "Layer-9";

    pdf.AddLayer("Printable Layer", ref layerID9);

 

    // Setting Layer usage options (print, zoom ... )

    pdf.ObjectAttribute["Layers[" + layerID8 + "]", "ZoomMin"] = 0.2;

    pdf.ObjectAttribute["Layers[" + layerID8 + "]", "ZoomMax"] = 0.7;

 

    // Making Layer-9 printable

    pdf.ObjectAttribute["Layers[" + layerID9 + "]", "SubTypePrint"] = "Print";

    pdf.ObjectAttribute["Layers[" + layerID9 + "]", "PrintState"] = "ON";

 

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

 

    // Kind of configuration

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigAS"] = "Category:Print;Event:Print;layers:" + layerID9 + ";|Event:View;Category:Zoom;layers:" + layerID8 + ";";

 

    // set state of visibility by default

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigBaseState"] = "OFF";

 

    // set the layers visibility to ON by default

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigON"] = "[" + layerID1 + " " + layerID3 + "]";

 

    // Set Order layers

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigOrder"] = "[" + layerID4 + " [" + layerID2 + " " + layerID3 + "] [" + layerID1 + " " + layerID5 + " " + layerID6 + " " + layerID7 + "]]";

 

    // set Groups

    pdf.ObjectAttribute["LayerConfigs[" + configID + "]", "ConfigRBGroups"] = "[[" + layerID5 + " " + layerID6 + " " + layerID7 + "]]";

 

    // Set CurrentPage

    pdf->CurrentPage = 1;

 

    // Create Text1

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text1");

    ACPDFCREACTIVEX.IacObject oText = pdf.GetObjectByName("Text1");

    oText["Left"] = 2000;

    oText["Right"] = 3000;

    oText["Top"] = 1500;

    oText["Bottom"] = 1515;

    oText["Text"] = "+++ Layer 1 +++";

    // Layer Attributes

    oText["LayerID"] = layerID1;

 

    // Create Text2

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text2");

    oText = pdf.GetObjectByName("Text2");

    oText["Left"] = 2500;

    oText["Right"] = 3000;

    oText["Top"] = 2500;

    oText["Bottom"] = 2515;

    oText["Text"] = "+++ Child invisible +++";

    // Layer Attributes

    oText["LayerID"] = layerID2;

 

    // Create Text3

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text3");

    oText = pdf.GetObjectByName("Text3");

    oText["Left"] = 2500;

    oText["Right"] = 3000;

    oText["Top"] = 3500;

    oText["Bottom"] = 3515;

    oText["Text"] = "+++ Child visible +++";

    // Layer Attributes

    oText["LayerID"] = layerID3;

 

    // Create Text4

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text4");

    oText = pdf.GetObjectByName("Text4");

    oText["Left"] = 2500;

    oText["Right"] = 2500;

    oText["Top"] = 4500;

    oText["Bottom"] = 4515;

    oText["Text"] = "+++ Parent for both children +++";

    // Layer Attributes

    oText["LayerID"] = layerID4;

 

    // Create Text5

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text5");

    oText = pdf.GetObjectByName("Text5");

    oText["Left"] = 1950;

    oText["Right"] = 2450;

    oText["Top"] = 5500;

    oText["Bottom"] = 5515;

    oText["Text"] = "+++ RB group text 1 +++";

    // Layer Attributes

    oText["LayerID"] = layerID5;

 

    // Create Text6

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text6");

    oText = pdf.GetObjectByName("Text6");

    oText["Left"] = 1950;

    oText["Right"] = 2450;

    oText["Top"] = 6500;

    oText["Bottom"] = 6515;

    oText["Text"] = "+++ RB group text 2 +++";

    // Layer Attributes

    oText["LayerID"] = layerID6;

 

    // Create Text7

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text7");

    oText = pdf.GetObjectByName("Text7");

    oText["Left"] = 1950;

    oText["Right"] = 2450;

    oText["Top"] = 7500;

    oText["Bottom"] = 7515;

    oText["Text"] = "+++ RB group text 3 +++";

    // Layer Attributes

    oText["LayerID"] = layerID7;

 

    // Create Text8

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text8");

    oText = pdf.GetObjectByName("Text8");

    oText["Left"] = 1950;

    oText["Right"] = 2450;

    oText["Top"] = 8500;

    oText["Bottom"] = 8515;

    oText["Text"] = "+++ Zoom text (visible only when zoom is between 20% and 70%) +++";

    // Layer Attributes

    oText["LayerID"] = layerID8;

 

    // Create Text9

    pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text9");

    oText = pdf.GetObjectByName("Text9");

    oText["Left"] = 1950;

    oText["Right"] = 2450;

    oText["Top"] = 9500;

    oText["Bottom"] = 9515;

    oText["Text"] = "+++ Printable text\r(visible only on print) +++";

    // Layer Attributes

    oText["LayerID"] = layerID9;

 

    // 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 = "Layer-1";

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

 

    _bstr_t layerID2 = "Layer-2";

    hr = pdf->AddLayer("Should not be visible", &layerID2.GetBSTR());

 

    _bstr_t layerID3 = "Layer-3";

    hr = pdf->AddLayer("Should be visible", &layerID3.GetBSTR());

 

    _bstr_t layerID4 = "Layer-4";

    hr = pdf->AddLayer("Parent Layer", &layerID4.GetBSTR());

 

    _bstr_t layerID5 = "Layer-5";

    hr = pdf->AddLayer("RB group element 1", &layerID5.GetBSTR());

 

    _bstr_t layerID6 = "Layer-6";

    hr = pdf->AddLayer("RB group element 2", &layerID6.GetBSTR());

 

    _bstr_t layerID7 = "Layer-7";

    hr = pdf->AddLayer("RB group element 3", &layerID7.GetBSTR());

 

    _bstr_t layerID8 = "Layer-8";

    hr = pdf->AddLayer("Zoom Layer", &layerID8.GetBSTR());

 

    _bstr_t layerID9 = "Layer-9";

    hr = pdf->AddLayer("Printable Layer", &layerID9.GetBSTR());

 

    // Setting Layer usage options (print, zoom ... )

    pdf->ObjectAttributeFloat("Layers[" + layerID8 + "]", "ZoomMin", 0.2);

    pdf->ObjectAttributeFloat("Layers[" + layerID8 + "]", "ZoomMax", 0.7);

 

    // Making Layer-9 printable

    pdf->ObjectAttributeStr("Layers[" + layerID9 + "]", "SubTypePrint", "Print");

    pdf->ObjectAttributeStr("Layers[" + layerID9 + "]", "PrintState", "ON");

 

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

 

    // Kind of configuration

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigAS", "Category:Print;Event:Print;layers:" + layerID9 + ";|Event:View;Category:Zoom;layers:" + layerID8 + ";");

 

    // set state of visibility by default

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

 

    // set the layers visibility to ON by default

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigON", "[" + layerID1 + " " + layerID3 + "]");

 

    // Set Order layers

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigOrder", "[" + layerID4 + " [" + layerID2 + " " + layerID3 + "] [" + layerID1 + " " + layerID5 + " " + layerID6 + " " + layerID7 + "]]");

 

    // set Groups

    hr = pdf->ObjectAttributeStr("LayerConfigs[" + configID + "]", "ConfigRBGroups", "[[" + layerID5 + " " + layerID6 + " " + layerID7 + "]]");

 

    // Set CurrentPage

    pdf->CurrentPage = 1;

 

    // Variable for Attributes

    _variant_t varAttribute;

    varAttribute.vt = VT_I4;  // integers

 

    // Create Text1

    hr = pdf->CreateObject(acObjectTypeText, "Text1");

    IacObjectPtr oText = pdf->GetObjectByName("Text1");

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

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

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

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

    oText->Attribute["Text"] = "+++ Layer 1 +++";

    // Layer Attributes

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

 

    // Create Text2

    hr = pdf->CreateObject(acObjectTypeText, "Text2");

    oText = pdf->GetObjectByName("Text2");

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

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

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

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

    oText->Attribute["Text"] = "+++ Child invisible +++";

    // Layer Attributes

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

 

    // Create Text3

    hr = pdf->CreateObject(acObjectTypeText, "Text3");

    oText = pdf->GetObjectByName("Text3");

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

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

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

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

    oText->Attribute["Text"] = "+++ Child visible +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID3;

 

    // Create Text4

    hr = pdf->CreateObject(acObjectTypeText, "Text4");

    oText = pdf->GetObjectByName("Text4");

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

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

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

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

    oText->Attribute["Text"] = "+++ Parent for both children +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID4;

 

    // Create Text5

    hr = pdf->CreateObject(acObjectTypeText, "Text5");

    oText = pdf->GetObjectByName("Text5");

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

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

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

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

    oText->Attribute["Text"] = "+++ RB group text 1 +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID3;

 

    // Create Text6

    hr = pdf->CreateObject(acObjectTypeText, "Text6");

    oText = pdf->GetObjectByName("Text2");

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

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

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

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

    oText->Attribute["Text"] = "+++ RB group text 2 +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID6;

 

    // Create Text7

    hr = pdf->CreateObject(acObjectTypeText, "Text7");

    oText = pdf->GetObjectByName("Text7");

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

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

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

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

    oText->Attribute["Text"] = "+++ RB group text 3 +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID7;

 

    // Create Text8

    hr = pdf->CreateObject(acObjectTypeText, "Text8");

    oText = pdf->GetObjectByName("Text2");

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

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

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

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

    oText->Attribute["Text"] = "+++ Zoom text (visible only when zoom is between 20% and 70%) +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID8;

 

    // Create Text9

    hr = pdf->CreateObject(acObjectTypeText, "Text9");

    oText = pdf->GetObjectByName("Text2");

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

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

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

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

    oText->Attribute["Text"] = "+++ Printable text\r(visible only on print) +++";

    // Layer Attributes

    oText->Attribute["LayerID"] = layerID9;

 

    // 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"

pdf.AddLayer "Layer 1", (layerID1)

 

Dim layerID2

layerID2 = "Layer-2"

pdf.AddLayer "Should not be visible", (layerID2)

 

Dim layerID3

layerID3 = "Layer-3"

pdf.AddLayer "Should be visible", (layerID3)

 

Dim layerID4

layerID4 = "Layer-4"

pdf.AddLayer "Parent Layer", (layerID4)

 

Dim layerID5

layerID5 = "Layer-5"

pdf.AddLayer "RB group element 1", (layerID5)

 

Dim layerID6

layerID6 = "Layer-6"

pdf.AddLayer "RB group element 2", (layerID6)

 

Dim layerID7

layerID7 = "Layer-7"

pdf.AddLayer "RB group element 3", (layerID7)

 

Dim layerID8

layerID8 = "Layer-8"

pdf.AddLayer "Zoom Layer", (layerID8)

 

Dim layerID9

layerID9 = "Layer-9"

pdf.AddLayer "Printable Layer", (layerID9)

 

' Setting Layer usage options (print, zoom ... )

pdf.ObjectAttribute("Layers[" + layerID8 + "]", "ZoomMin") = 0.2

pdf.ObjectAttribute("Layers[" + layerID8 + "]", "ZoomMax") = 0.7

 

' Making Layer-9 printable

pdf.ObjectAttribute("Layers[" + layerID9 + "]", "SubTypePrint") = "Print"

pdf.ObjectAttribute("Layers[" + layerID9 + "]", "PrintState") = "ON"

 

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

 

' Kind of configuration

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigAS") = "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";"

 

' set state of visibility by default

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigBaseState") = "OFF"

 

' set the layers visibility to ON by default

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigON") = "[" + layerID1 + " " + layerID3 + "]"

 

' Set Order layers

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigOrder") = "[" + layerID4 + " [" + layerID2 + " " + layerID3 + "] [" + layerID1 + " " + layerID5 + " " + layerID6 + " " + layerID7 + "]]"

 

' Set Groups

pdf.ObjectAttribute("LayerConfigs[" + configID + "]", "ConfigRBGroups") = "[[" + layerID5 + " " + layerID6 + " " + layerID7 + "]]"

 

' Set CurrentPage

pdf.CurrentPage = 1

 

' Adding Text1

pdf.CreateObject acObjectTypeText, "Text1"

Dim oText

Set oText = pdf.GetObjectByName("Text1")

oText("Left") = 2000

oText("Right") = 3000

oText("Top") = 1500

oText("Bottom") = 1515

oText("Text") = "+++ Layer 1 +++"

' Layer Attributes

oText("LayerID") = layerID1

 

' Adding Text2

pdf.CreateObject acObjectTypeText, "Text2"

Set oText = pdf.GetObjectByName("Text2")

oText("Left") = 2500

oText("Right") = 3000

oText("Top") = 2500

oText("Bottom") = 2515

oText("Text") = "+++ Child invisible +++"

' Layer Attributes

oText("LayerID") = layerID2

 

' Adding Text3

pdf.CreateObject acObjectTypeText, "Text3"

Set oText = pdf.GetObjectByName("Text3")

oText("Left") = 2500

oText("Right") = 3000

oText("Top") = 3500

oText("Bottom") = 3515

oText("Text") = "+++ Child visible +++"

' Layer Attributes

oText("LayerID") = layerID3

 

' Adding Text4

pdf.CreateObject acObjectTypeText, "Text4"

Set oText = pdf.GetObjectByName("Text4")

oText("Left") = 2500

oText("Right") = 2500

oText("Top") = 4500

oText("Bottom") = 4515

oText("Text") = "+++ Parent for both children +++"

' Layer Attributes

oText("LayerID") = layerID4

 

' Adding Text5

pdf.CreateObject acObjectTypeText, "Text5"

Set oText = pdf.GetObjectByName("Text5")

oText("Left") = 1950

oText("Right") = 2450

oText("Top") = 5500

oText("Bottom") = 5515

oText("Text") = "+++ RB group text 1 +++"

' Layer Attributes

oText("LayerID") = layerID5

 

' Adding Text6

pdf.CreateObject acObjectTypeText, "Text6"

Set oText = pdf.GetObjectByName("Text6")

oText("Left") = 1950

oText("Right") = 2450

oText("Top") = 6500

oText("Bottom") = 6515

oText("Text") = "+++ RB group text 2 +++"

' Layer Attributes

oText("LayerID") = layerID6       

 

' Adding Text7

pdf.CreateObject acObjectTypeText, "Text7"

Set oText = pdf.GetObjectByName("Text7")

oText("Left") = 1950

oText("Right") = 2450

oText("Top") = 7500

oText("Bottom") = 7515

oText("Text") = "+++ RB group text 3 +++"

' Layer Attributes

oText("LayerID") = layerID7

 

' Adding Text8

pdf.CreateObject acObjectTypeText, "Text8"

Set oText = pdf.GetObjectByName("Text8")

oText("Left") = 1950

oText("Right") = 2450

oText("Top") = 8500

oText("Bottom") = 8515

oText("Text") = "+++ Zoom text (visible only when zoom is between 20% and 70%) +++"

' Layer Attributes

oText("LayerID") = layerID8

 

' Adding Text9

pdf.CreateObject acObjectTypeText, "Text9"

Set oText = pdf.GetObjectByName("Text9")

oText("Left") = 1950

oText("Right") = 2450

oText("Top") = 9500

oText("Bottom") = 9515

oText("Text") = "+++ Printable text\r(visible only on print) +++"

' Layer Attributes

oText("LayerID") = layerID9

 

' Save PDF

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

 

' destroy objects

Set oText = Nothing

Set pdf = Nothing