Page | 10
Browse for acPDFCreatorLib.Net.dll. The control shows in the list of insertable .NET components as
“PDFCreator”. Once added to the toolbox, the component appears in the components toolbar and
can be inserted on a form:
Setting the Licensing Information
Before any operation can be done on the PDF Creator library or control, the library or the control
needs to be activated using the SetLicenseKey method as shown below.
A sample code for using the PDF Creator control to open a PDF file for viewing or editing:
// All Amyuni classes used here are defined in the Amyuni.PDFCreator namespace
// Initialize the Library
acPDFCreatorLib.Initialize ();
// Set the License key
acPDFCreatorLib.SetLicenseKey ("Amyuni Tech.", "07EFCD10001…7857EC1193FA”);
Amyuni.PDFCreator.PDFCreator pdfCreator;
PdfCreator = new Amyuni.PDFCreator.PDFCreator ();
//open a pdf document from file
System.IO.FileStream file1 = new System.IO.FileStream ("Page.pdf", FileMode.Open,
FileAccess.Read, FileShare.Read);
IacDocument document = pdfCreator.Document;
document.Open (file1, "");
//switch to design mode before adding objects to the document
document.ReportState = IacReportState.acReportStateDesign;
//create a rectangular frame to add to the document
IacPage page = document.GetPage (1);
Amyuni.PDFCreator.IacObject frame = page.CreateObject
(IacObjectType.acObjectTypeText,"Frame 1");
//position the frame
frame.AttributeByName ("Left").Value = 200;
frame.AttributeByName ("Top").Value = 600;
frame.AttributeByName ("Right").Value = 2000;
frame.AttributeByName ("Bottom").Value = 800;
frame.AttributeByName ("Text").Value = "Hello";
// save modified document to a new file (file2)
System.IO.FileStream file2 = new System.IO.FileStream ("test3.pdf",
FileMode.Create, FileAccess.Write, FileShare.Read);
document.Save (file2, IacFileSaveOption.acFileSaveView);
file2.Close ();
// terminate library to free resources
acPDFCreatorLib.Terminate ();