Attribute |
Description |
Type |
---|---|---|
LayerID (R) |
Attribute cannot be changed by the user. It is only assigned through AddLayer. |
String |
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 |
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).
Attribute |
Description |
Type |
---|---|---|
ConfigName (R) |
(Mandatory) This is the unique name of the configuration (configID). It is only assigned through AddLayerConfiguration. |
String |
ConfigBaseState |
(Optional) ("ON", "OFF" or "Unchanged"). |
String |
ConfigCreator |
(Optional) |
String |
ConfigON |
(Optional) Representing a list of layer IDs that are visible by default. (see Remarks). |
String |
ConfigOFF |
(Optional)Representing a list of layer IDs that are invisible by default. (see Remarks). |
String |
ConfigIntent |
(Optional) ("View" or "Design"). |
String |
ConfigOrder |
(Mandatory) String type representing an List of layer IDs. |
String |
ConfigList |
(Optional) ("AllPages" or "VisiblePages"). |
String |
ConfigRBGroups |
(Optional) List of LayerIDs |
String |
ConfigLocked |
(Optional) List of layer IDs that are always locked and cannot be changed by the user. |
String |
ConfigAS |
(Optional) See Remarks. |
String |
It is better to put BaseState as the opposite of PrintState.
The string should be the result of the concatenation of the Layer IDs obtained from the call of AddLayer.
For example: "[LayerID1 | LayerID2 | LayerID3]".
ConfigOrder is a string representing the order of the layers in the document, basically defining the tree order, listing all user interactive layers and sub layers. Inputting a wrong
A badly constructed ConfigOrder tree may render the generated file useless, here are the rules to follow:
The string must begin with a "[' and ends with a ' ]".
The layers IDs must be separated by |.
A new group of layers can be preceded by a descriptive string (title of the group).
Each new entry on the tree list must be enclosed in a new "[' ' ]" array.
For example: "[[(red components)| LayerID1 | LayerID2] [(Blue components)| LayerID3 | LayerID4]]".
LayerID1
LayerID2
LayerID3
LayerID4
ConfigRBGroups is a string representing the layers that behave as radio group style; only 1 layer from the group can be activated at a time. Rules to follow for ConfigRBGroups:
The string must begin with a "[' and ends with a ' ]".
Each radio-group related Layers must be enclosed between a "[' and a ' ]".
For example: "[[LayerID1 LayerID2] [LayerID3 LayerID4 LayerID5]]".
ConfigAS is a string relative to the configuration used. When setting additional layer attributes such as "Zoom" and "Print", those layers should be defined in the configuration dictionary.
Zoom attribute usage example:
"Event:View;Category:Zoom;layers: LayerID1"
Print attribute usage example:
"Category:Print;Event:Print;layers: LayerID2;"
Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"
' Initialize library
' This should be done once
acPDFCreatorLib.Initialize()
' set license key
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)
' Create a new PDF document
Dim doc As New Amyuni.PDFCreator.IacDocument()
' Create all the Layers
Dim layerID1 As String = "Layer1"
doc.AddLayer("LayerA", layerID1)
Dim layerID2 As String = "Layer2"
doc.AddLayer("LayerB-RB", layerID2)
Dim layerID3 As String = "Layer3"
doc.AddLayer("LayerC-RB", layerID3)
Dim layerID4 As String = "Layer4"
doc.AddLayer("LayerD", layerID4)
Dim layerID5 As String = "Layer5"
doc.AddLayer("LayerE", layerID5)
Dim layerID6 As String = "Layer6"
doc.AddLayer("Image Layer", layerID6)
Dim layerID7 As String = "Zoom Level"
doc.AddLayer("Image Layer - 2", layerID7)
Dim layerID8 As String = "Layer---8"
doc.AddLayer("Non Printable Layer", layerID8)
' Setting Layer usage options (print, zoom ... )
Using layerObj As Amyuni.PDFCreator.IacObject = doc.ObjectByName("Layers[" + layerID7 + "]")
layerObj.Attribute("ZoomMin").Value = 0.2
layerObj.Attribute("ZoomMax").Value = 0.7
End Using
' Making Layer - --8 non - printable
Using layerObj As Amyuni.PDFCreator.IacObject = doc.ObjectByName("Layers[" + layerID8 + "]")
layerObj.Attribute("SubTypePrint").Value = "Print"
layerObj.Attribute("PrintState").Value = "OFF"
End Using
' When setting ConfigAS attribute each block of Category/Event/layers must be separated by |
Dim configID As String = ""
doc.AddLayerConfiguration(configID)
Using oLayerConfig As Amyuni.PDFCreator.IacObject = doc.ObjectByName("LayerConfigs[" + configID + "]")
' Kind of configuration
oLayerConfig.Attribute("ConfigAS").Value = "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";"
' set the layers visibility to ON by default
oLayerConfig.Attribute("ConfigON").Value = "[" + layerID1 + " " + layerID4 + " " + layerID5 + "]"
' set the layers visibility to OFF by default
oLayerConfig.Attribute("ConfigOFF").Value = "[" + layerID2 + " " + layerID3 + " " + layerID6 + "]"
' set state of visibility by default
oLayerConfig.Attribute("ConfigBaseState").Value = "ON"
' Set Order layers
oLayerConfig.Attribute("ConfigOrder").Value = "[" + layerID4 + " [" + layerID1 + " " + layerID5 + "] [(this is the text string) " + layerID2 + " " + layerID3 + "] [(Turn On Nicole) " + layerID6 + "]]"
' Set Groups
oLayerConfig.Attribute("ConfigRBGroups").Value = "[[" + layerID2 + " " + layerID3 + "]]"
' set list of Layers
oLayerConfig.Attribute("ConfigList").Value = "AllPages"
' set layers to be locked and the user cannot change
oLayerConfig.Attribute("ConfigLocked").Value = "[" + layerID1 + "]"
End Using
' Create page object
Dim page As Amyuni.PDFCreator.IacPage
' Define first page of PDF document
page = doc.GetPage(1)
' Create Line 1
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeLine, "LineObject1")
.Attribute("Left").Value = 10
.Attribute("Right").Value = 5010
.Attribute("Top").Value = 10
.Attribute("Bottom").Value = 5010
.Attribute("StrokeColor").Value = &HFF0000
' Layer Attributes
.Attribute("LayerID").Value = layerID1
End With
' Create Line 2
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeLine, "LineObject2")
.Attribute("Left").Value = 10
.Attribute("Right").Value = 5010
.Attribute("Top").Value = 5010
.Attribute("Bottom").Value = 10
.Attribute("StrokeColor").Value = &HFF00FF
' Layer Attributes
.Attribute("LayerID").Value = layerID5
End With
' Create a Text1
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text1")
.Attribute("Left").Value = 10
.Attribute("Right").Value = 1000
.Attribute("Top").Value = 10
.Attribute("Bottom").Value = 25
.Attribute("Text").Value = "----------This test should go into layer 2 ..."
' Layer Attributes
.Attribute("LayerID").Value = layerID2
End With
' Create a Text2
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text2")
.Attribute("Left").Value = 2000
.Attribute("Right").Value = 5000
.Attribute("Top").Value = 0
.Attribute("Bottom").Value = 15
.Attribute("Text").Value = "This test should go into layer 3 (Radio button)"
' Layer Attributes
.Attribute("LayerID").Value = layerID3
End With
' Create Picture1
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypePicture, "Picture1")
.Attribute("Left").Value = 850
.Attribute("Right").Value = 10000
.Attribute("Top").Value = 5050
.Attribute("Bottom").Value = 10000
.Attribute("FileName").Value = "C:\temp\photo1.jpg"
' Layer Attributes
.Attribute("LayerID").Value = layerID6
End With
' Create Picture2
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypePicture, "Picture2")
.Attribute("Left").Value = 7000
.Attribute("Right").Value = 10000
.Attribute("Top").Value = 3800
.Attribute("Bottom").Value = 10000
.Attribute("FileName").Value = "C:\temp\photo2.jpg"
' Layer Attributes
.Attribute("LayerID").Value = layerID7
End With
' Create a "unprintable" text object
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text3")
.Attribute("Left").Value = 1000
.Attribute("Right").Value = 10000
.Attribute("Top").Value = 1000
.Attribute("Bottom").Value = 1015
.Attribute("Text").Value = "This text should not be printed"
' Layer Attributes
.Attribute("LayerID").Value = layerID8
End With
' Create new stream object
Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("C:\temp\CreatePDFDocument_resulting.pdf")
' Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileWrite.Close()
' terminate library to free resources
acPDFCreatorLib.Terminate()
End Sub
static void Sample
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";
const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";
// Initialize library
// This should be done once
acPDFCreatorLib.Initialize();
// set license key
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);
// Create a new PDF document
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();
// Create all the Layers
string layerID1 = "Layer1";
doc.AddLayer("LayerA", ref layerID1);
string layerID2 = "Layer2";
doc.AddLayer("LayerB-RB", ref layerID2);
string layerID3 = "Layer3";
doc.AddLayer("LayerC-RB", ref layerID3);
string layerID4 = "Layer4";
doc.AddLayer("LayerD", ref layerID4);
string layerID5 = "Layer5";
doc.AddLayer("LayerE", ref layerID5);
string layerID6 = "Layer6";
doc.AddLayer("Image Layer", ref layerID6);
string layerID7 = "Zoom Level";
doc.AddLayer("Image Layer - 2", ref layerID7);
string layerID8 = "Layer---8";
doc.AddLayer("Non Printable Layer", ref layerID8);
// Setting Layer usage options (print, zoom ... )
using (Amyuni.PDFCreator.IacObject layerObj = doc.ObjectByName("Layers[" + layerID7 + "]"))
{
layerObj.Attribute("ZoomMin").Value = 0.2;
layerObj.Attribute("ZoomMax").Value = 0.7;
}
// Making Layer - --8 non - printable
using (Amyuni.PDFCreator.IacObject layerObj = doc.ObjectByName("Layers[" + layerID8 + "]"))
{
layerObj.Attribute("SubTypePrint").Value = "Print";
layerObj.Attribute("PrintState").Value = "OFF";
}
// Define the layer configuration as it will appear in a PDF Viewer, e.g.the order and visibility of layers
string configID = "";
doc.AddLayerConfiguration(ref configID);
using (Amyuni.PDFCreator.IacObject oLayerConfig = doc.ObjectByName("LayerConfigs[" + configID + "]"))
{
// Kind of configuration
oLayerConfig.Attribute("ConfigAS").Value = "Category:Print;Event:Print;layers:" + layerID8 + ";|Event:View;Category:Zoom;layers:" + layerID7 + ";";
// set the layers visibility to ON by default
oLayerConfig.Attribute("ConfigON").Value = "[" + layerID1 + " " + layerID4 + " " + layerID5 + "]";
// set the layers visibility to OFF by default
oLayerConfig.Attribute("ConfigOFF").Value = "[" + layerID2 + " " + layerID3 + " " + layerID6 + "]";
// set state of visibility by default
oLayerConfig.Attribute("ConfigBaseState").Value = "ON";
// Set Order layers
oLayerConfig.Attribute("ConfigOrder").Value = "[" + layerID4 + " [" + layerID1 + " " + layerID5 + "] [(this is the text string) " + layerID2 + " " + layerID3 + "] [(Turn On Nicole) " + layerID6 + "]]";
// set Groups
oLayerConfig.Attribute("ConfigRBGroups").Value = "[[" + layerID2 + " " + layerID3 + "]]";
// set list of Layers
oLayerConfig.Attribute("ConfigList").Value = "AllPages";
// set layers to be locked and the user cannot change
oLayerConfig.Attribute("ConfigLocked").Value = "[" + layerID1 + "]";
}
// Create page object
Amyuni.PDFCreator.IacPage page;
// Define first page of PDF document
page = doc.GetPage(1);
// Create Line 1
using (Amyuni.PDFCreator.IacObject oLine = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeLine, "LineObject1"))
{
oLine.Attribute("Left").Value = 10;
oLine.Attribute("Right").Value = 5010;
oLine.Attribute("Top").Value = 10;
oLine.Attribute("Bottom").Value = 5010;
oLine.Attribute("StrokeColor").Value = 0xFF0000;
// Layer Attributes
oLine.Attribute("LayerID").Value = layerID1;
}
// Create Line 2
using (Amyuni.PDFCreator.IacObject oLine = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeLine, "LineObject2"))
{
oLine.Attribute("Left").Value = 10;
oLine.Attribute("Right").Value = 5010;
oLine.Attribute("Top").Value = 5010;
oLine.Attribute("Bottom").Value = 10;
oLine.Attribute("StrokeColor").Value = 0xFF00FF;
// Layer Attributes
oLine.Attribute("LayerID").Value = layerID5;
}
// Adding Text1
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text1"))
{
oText.Attribute("Left").Value = 10;
oText.Attribute("Right").Value = 1000;
oText.Attribute("Top").Value = 10;
oText.Attribute("Bottom").Value = 25;
oText.Attribute("Text").Value = "----------This test should go into layer 2 ...";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID2;
}
// Adding Text2
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text2"))
{
oText.Attribute("Left").Value = 2000;
oText.Attribute("Right").Value = 5000;
oText.Attribute("Top").Value = 10;
oText.Attribute("Bottom").Value = 25;
oText.Attribute("Text").Value = "This test should go into layer 3 (Radio button)";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID3;
}
// Create Picture1
using (Amyuni.PDFCreator.IacObject oPic = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypePicture, "Picture1"))
{
oPic.Attribute("Left").Value = 850;
oPic.Attribute("Right").Value = 10000;
oPic.Attribute("Top").Value = 5050;
oPic.Attribute("Bottom").Value = 10000;
oPic.Attribute("Filename").Value = @"c:\temp\photo1.jpg";
// Layer Attributes
oPic.Attribute("LayerID").Value = layerID6;
}
// Create Picture2
using (Amyuni.PDFCreator.IacObject oPic = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypePicture, "Picture2"))
{
oPic.Attribute("Left").Value = 7000;
oPic.Attribute("Right").Value = 10000;
oPic.Attribute("Top").Value = 5050;
oPic.Attribute("Bottom").Value = 10000;
oPic.Attribute("Filename").Value = @"c:\temp\photo2.jpg";
// Layer Attributes
oPic.Attribute("LayerID").Value = layerID7;
}
// Create a "unprintable" text object
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text3"))
{
oText.Attribute("Left").Value = 1000;
oText.Attribute("Right").Value = 10000;
oText.Attribute("Top").Value = 1000;
oText.Attribute("Bottom").Value = 1015;
oText.Attribute("Text").Value = "This text should not be printed";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID8;
}
// Create new stream object
System.IO.FileStream fileWrite = new System.IO.FileStream(@"C:\Temp\CreatePDFDocument_resulting.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Close the stream
fileWrite.Close();
// terminate library to free resources
acPDFCreatorLib.Terminate();
}
Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"
' Initialize library
' This should be done once
acPDFCreatorLib.Initialize()
' set license key
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)
' Create a new PDF document
Dim doc As New Amyuni.PDFCreator.IacDocument()
' Create all the Layers
Dim layerID1 As String = "Layer-1"
doc.AddLayer("Layer 1", layerID1)
Dim layerID2 As String = "Layer-2"
doc.AddLayer("Should not be visible", layerID2)
Dim layerID3 As String = "Layer-3"
doc.AddLayer("Should be visible", layerID3)
Dim layerID4 As String = "Layer-4"
doc.AddLayer("Parent Layer", layerID4)
Dim layerID5 As String = "Layer-5"
doc.AddLayer("RB group element 1", layerID5)
Dim layerID6 As String = "Layer-6"
doc.AddLayer("RB group element 2", layerID6)
Dim layerID7 As String = "Layer-7"
doc.AddLayer("RB group element 3", layerID7)
Dim layerID8 As String = "Layer-8"
doc.AddLayer("Zoom Layer", layerID8)
Dim layerID9 As String = "Layer-9"
doc.AddLayer("Print Layer", layerID9)
' Setting Layer usage options (print, zoom ... )
Using layerObj As Amyuni.PDFCreator.IacObject = doc.ObjectByName("Layers[" + layerID8 + "]")
layerObj.Attribute("ZoomMin").Value = 0.2
layerObj.Attribute("ZoomMax").Value = 0.7
End Using
' Making Layer - --8 non - printable
Using layerObj As Amyuni.PDFCreator.IacObject = doc.ObjectByName("Layers[" + layerID9 + "]")
layerObj.Attribute("SubTypePrint").Value = "Print"
layerObj.Attribute("PrintState").Value = "ON"
End Using
' When setting ConfigAS attribute each block of Category/Event/layers must be separated by |
Dim configID As String = ""
doc.AddLayerConfiguration(configID)
Using oLayerConfig As Amyuni.PDFCreator.IacObject = doc.ObjectByName("LayerConfigs[" + configID + "]")
' Kind of configuration
oLayerConfig.Attribute("ConfigAS").Value = "Category:Print;Event:Print;layers:" + layerID9 + ";|Event:View;Category:Zoom;layers:" + layerID8 + ";"
' set state of visibility by default
oLayerConfig.Attribute("ConfigBaseState").Value = "OFF"
' set the layers visibility to ON by default
oLayerConfig.Attribute("ConfigON").Value = "[" + layerID1 + " " + layerID3 + "]"
' /Set Order layers
oLayerConfig.Attribute("ConfigOrder").Value = "[" + layerID4 + " [" + layerID2 + " " + layerID3 + "] [" + layerID1 + " " + layerID5 + " " + layerID6 + " " + layerID7 + "]]"
' set Groups
oLayerConfig.Attribute("ConfigRBGroups").Value = "[[" + layerID5 + " " + layerID6 + " " + layerID7 + "]]"
End Using
' Create page object
Dim page As Amyuni.PDFCreator.IacPage
' Define first page of PDF document
page = doc.GetPage(1)
' Create a Text1
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text1")
.Attribute("Left").Value = 2000
.Attribute("Right").Value = 3000
.Attribute("Top").Value = 1500
.Attribute("Bottom").Value = 1515
.Attribute("Text").Value = "+++ Layer 1 +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID1
End With
' Create a Text2
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text2")
.Attribute("Left").Value = 2500
.Attribute("Right").Value = 3000
.Attribute("Top").Value = 2500
.Attribute("Bottom").Value = 2515
.Attribute("Text").Value = "+++ Child invisible +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID2
End With
' Create a Text3
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text3")
.Attribute("Left").Value = 2500
.Attribute("Right").Value = 3000
.Attribute("Top").Value = 3500
.Attribute("Bottom").Value = 3515
.Attribute("Text").Value = "+++ Child visible +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID3
End With
' Create a Text4
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text4")
.Attribute("Left").Value = 2500
.Attribute("Right").Value = 2500
.Attribute("Top").Value = 4500
.Attribute("Bottom").Value = 4515
.Attribute("Text").Value = "+++ Parent for both children +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID4
End With
' Create a Text5
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text5")
.Attribute("Left").Value = 1950
.Attribute("Right").Value = 2450
.Attribute("Top").Value = 5500
.Attribute("Bottom").Value = 5515
.Attribute("Text").Value = "+++ RB group text 1 +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID5
End With
' Create a Text6
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text6")
.Attribute("Left").Value = 1950
.Attribute("Right").Value = 2450
.Attribute("Top").Value = 6500
.Attribute("Bottom").Value = 6515
.Attribute("Text").Value = "+++ RB group text 2 +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID6
End With
' Create a Text7
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text7")
.Attribute("Left").Value = 1950
.Attribute("Right").Value = 2450
.Attribute("Top").Value = 7500
.Attribute("Bottom").Value = 7515
.Attribute("Text").Value = "+++ RB group text 3 +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID7
End With
' Create a Text8
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text8")
.Attribute("Left").Value = 1950
.Attribute("Right").Value = 2450
.Attribute("Top").Value = 8500
.Attribute("Bottom").Value = 8515
.Attribute("Text").Value = "+++ Zoom text (visible only when zoom is between 20% and 70%) +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID8
End With
' Create a Text9
With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text9")
.Attribute("Left").Value = 1950
.Attribute("Right").Value = 2450
.Attribute("Top").Value = 9500
.Attribute("Bottom").Value = 9515
.Attribute("Text").Value = "+++ Printable text\r(visible only on print) +++"
' Layer Attributes
.Attribute("LayerID").Value = layerID9
End With
' Create new stream object
Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("C:\temp\CreatePDFDocument_resulting.pdf")
' Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileWrite.Close()
' terminate library to free resources
acPDFCreatorLib.Terminate()
End Sub
static void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";
const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";
// Initialize library
// This should be done once
acPDFCreatorLib.Initialize();
// set license key
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);
// Create a new PDF document
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();
// Create all the Layers
string layerID1 = "Layer-1";
doc.AddLayer("Layer 1", ref layerID1);
string layerID2 = "Layer-2";
doc.AddLayer("Should not be visible", ref layerID2);
string layerID3 = "Layer-3";
doc.AddLayer("Should be visible", ref layerID3);
string layerID4 = "Layer-4";
doc.AddLayer("Parent Layer", ref layerID4);
string layerID5 = "Layer-5";
doc.AddLayer("RB group element 1", ref layerID5);
string layerID6 = "Layer-6";
doc.AddLayer("RB group element 2", ref layerID6);
string layerID7 = "Layer-7";
doc.AddLayer("RB group element 3", ref layerID7);
string layerID8 = "Layer-8";
doc.AddLayer("Zoom Layer", ref layerID8);
string layerID9 = "Layer-9";
doc.AddLayer("Print Layer", ref layerID9);
// Setting Layer usage options (print, zoom ... )
using (Amyuni.PDFCreator.IacObject layerObj = doc.ObjectByName("Layers[" + layerID8 + "]")) {
layerObj.Attribute("ZoomMin").Value = 0.2;
layerObj.Attribute("ZoomMax").Value = 0.7;
}
// Making Layer 9 printable
using (Amyuni.PDFCreator.IacObject layerObj = doc.ObjectByName("Layers[" + layerID9 + "]"))
{
layerObj.Attribute("SubTypePrint").Value = "Print";
layerObj.Attribute("PrintState").Value = "ON";
}
// Define the layer configuration as it will appear in a PDF Viewer, e.g.the order and visibility of layers
string configID = "";
doc.AddLayerConfiguration(ref configID);
using (Amyuni.PDFCreator.IacObject oLayerConfig = doc.ObjectByName("LayerConfigs[" + configID + "]"))
{
// Kind of configuration
oLayerConfig.Attribute("ConfigAS").Value = "Category:Print;Event:Print;layers:" + layerID9 + ";|Event:View;Category:Zoom;layers:" + layerID8 + ";";
// set state of visibility by default
oLayerConfig.Attribute("ConfigBaseState").Value = "OFF";
// set the layers visibility to ON by default
oLayerConfig.Attribute("ConfigON").Value = "[" + layerID1 + " " + layerID3 + "]";
// Set Order layers
oLayerConfig.Attribute("ConfigOrder").Value = "[" + layerID4 + " [" + layerID2 + " " + layerID3 + "] [" + layerID1 + " " + layerID5 + " " + layerID6 + " " + layerID7 + "]]";
// set Groups
oLayerConfig.Attribute("ConfigRBGroups").Value = "[[" + layerID5 + " " + layerID6 + " " + layerID7 + "]]";
}
// Create page object
Amyuni.PDFCreator.IacPage page;
// Define first page of PDF document
page = doc.GetPage(1);
// Adding Text1
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text1"))
{
oText.Attribute("Left").Value = 2000;
oText.Attribute("Right").Value = 3000;
oText.Attribute("Top").Value = 1500;
oText.Attribute("Bottom").Value = 1515;
oText.Attribute("Text").Value = "+++ Layer 1 +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID1;
}
// Adding Text2
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text2"))
{
oText.Attribute("Left").Value = 2500;
oText.Attribute("Right").Value = 3000;
oText.Attribute("Top").Value = 2500;
oText.Attribute("Bottom").Value = 2515;
oText.Attribute("Text").Value = "+++ Child invisible +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID2;
}
// Adding Text3
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text3"))
{
oText.Attribute("Left").Value = 2500;
oText.Attribute("Right").Value = 3000;
oText.Attribute("Top").Value = 3500;
oText.Attribute("Bottom").Value = 3515;
oText.Attribute("Text").Value = "+++ Child visible +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID3;
}
// Adding Text4
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text4"))
{
oText.Attribute("Left").Value = 2000;
oText.Attribute("Right").Value = 2500;
oText.Attribute("Top").Value = 4500;
oText.Attribute("Bottom").Value = 4515;
oText.Attribute("Text").Value = "+++ Parent for both children +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID4;
}
// Adding Text5
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text5"))
{
oText.Attribute("Left").Value = 1950;
oText.Attribute("Right").Value = 2450;
oText.Attribute("Top").Value = 5500;
oText.Attribute("Bottom").Value = 5515;
oText.Attribute("Text").Value = "+++ RB group text 1 +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID5;
}
// Adding Text6
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text6"))
{
oText.Attribute("Left").Value = 1950;
oText.Attribute("Right").Value = 2450;
oText.Attribute("Top").Value = 6500;
oText.Attribute("Bottom").Value = 6515;
oText.Attribute("Text").Value = "+++ RB group text 2 +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID6;
}
// Adding Text7
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text7"))
{
oText.Attribute("Left").Value = 1950;
oText.Attribute("Right").Value = 2450;
oText.Attribute("Top").Value = 7500;
oText.Attribute("Bottom").Value = 7515;
oText.Attribute("Text").Value = "+++ RB group text 3 +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID7;
}
// Adding Text8
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text8"))
{
oText.Attribute("Left").Value = 1950;
oText.Attribute("Right").Value = 2450;
oText.Attribute("Top").Value = 8500;
oText.Attribute("Bottom").Value = 8515;
oText.Attribute("Text").Value = "+++ Zoom text (visible only when zoom is between 20% and 70%) +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID8;
}
// Adding Text9
using (Amyuni.PDFCreator.IacObject oText = page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text9"))
{
oText.Attribute("Left").Value = 1950;
oText.Attribute("Right").Value = 2450;
oText.Attribute("Top").Value = 9500;
oText.Attribute("Bottom").Value = 9515;
oText.Attribute("Text").Value = "+++ Printable text\r(visible only on print) +++";
// Layer Attributes
oText.Attribute("LayerID").Value = layerID9;
}
// Create new stream object
System.IO.FileStream fileWrite = new System.IO.FileStream(@"C:\Temp\CreatePDFDocument_resulting.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Close the stream
fileWrite.Close();
// terminate library to free resources
acPDFCreatorLib.Terminate();
}