Hi,
I downloaded your demo to use the PDFStamp.dll for a vb.net project I'm working on.
For a couple weeks everything seemed to work great and I could stamp drawings, however, for some reason it quit working and I'm not sure why.
So I tried re-writing the app but now when I try to add reference of PDFStamp.dll, I get error:
"A reference to PDFStamp.dll could not be added, please make sure file
is accessible and that its a valid assembly or COM component"
It was working fine for a couple weeks but now it fails.
This is an unregistered PDFStamp, does it have some type of expiration?
Does it need to be registered to work again?
Please help!
Thanks,
Customer
-----------------------------------------------------------
PDFStamp.dll is a 32bit DLL Library, you can't add a reference to it, you need call it from your code directly, for example,
Module Module1
Private Declare Function veryOpen Lib "PdfStamp.dll" (ByVal sIn As String, ByVal sOut As String) As Integer
Private Declare Sub veryClose Lib "PdfStamp.dll" (ByVal id As Integer)
Private Declare Function veryAddText Lib "PdfStamp.dll" (ByVal id As Integer, ByVal position As Integer, ByVal sstring As String, _
ByVal color As Integer, ByVal alignment As Integer, ByVal shift_lr As Integer, ByVal shift_tb As Integer, ByVal rotate As Integer, _
ByVal layer As Integer, ByVal hollow As Integer, ByVal fontcode As Integer, ByVal fontname As String, ByVal fontsize As Integer, _
ByVal action As Integer, ByVal link As String, ByVal pageno As Integer) As Integer
Private Declare Function veryAddImage Lib "PdfStamp.dll" (ByVal id As Integer, ByVal position As Integer,_
ByVal filename As String, ByVal shift_lr As Integer, ByVal shift_tb As Integer, ByVal rotate As Integer, _
ByVal layer As Integer, ByVal zoomW As Integer, ByVal zoomH As Integer, ByVal action As Integer, ByVal link As String, _
ByVal pageno As Integer) As Integer
Friend Sub execWatermarkPDF(ByRef strPDFFileName As String)
Dim lngDraftPDFFileid As Integer
Dim lngDraftPDFCodeId As Integer
Try
lngDraftPDFFileid = veryOpen(strPDFFileName, strPDFFileName)
If (lngDraftPDFFileid > 0) Then
lngDraftPDFCodeId = veryAddText(lngDraftPDFFileid, 9, "DRAFT Copy", RGB(200, 200, 200), 18, 0, -10, 45, 1, 1, 200, "Courier", 60, 0, "None", 0)
lngDraftPDFCodeId = veryAddImage(lngDraftPDFFileid, 0, "C:\test.jpg", 0, 0, 0, 1, 49, 49, 0, 0, 0)
veryClose(lngDraftPDFFileid)
messagebox.Show("Completed!")
End If
Catch exGeneral As Exception
messagebox.Show(exGeneral.Message & environment.NewLine & exGeneral.StackTrace)
End Try
End Sub
End Module
If you wish call a COM component from VB.NET code, you may use PDFStampCom.exe instead of PDFStamp.dll library, PDFStampCom.exe is a COM interface based on PDFStamp.dll, PDFStampCom.exe can be called from both 32bit and 64bit applications,
Public Class Form1
Const Very_Set_Range = 131
Const Very_Set_Opacity = 240
Const Very_Get_Opacity = 240
Const Very_Get_PdfPageCount = 206
Const Very_Get_PageBoxForStamp = 260
Const Very_Set_EmbedFont = 241
Const Very_Get_EmbedFont = 241
Const Very_Set_TransparentColor = 242
Const Very_Set_ImageLossless = 243
Const Very_Set_InsertMultipleImageCopy = 244
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFolder As String
Dim iRet As Integer
strFolder = Application.StartupPath()
Dim strPDFFile As String = strFolder & "\example.pdf"
Dim strOutFile As String = strFolder & "\vbcom-test.pdf"
Dim pdfstamp As Object = CreateObject("PDFStampCOM.CPDFStamp")
pdfstamp.veryRegEx("XXXXXXXXXXXXXX")
Dim id As Integer = pdfstamp.veryOpenEx(strPDFFile, strOutFile)
'id = pdfstamp.VeryStampLayerOpenEx(strPDFFile, strOutFile, "PDFManWatermark_Overlayer", "PDFManWatermark_Underlayer")
If (id > 0) Then
Dim Page As Integer = 1
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_InsertMultipleImageCopy, 1, 0, 0, 0)
Dim pagecount As Integer = pdfstamp.veryGetFunctionEx(id, Very_Get_PdfPageCount, 0, 0, 0, 0)
MsgBox("PDF file: " & strPDFFile & ", Page Count = " & CStr(pagecount))
For Page = 1 To pagecount
Dim leftpos As Integer = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp, Page, 0, "left", 0)
Dim Top As Integer = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp, Page, 0, "top", 0)
Dim pagewidth As Integer = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp, Page, 0, "width", 0)
Dim pageheight As Integer = pdfstamp.veryGetFunctionEx(id, Very_Get_PageBoxForStamp, Page, 0, "height", 0)
'We need to control which pages the stamp goes on
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_Range, Page, 1, 0, 0)
Dim strStampBuf As String = "Page:" + CStr(pagecount - Page + 1) + ", Page Box: [" + CStr(leftpos) + " " + CStr(Top) + " " + CStr(pagewidth) + " " + CStr(pageheight) + "]"
'Not embed TTF font for general text stamp
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_EmbedFont, 0, 0, 0, 0)
iRet = pdfstamp.veryAddTextEx(id, 2, strStampBuf, 255, 0, 0, 0, 0, 0, 0, 300, 0, 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, 0, 0)
iRet = pdfstamp.veryAddTextEx(id, 1, "0123456789", RGB(0, 0, 0), 0, 0, 0, 0, 0, 0, 0, "Code-39-20", 8, 1, "https://www.verypdf.com/", 0)
iRet = pdfstamp.verySetFunctionEx(id, Very_Set_ImageLossless, 1, 0, 0, 0)
iRet = pdfstamp.veryAddImageEx(id, 9, strFolder & "\watermark.gif", 0, 0, 0, 0, 50, 50, 0, 0, 0)
Next
pdfstamp.veryCloseEx(id)
End If
iRet = pdfstamp.VeryStampDeleteStampFromPagesEx(strOutFile, strOutFile + "-StampRemoval.pdf", "1,5-6,8,13-15")
iRet = pdfstamp.VeryStampDeleteImagesFromPagesEx(strOutFile, strOutFile + "-ImageRemoval.pdf", 1240, 1240, "1,5-6,8,13-15")
Dim nIsStamped1 As Integer = pdfstamp.VeryStampIsStampedEx(strPDFFile)
Dim nIsStamped2 As Integer = pdfstamp.VeryStampIsStampedEx(strOutFile)
Dim strMessage As String = strPDFFile & ", Check Stamp Status: " & CStr(nIsStamped1) & vbCrLf
strMessage = strMessage & strOutFile & ", Check Stamp Status: " & CStr(nIsStamped2)
MsgBox(strMessage)
strOutFile = strFolder & "\vbcom-newLayer-test.pdf"
id = pdfstamp.VeryStampLayerOpenEx(strPDFFile, strOutFile, "Foreground Layer", "Background Layer")
If (id > 0) Then
iRet = pdfstamp.veryAddTextEx(id, 2, "Test VeryStampLayerOpen() function", 255, 0, 0, 0, 0, 0, 0, 300, 0, 10, 1, "https://www.verypdf.com", 0)
pdfstamp.veryCloseEx(id)
End If
strOutFile = strFolder & "\vbcom-Encrypted-test.pdf"
iRet = pdfstamp.VeryStampEncryptPDFEx(strPDFFile, strOutFile, "", "123", 1, 3900)
End Sub
End Class
Please refer to more information about PDFStampCom.exe from following web pages,
https://www.verypdf.com/wordpress/201106/pdf-stamp-com-sdk-3-2-doesnt-work-on-win2k8-64bit-287.html
https://www.verypdf.com/wordpress/201310/how-can-i-call-pdfstampcom-from-c-code-39006.html
https://www.verypdf.com/wordpress/201107/use-pdfstamp-dll-on-windows-2008-64-bit-system-1553.html