Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: I want to draw a signature anywhere on an Acrobat document...
Conf: (P-PDF) Developers, Msg: 96233
From: BillyT2003
Date: 9/11/2003 05:10 AM

Here is the deal:

I have an ePadInk device to all people to sign their signature. I also have a VB application that draws the signature in a VB picture box as I'm signing the device.

Everything is set to work in pixels and not twips.

When the user invokes my application called Signature Stamper, the user will put the stamper window over the Adobe window he wants to stamp.

When the user is done signing the ePad device and hits the button on my user interface:

+ I get the rectangle for the picture box of the stamper window.

+ I hide the Stamper window and use the Win32 API WindowFromPoint function to get the window handle of the window behind me, which I then set as the foreground window.

+ If the window class name of the window handle of the window behind me is not 'AVL_AVView', then I issue a typical "I'm sorry, but you cannot stamp a signature on this window." type message.

+ If the window class name is 'AVL_AVView', then I know that it is the Adobe Window that I want to draw on.

+ I then attempt to draw on the Adobe window as I toggle the pencil tool on and off appropriately using the Acrobat SDK and attempt to draw the signature through using calls to the Windows API PostMessage function with the appropriate WM_LBUTTONDOWN, and WM_LBUTTONUP messages.

+ The signature is drawn correctly, using this method, except that it looks like it's in 3D. As it does not just plot each point as I'm telling it to, but it plots each point as a vertical line.

Where am I going wrong with this? It seems like this should be a simple exercize, but it is turning into an exercize in futility. ;)

I will a copy of the stamp function that does most of the work at the end of this post. Any input on this problem is greatly appreciated. ;)

Best Regards,
Bill Tello

Private Sub x_StampIt(ppctSourceWindowPictureBox As PictureBox)
Dim saSourceWindowPictureBoxBitmapArray() As String
Dim udtSourceWindowRect As RECT
Dim sWindowBehindMeClassName As String
Dim lPackedXY As Long
Dim lSourceWindowColorValue As Long
Dim lSourceWindowPictureBoxHeight As Long
Dim lSourceWindowPictureBoxWidth As Long
Dim lWindowBehindMeHandle As Long
Dim lWindowBehindMeParentApplicationHandle As Long
Dim lXIndex As Long
Dim lYIndex As Long

' get the stamp tool picturebox rectangle
win32api_GetWindowRect ppctSourceWindowPictureBox.hwnd, udtSourceWindowRect

With udtSourceWindowRect
.Right = .Right - 5
.Bottom = .Bottom - 5
lSourceWindowPictureBoxHeight = (.Bottom - .Top)
lSourceWindowPictureBoxWidth = (.Right - .Left)
End With

' scan the stamp tool picturebox to an array
Screen.MousePointer = vbCrosshair
Me.Caption = "SYSTOC Stamp Tool - Scanning Signature"

With udtSourceWindowRect
ReDim saSourceWindowPictureBoxBitmapArray(0 To lSourceWindowPictureBoxHeight) As String

For lYIndex = 0 To lSourceWindowPictureBoxHeight
saSourceWindowPictureBoxBitmapArray(lYIndex) = ""

For lXIndex = 0 To lSourceWindowPictureBoxWidth
lSourceWindowColorValue = win32api_GetPixel(ppctSourceWindowPictureBox.hdc, lXIndex, lYIndex)

Select Case lSourceWindowColorValue
Case vbWhite:
saSourceWindowPictureBoxBitmapArray(lYIndex) = saSourceWindowPictureBoxBitmapArray(lYIndex) & "0"
Case Else
saSourceWindowPictureBoxBitmapArray(lYIndex) = saSourceWindowPictureBoxBitmapArray(lYIndex) & "1"
End Select
End With

Me.Caption = "SYSTOC Stamp Tool"
Screen.MousePointer = vbHourglass

' hide the stamp tool

' now that the stamp tool is out of the way, get the window handle of the window behind it
With udtSourceWindowRect
lWindowBehindMeHandle = win32api_WindowFromPoint(.Left, .Top)
End With

' ensure that it is an Adobe Acrobat window
sWindowBehindMeClassName = x_ClassName(lWindowBehindMeHandle)

If (Len(sWindowBehindMeClassName) = 0) Then
MsgBox "You cannot stamp a signature here.", vbInformation Or vbOKOnly, "Information"
Exit Sub
If (InStr(1, mcsClassnameAdobeAcrobatCanvas, sWindowBehindMeClassName) <= 0) Then
MsgBox "You cannot stamp a signature here.", vbInformation Or vbOKOnly, "Information"
Exit Sub
End If
End If

' get the application window handle of the window behind me
lWindowBehindMeParentApplicationHandle = lWindowBehindMeHandle

If (win32api_GetParent(lWindowBehindMeParentApplicationHandle) <> 0) Then
lWindowBehindMeParentApplicationHandle = win32api_GetParent(lWindowBehindMeParentApplicationHandle)

Do While (lWindowBehindMeParentApplicationHandle <> 0)
If (win32api_GetParent(lWindowBehindMeParentApplicationHandle) = 0) Then
Exit Do
lWindowBehindMeParentApplicationHandle = win32api_GetParent(lWindowBehindMeParentApplicationHandle)
End If
End If

' activate the application window of the window behind me
win32api_SetForegroundWindow lWindowBehindMeHandle

' draw the signature on the window behind me
win32api_SetCapture lWindowBehindMeHandle

With udtSourceWindowRect
win32api_SetCursorPos .Left, .Top

For lYIndex = .Top To .Bottom
For lXIndex = .Left To .Right
If (Val(Mid$(saSourceWindowPictureBoxBitmapArray(lYIndex - .Top), (lXIndex - .Left) + 1, 1)) = 1) Then
win32api_SetCursorPos lXIndex, lYIndex
lPackedXY = (lYIndex * &H10000) + lXIndex
moAcrobatCAcroApp.SetActiveTool "Ink", 0
win32api_PostMessage lWindowBehindMeHandle, WM_LBUTTONDOWN, MK_LBUTTON, lPackedXY
win32api_Sleep 100
win32api_PostMessage lWindowBehindMeHandle, WM_LBUTTONUP, 0, lPackedXY
moAcrobatCAcroApp.SetActiveTool "EraseInk", 0
End If
End With

moAcrobatCAcroApp.SetActiveTool "EraseInk", 1

' re-display the stamp tool
End Sub

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.