Print Page | Close Window

MS Access(vb6) & DLL Version

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3804
Printed Date: 02 May 24 at 12:03PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: MS Access(vb6) & DLL Version
Posted By: Howard
Subject: MS Access(vb6) & DLL Version
Date Posted: 16 Apr 20 at 1:37PM
I need to fill PDF form (SetFormFieldValueByTitle) from MS Access without any additional installation or library registration on the client. It should be possible with DLL version, but I didn't find any tutorial/sample for the DLL & MS Access or vb6.
There is header file for vb6 in Trial Version (DebenuPDFLibraryDLL1312.bas), which should work for MS Access too. How to initiate the PDF Library?
I found a lot of info about QPF, but need to test the described functionality before buying the full version. Any DLL & Access/vb6 sample will be welcome (found only vb.net in faq).

Thanks in advance!



Replies:
Posted By: Ingo
Date Posted: 16 Apr 20 at 3:05PM
Hi Howard,

please have a look into the vb-sample below.
The heaviest thing is the string handling with unicode.
Please have a detailed look into pointers as well.
Important at least where the dll should be (you'll know the difference with paths in win32 and win64).
If you want to use the dll with vba inside MS Access, Excel, … then the dll has to be in the system32- or syswow64-directory (application directory won’t work).
Choosing the dll inside for example a mdb-project via extras -> references won't work 'cause the dll can't be registered without an entry point – so simply copying into system32 or syswow64 … that’s all.

Cheers and welcome here,
Ingo

- - -

my vb-sample - the module1.bas-file...

Attribute VB_Name = "Module1"
Public Declare Function GetPDFfunction1 Lib "QuickPDF.dll" (ByVal Filename As String) As Long
Public Declare Function GetPDFfunction2 Lib "QuickPDF.dll" (ByVal Filename As String, ByVal Opt As Long, ByVal sepa As String, ByVal fipa As Long) As Long
Public Declare Function GetPDFfunction3 Lib "QuickPDF.dll" (ByVal Filename As String, ByVal FieldName As String) As Long

Public Declare Function apiLStrCopyW Lib "kernel32.dll" Alias "lstrcpyW" (ByVal lpString1 As Long, ByVal lpString2 As Long) As Long
Public Declare Function apiLStrLenW Lib "kernel32.dll" Alias "lstrlenW" (ByVal lpString As Long) As Long

Public Function GetStringFromPtrW(ByVal ptr As Long) As String
  'create a matching buffer
  GetStringFromPtrW = String$(apiLStrLenW(ptr), 0)
  'copying the string into the buffer
  apiLStrCopyW StrPtr(GetStringFromPtrW), ptr
End Function

now the relevant functions out of my form1.frm-file...

Private Sub Command1_Click()
    Dim bPfad() As Byte
    Dim sepa() As Byte
    bPfad = StrConv(Text1.Text, vbUnicode)
    sepa = StrConv(";", vbUnicode)
    Text2.Text = GetStringFromPtrW(GetPDFfunction2(bPfad, 2, sepa, 1))
End Sub

Private Sub Command2_Click()
    Dim bPfad() As Byte
    Dim sepa() As Byte
    bPfad = StrConv(Text1.Text, vbUnicode)
    sepa = StrConv(";", vbUnicode)
    Text2.Text = GetStringFromPtrW(GetPDFfunction2(bPfad, 1, sepa, 1))
End Sub

Private Sub Command3_Click()
    Dim bPfad() As Byte
    Dim bfield() As Byte
    bPfad = StrConv(Text1.Text, vbUnicode)
    bfield = StrConv(Text3.Text, vbUnicode)
    Text2.Text = GetStringFromPtrW(GetPDFfunction3(bPfad, bfield)) 'Get...
End Sub

Private Sub option1_Click()
    Dim bPfad() As Byte
    Dim sepa() As Byte
    bPfad = StrConv(Text1.Text, vbUnicode)
    sepa = StrConv(";", vbUnicode)
'   very long string contents will not be supported in a proper way by common edit controls...   
    If Len(GetStringFromPtrW(GetPDFfunction2(bPfad, 3, sepa, 1))) > 2000 Then
      Text2.Text = Left(GetStringFromPtrW(GetPDFfunction2(bPfad, 3, sepa, 1)), 2000) & "...!!!...aborted because not senseful for a single edit-field...!!!"
    Else
      Text2.Text = GetStringFromPtrW(GetPDFfunction2(bPfad, 3, sepa, 1))
    End If
End Sub

Private Sub option2_Click()
    Dim bPfad() As Byte
    bPfad = StrConv(Text1.Text, vbUnicode)
    Text2.Text = GetPDFfunction1(bPfad)
End Sub




-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk