The SetLicenseKey method is used to set licensing information.
Public Shared Function SetLicenseKey(Company As String, LicKey As String) As Boolean
public static bool SetLicenseKey(string Company , string LicKey)
Company
Name of the company or public user having licensed the product.
LicKey
License key provided by Amyuni Technologies when downloading or purchasing a product.
Returns Value True if the license key is valid, False otherwise.
The exception Amyuni.PDFCreator.IacException.LicenseKeyError might be generated if the provided license is not valid or wrong.
acPDFCreator.Net and System.Windows.Forms should be added in the References to have access to this method
In case the license was not set as indicated, the user will have limited authorities as of using the PDF Creator control. Moreover, a watermark will always appear on every page viewed in the control or saved in a file.
There are two alternative ways to set the license: Using the acPDFCreatorLib.SetLicenseKey Method or IacDocument.SetLicenseKey Method.
Member of Amyuni.PDFCreator.PDFCreator.
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()
' Create new stream object
Dim fileRead As System.IO.Stream = System.IO.File.OpenRead("C:\temp\PDFDocument.pdf")
' Creating a new Amyuni PDFCreator object
Dim pdf As New Amyuni.PDFCreator.PDFCreator()
' Set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode)
' Open stream
Dim Password As String = ""
pdf.Document.Open(fileRead, Password)
' Declare image sizes
Dim nW, nH As Integer
' Get the width and height of page 1 of the PDF document
' The PDF Creator.NET also exposes a number methods or properties that will allow
' the developer to access or interate pages
nW = pdf.GetPage(1).GetPageFormat().Width
nH = pdf.GetPage(1).GetPageFormat().Length
' Create Image
Const twipsPerInch As Integer = 1440
Const resolution As Integer = 90
' Create Image
Dim img As New System.Drawing.Bitmap(Convert.ToInt32(nW * resolution / twipsPerInch), Convert.ToInt32(nH * resolution / twipsPerInch))
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(img)
' set image object background to white
g.Clear(System.Drawing.Color.White)
' get a device contents of the PDF document on the graphic context
Dim hdc As IntPtr = g.GetHdc()
' draw the contents of the PDF object on the graphic context
pdf.DrawCurrentPage(hdc, True)
' Clean up
g.ReleaseHdc(hdc)
g.Dispose()
' Saving image
img.Save("c:\temp\image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
' Close the stream
fileRead.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();
// Create a steam that will be used to load
// this call also be a filestream from a database
System.IO.FileStream fileRead = new System.IO.FileStream(@"c:\temp\PDFdocument.pdf",
System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
// Creating a new Amyuni PDFCreator object
Amyuni.PDFCreator.PDFCreator pdf = new Amyuni.PDFCreator.PDFCreator();
// Set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode);
// Open stream
String password = "";
pdf.Document.Open(fileRead, password);
// declare images sizes
int nW, nH;
// Get the width and height of page 1 of the PDF document
// The PDF Creator.NET also exposes a number methods or properties that will allow
// the developer to access or interate pages
nW = pdf.GetPage(1).GetPageFormat().Width;
nH = pdf.GetPage(1).GetPageFormat().Length;
// Create Image
const int twipsPerInch = 1440;
const int resolution = 90;
System.Drawing.Bitmap img = new System.Drawing.Bitmap((int)(nW * resolution / twipsPerInch), (int)(nH * resolution / twipsPerInch));
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);
// set image object background to white
g.Clear(System.Drawing.Color.White);
// Get a device context for the grahics object
IntPtr hdc = g.GetHdc();
// draw the contents of the PDF object on the graphic context
pdf.DrawCurrentPage(hdc, true);
// clean up
g.ReleaseHdc(hdc);
g.Dispose();
// Saving image
img.Save(@"c:\temp\image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
// Close the stream
fileRead.Close();
// terminate library to free resources
acPDFCreatorLib.Terminate();
}