Attribute VB_Name = "modVeryTest"
Option Explicit
Private Declare Function VeryStampOpen Lib "verywrite.dll" (ByVal sIn As String, ByVal sOut As String) As Long
Private Declare Sub VeryStampClose Lib "verywrite.dll" (ByVal id As Long)
Private Declare Function VeryStampAddRectWithLayer Lib "verywrite.dll" (ByVal id As Long, ByVal start_x As Long, ByVal start_y As Long, ByVal end_x As Long, ByVal end_y As Long, ByVal line_width As Long, ByVal text_color As Long, ByVal flagfill As Long, ByVal fill_color As Long, ByVal layer As Long) As Long
Private Declare Function VeryStampSetFunction Lib "verywrite.dll" (ByVal id As Long, ByVal func_code As Long, ByVal Para1 As Long, ByVal Para2 As Long, ByVal szPara3 As String, ByVal szPara4 As String) As Long
Sub Main()
Debug.Assert False
TestStamp "Test Data\Sample1_v1.6.pdf", 150, 150, 50, 50 ' Returns -1
TestStamp "Test Data\Sample2_v1.6.pdf", 150, 150, 50, 50 ' Returns -1
TestStamp "Test Data\Sample3_v1.5.pdf", 150, 150, 50, 50 ' Returns -1
TestStamp "Test Data\Sample4_v1.5.pdf", 150, 150, 50, 50 ' Returns -1
TestStamp "Test Data\Sample5_v1.7.pdf", 150, 150, 50, 50 ' Returns -3
TestStamp "Test Data\Sample9_v1.6.pdf", 150, 150, 50, 50 ' No errors, but generates invalid output
End Sub
Private Sub TestStamp(Filename As String, ByVal X0 As Long, ByVal Y0 As Long, ByVal X1 As Long, ByVal Y1 As Long)
Dim Processor As Long
Dim Page As Long
Dim ret As Long
Dim ForeColor As Long
Dim BackColor As Long
Dim Outfile As String
Outfile = App.Path & "\" & Filename & ".out.pdf"
FileCopy App.Path & "\" & Filename, Outfile
Processor = VeryStampOpen(Outfile, vbNullString)
If Processor < 1 Then
MsgBox "VeryStampOpen failed with " & Processor & " on file " & Filename
Kill Outfile ' No need to keep the copy since we didn't do anything with it
Exit Sub
End If
Page = 1
ret = VeryStampSetFunction(Processor, 131, Page, 1, vbNullString, vbNullString)
If ret <= 0 Then
MsgBox "VeryStampSetFunction failed with " & ret & " on file " & Filename
GoTo Cleanup
End If
ForeColor = 0
BackColor = 10 '16777215
ret = VeryStampAddRectWithLayer(Processor, X0, Y0, X1, Y1, 1, ForeColor, 1, BackColor, 0)
If ret <= 0 Then
MsgBox "VeryStampAddRectWithLayer failed with " & ret & " on file " & Filename
GoTo Cleanup
End If
Cleanup:
VeryStampClose Processor
End Sub