Additional to the Common Attributes, this object has the following attributes:
Attribute Name |
Description |
Type |
Values |
Default Value |
---|---|---|---|---|
Left |
Left position in Twips |
Integer |
0 |
|
Top |
Top position in Twips |
Integer |
0 |
|
Right |
Right position in Twips |
Integer |
0 |
|
Bottom |
Bottom position in Twips |
Integer |
0 |
|
LeftF |
Left position in Twips |
Float |
0.00F |
|
TopF |
Top position in Twips |
Float |
0.00F |
|
RightF |
Right position in Twips |
Float |
0.00F |
|
BottomF |
Bottom position in Twips |
Float |
0.00F |
|
Page |
Page Index where object is located. Page Number is Page Index + 1. |
Integer |
>= 0 |
0 |
Filename |
Source file name, if image is loaded from an external file. |
String |
Supported input formats are: JPEG, BMP, TIFF, GIF, and PNG. |
None |
BorderColor |
Color for drawing text border. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF or in COLORREF (aabbggrr) 00000000 to FFFFFFFF |
000000 (Solid black) |
BorderWidth |
Width of border around text. Units in Twips. |
eum acBorderWidth
|
0: acBorderWidthNone 1: acBorderWidthSimple 2: acBorderWidthDouble 3: acBorderWidthTriple 4: acBorderWidthQuadruple |
0: acBorderWidthNone |
Compression |
Compression method. |
enum acImageCompressionConstants |
0: acCompressionDefault 1: acCompression256Colors 2: acCompressionJPegLow 7: acCompressionJPegMedium 9: acCompressionJPegHigh 10: acCompressionCCITTFax 11: acCompressionPNG 12: acCompressionJPG2000 13: acCompressionJBIG2 14: acCompressionJBIG2Huffman |
0: DocumentDefaultValue |
Hyperlink |
Clicking on the object in Run mode will navigate to the specified location |
String |
Using URL: http://, ftp: // , mailto:// , Using Bookmark: #Ref ex: #Pages[2] |
|
Locked |
Object cannot be modified |
Boolean |
True / False |
False |
BitmapData |
Defines the image information. |
Byte Array |
|
[] |
BitmapWidth |
Width of the image. In Pixels. |
Integer |
|
0 |
BitmapHeight |
Height of the image. In Pixels. |
Integer |
|
0 |
BitsPerComponent |
Number of bits per color component. |
Integer |
|
0 |
ColorSpace |
Defines the color-space for this bitmap. |
Integer |
|
0 |
Palette |
Color palette. |
Integer Array |
|
0 |
Mask |
Color used as mask. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF or in COLORREF (aabbggrr) 00000000 to FFFFFFFF |
FFFFFFFF (Transparent) |
GrayScale |
True if image is grayscale. |
Boolean |
True/False |
False |
Hidden |
Hidden in certain report states |
Integer |
A binary combination of the following values: 1: Hidden in Run mode 2: Hidden in Design mode 4: Reserved value 8: Hidden in Print preview 16: Hidden in Annotation mode |
0: Always visible |
RGBMask |
RGB Mask. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF or in COLORREF (aabbggrr) 00000000 to FFFFFFFF |
FFFFFFFF (Transparent) |
ClipPoints |
Points that define the clip region. |
Array of Points |
|
NULL |
ClipOps |
Operations that define how the points are connected. |
Array of enum PolyOps |
0: acNoOp 1: acCloseFigure 2: acLineTo 4: acBezierTo 6: acMoveto 16: acClip_Winding 32: acClip_Alternate |
0: acNoOp |
BitsPerColor |
Number of bits per color. |
Integer |
|
0 |
ColorDepth |
Number of possible colors. |
Integer |
|
0 |
LayerID |
ID layer which belongs the object. |
String |
||
Annotation |
Object is saved as an annotation as opposed to a drawing within the page contents |
Boolean |
True / False |
False for static objects such as lines, polygons and text. True for dynamic objects such as form fields or high-lighters |
Rotation |
Object rotation. |
Integer |
10th of a degree |
0 |
ImageFileData |
Byte array of an image file, as it is read from the file system. |
Byte Array |
Supported input formats are: JPEG, BMP, TIFF, GIF, and PNG. |
[] |
Visible |
Object is visible when document is printed |
Boolean |
True / False |
True |
CanActivate |
User can Activate. |
Boolean |
True/False |
True |
XAML |
XAML representation of the object |
String |
||
Opacity |
Object' s image will be rendered in the case of using GDI+ or DirectX with varying range of translucency |
Integer |
1 (most translucent) to 100 (most opaque) |
100 |
BlendMode |
Blends the color object according to a define mode. This blending is also applied to the object when it is saved or printed. |
enum acBlendMode |
0: acBlendModeNormal 1: acBlendModeMultiply 2: acBlendModeScreen 3: acBlendModeOverlay 4 : acBlendModeDarken 5: acBlendModeLighten 6: acBlendModeColorDodge 7: acBlendModeColorBurn 8: acBlendModeHardLight 9: acBlendModeSoftLight 10: acBlendModeDifference 11: acBlendModeExclusion 12 : acBlendModeHue 13: acBlendModeSaturation 14 : acBlendModeColor 15: acBlendModeLuminosity 16: acBlendModeCompatible |
0: acBlendModeNormal |
Creating a picture object from an external file using the FileName attribute.
Sub Sample()
'Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"
Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"
'Initialize library
'This should be done once
Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX()
'set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode)
' Set CurrentPage
pdf.CurrentPage = 1
'Create a Picture in the current Page
pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1")
'Define obj as Picture1
Dim oPic As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Picture1")
'General Attributes
oPic("Left") = 1000
oPic("Right") = 5000
oPic("Top") = 0
oPic("Bottom") = 4000
'Picture Attributes
oPic("BorderColor") = &HFF00FF
oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple
oPic("Filename") = "c:\temp\image.jpg"
'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";
// Initialize library
// This should be done once
ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX();
// set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode);
// Set CurrentPage
pdf.CurrentPage = 1;
// Create a Picture in the current Page
pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1");
// Define obj as Picture1
ACPDFCREACTIVEX.IacObject oPic = pdf.GetObjectByName("Picture1");
// General Attributes
oPic["Left"] = 1000;
oPic["Right"] = 5000;
oPic["Top"] = 0;
oPic["Bottom"] = 4000;
// Picture Attributes
oPic["BorderColor"] = 0xFF00FF;
oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple;
oPic["Filename"] = @"c:\temp\image.jpg";
// 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));
// Set CurrentPage
pdf->CurrentPage = 1;
// Create a Picture in the current Page
pdf->CreateObject(acObjectTypePicture, "Picture1");
// Define obj as Picture1
IacObjectPtr oPic = pdf->GetObjectByName("Picture1");
// General Attributes
oPic->Attribute["Left"] = 1000;
oPic->Attribute["Right"] = 5000;
oPic->Attribute["Top"] = 0;
oPic->Attribute["Bottom"] = 4000;
// Picture Attributes
_variant_t varAttribute;
varAttribute.vt = VT_I4; // integers
varAttribute.lVal = 0xFF00FF;
oPic->Attribute["BorderColor"] = varAttribute;
varAttribute.lVal = acBorderWidthSimple;
oPic->Attribute["BorderWidth"] = varAttribute;
oPic->Attribute["FileName"] = "c:\\temp\\image.jpg";
// Save pdf
pdf->Save("c:\\temp\\CreatePDFDocument_resulting.pdf", acFileSaveView);
// destroy objects
pdf = NULL;
oPic = NULL;
return 0;
}
'acBorderWidth Constants
Const acBorderWidthNone = 0
Const acBorderWidthSimple = 1
Const acBorderWidthDouble = 2
Const acBorderWidthTriple = 3
Const acBorderWidthQuadruple = 4
'ObjectTypeConstants
Const acObjectTypeArrow = 36
Const acObjectTypeBarcode = 45
Const acObjectTypeCell = 33
Const acObjectTypeCheckBox = 21
Const acObjectTypeEllipse = 4
Const acObjectTypeExcel = 17
Const acObjectTypeFrame = 2
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
'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 Picture in the current Page
pdf.CreateObject acObjectTypePicture, "Picture1"
'Define Object
Dim oPic
Set oPic = pdf.GetObjectByName("Picture1")
'General Attributes
oPic("Left") = 1000
oPic("Right") = 5000
oPic("Top") = 0
oPic("Bottom") = 4000
'Field Attributes
oPic("BorderColor") = &HFF00FF
oPic("BorderWidth") = acBorderWidthSimple
oPic("Filename") = "c:\temp\image.jpg"
'Save PDF
pdf.Save "c:\temp\CreatePDFDocument_resulting.pdf", acFileSaveView
'destroy Objects
Set pdf = Nothing
Set oPic = Nothing
Creating a picture object from the data(pixels) of a Bitmap in memory, excluding the headers, using the BitmapData attribute. This attribute does not support compressed images.
Sub Sample()
'Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"
Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"
'Initialize library
'This should be done once
Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX()
'set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode)
'Load an Image
Dim bpc As Integer = 0
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap("c:\temp\image.jpg")
Select Case bmp.PixelFormat
Case System.Drawing.Imaging.PixelFormat.Format32bppArgb
bpc = 32
Case System.Drawing.Imaging.PixelFormat.Format24bppRgb
bpc = 24
Case System.Drawing.Imaging.PixelFormat.Format8bppIndexed
bpc = 24
'This code is needed only for GIF format
Dim bm As System.Drawing.Bitmap = New System.Drawing.Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
''obtain a Graphics object for the new image and draw the old image onto it using DrawImage
Dim gr As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bm)
Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, bm.Width, bm.Height)
gr.DrawImage(bmp, rect, 0, 0, bm.Width, bm.Height, System.Drawing.GraphicsUnit.Pixel)
bmp = bm
Case System.Drawing.Imaging.PixelFormat.Format1bppIndexed
bpc = 1
Case Else
bpc = 8
End Select
'Lock the bitmap’s bits.
Dim rect1 As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height)
Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(rect1, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)
'Declare an array to hold the bytes of the bitmap.
Dim bytes As Integer = bmp.Height * bmpData.Stride
Dim rgbValues(bytes) As Byte
'Copy the RGB values into the array.
For scanLine = bmp.Height - 1 To 0 Step -1
'Get the address of the Nth scanline.
Dim ptr As IntPtr = IntPtr.Add(bmpData.Scan0, scanLine * bmpData.Stride)
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, bmpData.Stride * (bmp.Height - scanLine - 1), bmpData.Stride)
Next
' Set CurrentPage
pdf.CurrentPage = 1
'Create a Picture in the current Page
pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1")
'Define obj as Picture1
Dim oPic As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Picture1")
'General Attributes
oPic("Left") = 1000
oPic("Right") = 1000 + 8500 * bmp.Width / bmp.Height
oPic("Top") = 1000
oPic("Bottom") = 8500
'Picture Attributes
oPic("BorderColor") = &HFF00FF
oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple
oPic("BitsPerComponent") = bpc
oPic("BitmapWidth") = bmp.Width
oPic("BitmapHeight") = bmp.Height
oPic("BitmapData") = rgbValues
'Unlock the bits.
bmp.UnlockBits(bmpData)
'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";
// Initialize library
// This should be done once
ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX();
// set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode);
// Load an Image
int bpc = 0;
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(@"c:\temp\image.jpg");
switch (bmp.PixelFormat)
{
case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
bpc = 32;
break;
case System.Drawing.Imaging.PixelFormat.Format24bppRgb:
bpc = 24;
break;
case System.Drawing.Imaging.PixelFormat.Format8bppIndexed:
bpc = 24;
// This code is needed only for GIF format
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
// obtain a Graphics object for the new image and draw the old image onto it using DrawImage
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bm);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bm.Width, bm.Height);
gr.DrawImage(bmp, rect, 0, 0, bm.Width, bm.Height, System.Drawing.GraphicsUnit.Pixel);
bmp = bm;
break;
case System.Drawing.Imaging.PixelFormat.Format1bppIndexed:
bpc = 1;
break;
default:
bpc = 8;
break;
}
// Lock the bitmap's bits.
System.Drawing.Rectangle rect1 = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect1, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
// Declare an array to hold the bytes of the bitmap.
int bytes = bmp.Height * bmpData.Stride;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array.
for (int scanLine = bmp.Height - 1; scanLine >= 0; scanLine--)
{
// Get the address of the Nth scanline.
IntPtr ptr = IntPtr.Add(bmpData.Scan0, scanLine * bmpData.Stride);
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, bmpData.Stride * (bmp.Height - scanLine - 1), bmpData.Stride);
}
// Set CurrentPage
pdf.CurrentPage = 1;
// Create a Picture in the current Page
pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1");
// Define obj as Picture1
ACPDFCREACTIVEX.IacObject oPic = pdf.GetObjectByName("Picture1");
// General Attributes
oPic["Left"] = 1000;
oPic["Right"] = 1000 + 8500 * bmp.Width / bmp.Height;
oPic["Top"] = 1000;
oPic["Bottom"] = 8500;
// Picture Attributes
oPic["BorderColor"] = 0xFF00FF;
oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple;
oPic["BitsPerComponent"] = bpc;
oPic["BitmapWidth"] = bmp.Width;
oPic["BitmapHeight"] = bmp.Height;
oPic["BitmapData"] = rgbValues;
// Unlock the bits.
bmp.UnlockBits(bmpData);
// Save PDF
pdf.Save(@"c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView);
}
#include <atlimage.h>
#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));
// Load an image
CImage image;
image.Load(_T("c:\\temp\\image.jpg"));
int bpp = image.GetBPP();
int width = image.GetWidth();
int height = image.GetHeight();
const BYTE * bitmapData = (BYTE *)image.GetBits();
int pitch = image.GetPitch();
int bytes = abs(pitch) * height;
SAFEARRAYBOUND Bound;
Bound.lLbound = 0;
Bound.cElements = bytes;
SAFEARRAY * bmpData = SafeArrayCreate(VT_UI1, 1, &Bound);
BYTE * pData = NULL;
HRESULT hrv = SafeArrayAccessData(bmpData, (void **)&pData);
int stride = abs(pitch);
for (int scanLine = height - 1; scanLine >= 0; scanLine--)
{
const BYTE * src = (BYTE *)image.GetPixelAddress(0, scanLine);
memcpy(pData + stride * (height - scanLine - 1), src, stride);
}
SafeArrayUnaccessData(bmpData);
// Set CurrentPage
pdf->CurrentPage = 1;
// Create a Picture in the current Page
pdf->CreateObject(acObjectTypePicture, "Picture1");
// Define obj as Picture1
IacObjectPtr oPic = pdf->GetObjectByName("Picture1");
// General Attributes
oPic->Attribute["Left"] = 1000;
oPic->Attribute["Right"] = 5000;
oPic->Attribute["Top"] = 0;
oPic->Attribute["Bottom"] = 4000;
// Picture Attributes
_variant_t varAttribute;
varAttribute.vt = VT_I4; // integers
varAttribute.lVal = 0xFF00FF;
oPic->Attribute["BorderColor"] = varAttribute;
varAttribute.lVal = acBorderWidthSimple;
oPic->Attribute["BorderWidth"] = varAttribute;
varAttribute.lVal = bpp;
oPic->Attribute["BitsPerComponent"] = varAttribute;
varAttribute.lVal = width;
oPic->Attribute["BitmapWidth"] = varAttribute;
varAttribute.lVal = height;
oPic->Attribute["BitmapHeight"] = varAttribute;
varAttribute.vt = VT_ARRAY | VT_UI1; // A SAFEARRAY pointer and An unsigned character
varAttribute.parray = bmpData;
oPic->Attribute["BitmapData"] = varAttribute;
// Save PDF
pdf->Save("c:\\temp\\CreatePDFDocument_resulting.pdf", acFileSaveView);
// destroy objects
pdf = NULL;
oPic = NULL;
return 0;
}
Creating a picture object from the image data as a byte array using the ImageFileData attribute. This attribute supports compressed images.
Sub Sample()
'Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"
Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"
'Initialize library
'This should be done once
Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX()
'set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode)
'Getting the BitMapData from the Image File
Dim sourceFile As System.IO.FileStream = New System.IO.FileStream("c:\temp\image.jpg", System.IO.FileMode.Open)
Dim binReader As System.IO.BinaryReader = New System.IO.BinaryReader(sourceFile)
Dim imgData As Byte() = binReader.ReadBytes(sourceFile.Length)
sourceFile.Close() 'dispose streamer
binReader.Close() 'dispose reader
' Set CurrentPage
pdf.CurrentPage = 1
'Create a Picture in the current Page
pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1")
'Define obj as Picture1
Dim oPic As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Picture1")
'General Attributes
oPic("Left") = 1000
oPic("Right") = 5000
oPic("Top") = 0
oPic("Bottom") = 4000
'Picture Attributes
oPic("BorderColor") = &HFF00FF
oPic("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple
oPic("ImageFileData") = imgData
'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";
// Initialize library
// This should be done once
ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX();
// set license key
pdf.SetLicenseKey(strLicenseTo, strActivationCode);
// Getting the BitMapData from the Image File
System.IO.FileStream sourceFile = new System.IO.FileStream(@"c:\temp\image.jpg", System.IO.FileMode.Open);
System.IO.BinaryReader binReader = new System.IO.BinaryReader(sourceFile);
Byte[] imgData = binReader.ReadBytes((int)sourceFile.Length);
sourceFile.Close(); // dispose streamer
binReader.Close(); // dispose reader
// Set CurrentPage
pdf.CurrentPage = 1;
// Create a Picture in the current Page
pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypePicture, "Picture1");
// Define obj as Picture1
ACPDFCREACTIVEX.IacObject oPic = pdf.GetObjectByName("Picture1");
// General Attributes
oPic["Left"] = 1000;
oPic["Right"] = 5000;
oPic["Top"] = 0;
oPic["Bottom"] = 4000;
// Picture Attributes
oPic["BorderColor"] = 0xFF00FF;
oPic["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple;
oPic["ImageFileData"] = imgData;
// Save PDF
pdf.Save(@"c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView);
}
#include <iostream>
#include <fstream>
#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));
// Getting the BitMapData from the Image File
int size;
char * memblock;
ifstream file ("c:\\temp\\image.jpg", ios::in|ios::binary|ios::ate);
file.seekg(0, ios::end);
size = file.tellg();
memblock = new char[size];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();
SAFEARRAYBOUND Bound;
Bound.lLbound = 0;
Bound.cElements = size;
SAFEARRAY * imgData = SafeArrayCreate(VT_UI1, 1, &Bound);
BYTE * pData = NULL;
HRESULT hrv = SafeArrayAccessData(imgData, (void **)&pData);
memcpy(pData, memblock, size);
SafeArrayUnaccessData(imgData);
// Set CurrentPage
pdf->CurrentPage = 1;
// Create a Picture in the current Page
pdf->CreateObject(acObjectTypePicture, "Picture1");
// Define obj as Picture1
IacObjectPtr oPic = pdf->GetObjectByName("Picture1");
// General Attributes
oPic->Attribute["Left"] = 1000;
oPic->Attribute["Right"] = 5000;
oPic->Attribute["Top"] = 0;
oPic->Attribute["Bottom"] = 4000;
// Picture Attributes
_variant_t varAttribute;
varAttribute.vt = VT_I4; // integers
varAttribute.lVal = 0xFF00FF;
oPic->Attribute["BorderColor"] = varAttribute;
varAttribute.lVal = acBorderWidthSimple;
oPic->Attribute["BorderWidth"] = varAttribute;
varAttribute.vt = VT_ARRAY | VT_UI1; // A SAFEARRAY pointer and An unsigned character
varAttribute.parray = imgData;
oPic->Attribute["ImageFileData"] = varAttribute;
// Save PDF
pdf->Save("c:\\temp\\CreatePDFDocument_resulting.pdf", acFileSaveView);
delete[] memblock;
// destroy objects
pdf = NULL;
oPic = NULL;
return 0;
}