Using the PDFCreator as a DLL in .NET

To use the Amyuni PDF Creator library as a dll, without adding the ActiveX control to your project, you need to generate the type library and ActiveX control wrappers for it and add these to your references:

  1. Start the visual studio command prompt by navigating to: Start Menu\Programs\Microsoft Visual Studio 2017\ Visual Studio Tools.

  2. Start the application Visual Studio 2017 Command Prompt.

Change to the folder into the folder where the creator library was installed and run the aximp command on it:

 

  1. Next go to your Visual Studio project’s References folder and add the two dlls generated above by browsing to their location.

 

To add use the library through the COM IDispatch interface, use the ProgID "PDFCreactiveX.PDFCreactiveX"

To make sure that the latest version 6.0 is being used, you can also use "PDFCreactiveX.PDFCreactiveX.6.5"

 

Example

<Flags>

Enum ObjectTypeConstants As Integer

    acObjectTypeAnnotation = 40

    acObjectTypeArrow = 36

    acObjectTypeAttachment = 43

    acObjectTypeBarcode = 45

    acObjectTypeCell = 33

    acObjectTypeCheckBox = 21

    acObjectTypeDefaultAttributes = 37

    acObjectTypeDocument = 30

    acObjectTypeEllipse = 4

    acObjectTypeError = 42

    acObjectTypeExcel = 17

    acObjectTypeExternal = 38

    acObjectTypeField = 6

    acObjectTypeFont = 34

    acObjectTypeFormXObject = 44

    acObjectTypeFrame = 2

    acObjectTypeFreehand = 9

    acObjectTypeGraph = 19

    acObjectTypeGroup = 29

    acObjectTypeHighlight = 23

    acObjectTypeLayer = 41

    acObjectTypeLine = 1

    acObjectTypeOLE = 20

    acObjectTypePage = 31

    acObjectTypePageNumbers = 35

    acObjectTypePicture = 7

    acObjectTypePolygon = 8

    acObjectTypeRoundFrame = 3

    acObjectTypeRow = 32

    acObjectTypeSection = 15

    acObjectTypeSelection = 24

    acObjectTypeSignature = 39

    acObjectTypeStickyNote = 22

    acObjectTypeTable = 16

    acObjectTypeText = 5

    acObjectTypeUnknown = 0

    acObjectTypeWord = 18

End Enum

 

<Flags>

Enum acBorderWidth As Integer

    acBorderWidthNone = 0

    acBorderWidthSimple = 1

    acBorderWidthDouble = 2

    acBorderWidthTriple = 3

    acBorderWidthQuadruple = 4

End Enum

 

<Flags>

Enum FileSaveOptionConstants As Integer

    acFileSaveAll = 0

    acFileSaveDefault = -1

    acFileSaveDesign = 2

    acFileSavePDF14 = 5

    acFileSavePDFA = 4

    acFileSavePDFA_7 = 3

    acFileSaveView = 1

End Enum

 

 

Sub Sample()

    ' ants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"

    Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"

 

    ' Initializing PDFCreativeX Object

    Dim pdfCreactiveX As Type = Type.GetTypeFromProgID("PDFCreactiveX.PDFCreactiveX.6.5", True)

    Dim pdf = Activator.CreateInstance(PDFCreactiveX)

 

    ' Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Set CurrentPage

    pdf.CurrentPage = 1

 

    ' Create a Text in the current Page

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

 

    ' Define obj as Text1

    Dim oText = pdf.GetObjectByName("Text1")

 

    ' Set-up the Text

    oText("Left") = 1000

    oText("Right") = 5000

    oText("Top") = 0

    oText("Bottom") = 4000

    oText("BorderColor") = &HFF00FF

    oText("BorderWidth") = acBorderWidth.acBorderWidthDouble

 

    ' Text Attributes

    oText("Text") = "Amyuni Technologies"

 

    ' Save PDF

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

 

 

    oText = Nothing

End Sub

[Flags]

enum ObjectTypeConstants

{

    acObjectTypeAnnotation = 40,

    acObjectTypeArrow = 36,

    acObjectTypeAttachment = 43,

    acObjectTypeBarcode = 45,

    acObjectTypeCell = 33,

    acObjectTypeCheckBox = 21,

    acObjectTypeDefaultAttributes = 37,

    acObjectTypeDocument = 30,

    acObjectTypeEllipse = 4,

    acObjectTypeError = 42,

    acObjectTypeExcel = 17,

    acObjectTypeExternal = 38,

    acObjectTypeField = 6,

    acObjectTypeFont = 34,

    acObjectTypeFormXObject = 44,

    acObjectTypeFrame = 2,

    acObjectTypeFreehand = 9,

    acObjectTypeGraph = 19,

    acObjectTypeGroup = 29,

    acObjectTypeHighlight = 23,

