Thanks for the SDK link, however the example files are not working. Please see the attached document.
When I call PDFStamp SDK from C# code, I'm get following error message,
Argument Null Exception was unhandled.
The following is the source code for PDFStamp SDK product,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PDFStampCom;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int Very_Set_Range = 131;
int Very_Set_Opacity = 240;
int Very_Get_Opacity = 240;
int Very_Get_PdfPageCount = 206;
int Very_Get_PageBoxForStamp = 260;
int Very_Set_EmbedFont = 241;
int Very_Get_EmbedFont = 241;
int Very_Set_TransparentColor = 242;
private void PDFStamp_Click(object sender, EventArgs e)
{
string strPDFFile;
string strOutFile;
int id;
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
strPDFFile = appPath + "\\example.pdf";
strOutFile = appPath + "\\C#-com-test.pdf";
System.Type pdfstampType = System.Type.GetTypeFromProgID
("PDFStampCom.CPDFStamp");
PDFStampCom.CPDFStamp pdfstamp = (PDFStampCom.CPDFStamp)
System.Activator.CreateInstance(pdfstampType);
//id = pdfstamp.veryOpenEx(strPDFFile, strOutFile);
id = pdfstamp.VeryStampLayerOpenEx(strPDFFile, strOutFile,
"PDFManWatermark_Overlayer", "PDFManWatermark_Underlayer");
if (id > 0)
{
int pagecount = pdfstamp.veryGetFunctionEx(id, Very_Get_PdfPageCount,
0, 0, null, null);
for (int Page = 1; Page <= pagecount; Page++)
{
string strStampBuf;
long left, top, pagewidth, pageheight;
left = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "left", null);
top = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "top", null);
pagewidth = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "width", null);
pageheight = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "height", null);
//We need to control which pages the stamp goes on
int iRet = pdfstamp.verySetFunctionEx(id, Very_Set_Range, Page,
1, null, null);
strStampBuf = "Page:" + (pagecount - Page + 1).ToString() +
", Page Box: [" + left.ToString() + " " + top.ToString() + " "
+ pagewidth.ToString() + " " + pageheight.ToString() + "]";
//*'*/Not embed TTF font for general text stamp
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_EmbedFont, 0, 0,
null, null);
iRet = pdfstamp.veryAddTextEx(id, 2, strStampBuf, 255, 0, 0, 0, 0,
0, 0, 300, null, 10, 1, "https://www.verypdf.com", 0);
//*'*/Embed special TTF font into PDF file, we can to use any TTF font
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_EmbedFont, 1, 0,
null, null);
iRet = pdfstamp.veryAddTextEx(id, 1, "0123456789", 0, 0, 0, 0, 0,
0, 0, 0, "Code-39-20", 8, 1, "https://www.verypdf.com/", 0);
}
pdfstamp.veryCloseEx(id);
pdfstamp.VeryStampEncryptPDFEx(strOutFile, strOutFile + "-encrypted.pdf",
null, "123", 2, 3900);
}
}
private void button1_Click(object sender, EventArgs e)
{
string strPDFFile;
string strOutFile;
int id;
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
strPDFFile = appPath + "\\example.pdf";
strOutFile = appPath + "\\C#-com-barcode.pdf";
System.Type pdfstampType = System.Type.GetTypeFromProgID
("PDFStampCom.CPDFStamp");
PDFStampCom.CPDFStamp pdfstamp = (PDFStampCom.CPDFStamp)
System.Activator.CreateInstance(pdfstampType);
id = pdfstamp.veryOpenEx(strPDFFile, strOutFile);
if (id > 0)
{
int pagecount = pdfstamp.veryGetFunctionEx(id, Very_Get_PdfPageCount, 0,
0, null, null);
for (int Page = 1; Page <= pagecount; Page++)
{
string strStampBuf;
long left, top, pagewidth, pageheight;
left = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "left", null);
top = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp, Page,
0, "top", null);
pagewidth = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "width", null);
pageheight = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp,
Page, 0, "height", null);
//We need to control which pages the stamp goes on
int iRet = pdfstamp.verySetFunctionEx(id, Very_Set_Range, Page,
1, null, null);
strStampBuf = "Page:" + (pagecount - Page + 1).ToString() +
", Page Box: [" + left.ToString() + " " + top.ToString() + " "
+ pagewidth.ToString() + " " + pageheight.ToString() + "]";
//*'*/Not embed TTF font for general text stamp
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_EmbedFont, 0, 0,
null, null);
iRet = pdfstamp.veryAddTextEx(id, 2, strStampBuf, 255, 0, 0, 0, 0,
0, 0, 300, null, 10, 1, "https://www.verypdf.com", 0);
//*'*/Embed special TTF font into PDF file, we can to use any TTF font
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_EmbedFont, 1, 0,
null, null);
string strFontName = "Free 3 of 9";
iRet = pdfstamp.veryAddTextEx(id, 1, "0123456789", 0, 0, 0, 0, 0,
0, 0, 0, strFontName, 8, 1, "https://www.verypdf.com/", 0);
}
pdfstamp.veryCloseEx(id);
}
}
}
}
Customer
-------------------------------------
Have you already registered the "PDFStampCom.exe" COM component? if not, you can run "bin/install_for_x64.bat" to register PDFStampCom.exe first, you need run it with administrator right, you can also run following command line to register it by manual,
PDFStampCom.exe /regserver
after you registered the "PDFStampCom.exe" COM component into your system, you can call it from your C# code without any restrictions.
Please refer to following web pages for more information,
https://www.verypdf.com/wordpress/201106/pdf-stamp-com-sdk-3-2-doesnt-work-on-win2k8-64bit-287.html
https://www.verypdf.com/wordpress/201107/use-pdfstamp-dll-on-windows-2008-64-bit-system-1553.html