    acObjectTypeLayer = 41,

    acObjectTypeLine = 1,

    acObjectTypeOLE = 20,

    acObjectTypePage = 31,

    acObjectTypePageNumbers = 35,

    acObjectTypePicture = 7,

    acObjectTypePolygon = 8,

    acObjectTypeRoundFrame = 3,

    acObjectTypeRow = 32,

    acObjectTypeSection = 15,

    acObjectTypeSelection = 24,

    acObjectTypeSignature = 39,

    acObjectTypeStickyNote = 22,

    acObjectTypeTable = 16,

    acObjectTypeText = 5,

    acObjectTypeUnknown = 0,

    acObjectTypeWord = 18

}

 

enum acBorderWidth

{

    acBorderWidthNone = 0,

    acBorderWidthSimple = 1,

    acBorderWidthDouble = 2,

    acBorderWidthTriple = 3,

    acBorderWidthQuadruple = 4,

}

 

[Flags]

enum FileSaveOptionConstants

{

    acFileSaveAll = 0,

    acFileSaveDefault = -1,

    acFileSaveDesign = 2,

    acFileSavePDF14 = 5,

    acFileSavePDFA = 4,

    acFileSavePDFA_7 = 3,

    acFileSaveView = 1

}

 

static void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Creator Evaluation";

    const string strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";

 

    // Initializing PDFCreativeX Object

    Type PDFCreactiveX = Type.GetTypeFromProgID("PDFCreactiveX.PDFCreactiveX.6.5", true);

    dynamic pdf = Activator.CreateInstance(PDFCreactiveX);

 

    // Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Set CurrentPage

    pdf.CurrentPage = 1;

 

    // Create a Text in the current Page

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

 

    // Define obj as Text1

    dynamic oText = pdf.GetObjectByName("Text1");

 

    // Set-up the Picture

    oText["Left"] = 1000;

    oText["Right"] = 5000;

 

    oText["Top"] = 0;

    oText["Bottom"] = 4000;

    oText["BorderColor"] = 0xFF00FF;

    oText["BorderWidth"] = acBorderWidth.acBorderWidthDouble;

 

    // Text Attributes

    oText["Text"] = "Amyuni Technologies";

 

    // Save PDF

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

 

 

    oText = null;

}

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

 

    // Set CurrentPage

    pdf->CurrentPage = 1;

 

    // Create a Picture in the current Page

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

 

    // Set-up variables for attributes

    _variant_t varAttribute;

 

    // Set-up the Picture

    varAttribute.vt = VT_I4;  // integers

    varAttribute.lVal = 1000;

    pdf->put_ObjectAttribute(_bstr_t("Text1"), _bstr_t(L"Left"), varAttribute);

 

    varAttribute.lVal = 5000;

    pdf->put_ObjectAttribute(_bstr_t("Text1"), _bstr_t(L"Right"), varAttribute);

 

    varAttribute.lVal = 0;

    pdf->put_ObjectAttribute(_bstr_t("Text1"), _bstr_t(L"Top"), varAttribute);

 

    varAttribute.lVal = 4000;

    pdf->put_ObjectAttribute(_bstr_t("Text1"), _bstr_t(L"Bottom"), varAttribute);

 

    varAttribute.lVal = 0xFF00FF;

    pdf->put_ObjectAttribute(_bstr_t("Text1"), _bstr_t(L"BorderColor"), varAttribute);

 

    varAttribute.lVal = 1;

    pdf->put_ObjectAttribute(_bstr_t("Text1"), _bstr_t(L"BorderWidth"), varAttribute);

 

    // Text Attributes

    pdf->ObjectAttributeStr(_bstr_t("Text1"), _bstr_t("Text"), _bstr_t("Amyuni Technologies"));;

 

    // Save PDF

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

 

    // destroy objects

    pdf = NULL;

 

    Return 0;

}

' ObjectTypeConstants

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

 

' acBorderWidth

Const acBorderWidthNone = 0

Const acBorderWidthSimple = 1

Const acBorderWidthDouble = 2

Const acBorderWidthTriple = 3

Const acBorderWidthQuadruple = 4

 

' FileSaveOptionConstants

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

 

' Set CurrentPage

pdf.CurrentPage = 1

 

' Create a Text in the current Page

pdf.CreateObject acObjectTypeText, "Text1"

 

' Define Object

Dim oText 

Set oText = pdf.GetObjectByName("Text1")

 

' General Attributes

oText("Left") = 1000

oText("Right") = 5000

oText("Top") = 0

oText("Bottom") = 4000

oText("BorderColor") = &HFF00FF

 

oText("BorderWidth") = acBorderWidthDouble

 

' Text Attributes

oText("Text") = "Amyuni Technologies"

 

' Save PDF

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

 

' destroy Objects

Set pdf = Nothing

Set oText = Nothing