Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Getting Started with the dll in VB.Net
  FAQ FAQ  Forum Search   Register Register  Login Login

Getting Started with the dll in VB.Net

 Post Reply Post Reply
Author
Message
Dan View Drop Down
Team Player
Team Player
Avatar

Joined: 21 Oct 11
Location: US
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dan Quote  Post ReplyReply Direct Link To This Post Topic: Getting Started with the dll in VB.Net
    Posted: 03 Nov 11 at 3:16PM
Hi,

I'm having trouble getting the dll version 8.12 working in VB.Net. The Getting Started was a little help..

I understand access to the library is done via the file C:\Program Files (x86)\Quick PDF Library\DLL\Import\VB.NET\QuickPDFDLL0812.vb, which I copied into my project App_Code directory.

The guide doesn't say what to do with the dll. I can't reference it through VS's Add Reference dialog. I get this error:
A reference to 'C:\Program Files (x86)\Quick PDF Library\DLL\QuickPDF64DLL0812.dll' could not be added. No type libraries were found in the component.

Also,
Visual Studio can't find the method QuickPDFDLL0812.QuickPDFCreateLibrary() as shown in the example in the Getting Started guide.

The only thing it can find is: QuickPDFDLL0812.PDFLibrary

So I downloaded the VB.Net code sample project here: http://www.quickpdflibrary.com/samples/index.php

First thing I notice is it uses version 7.21. Is there a current example?

Anyways, I unzipped and loaded the project into Visual Studio 2010, letting VS update the project to be used with 2010. Then I updated Form1.vb by updating the LicenseKey and changed the path to the .dll to:
QP = New PDFLibrary("QuickPDFDLL0721.dll")

I also tried leaving it:
QP = New PDFLibrary("../../QuickPDFDLL0721.dll")


Regardless, when I run or debug the project I get an error after clicking the "HelloWorld" button on the form on line 29 of QuickPDFDLL0721.vb:

QuickPDFAddArcToPath = DirectCast(Marshal.GetDelegateForFunctionPointer(GetProcAddress(dllHandle, "QuickPDFAddArcToPath"), GetType(DelegateIIDDD)), DelegateIIDDD)

The error is:
System.ArgumentNullException was unhandled
Message=Value cannot be null.
Parameter name: ptr
ParamName=ptr
Source=mscorlib
StackTrace:
       at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr ptr, Type t)
       at visual_basic_dll_sample.QuickPDFDLL0721.DLL..ctor(String dllFileName) in D:\Projects\Examples\visual-basic_dll_sample\QuickPDFDLL0721.vb:line 29
       at visual_basic_dll_sample.QuickPDFDLL0721.PDFLibrary..ctor(String dllFileName) in D:\Projects\Examples\visual-basic_dll_sample\QuickPDFDLL0721.vb:line 1303
       at visual_basic_dll_sample.Form1.btnHelloWorld_Click(Object sender, EventArgs e) in D:\Projects\Examples\visual-basic_dll_sample\Form1.vb:line 13
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at visual_basic_dll_sample.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Back to Top
Dan View Drop Down
Team Player
Team Player
Avatar

Joined: 21 Oct 11
Location: US
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dan Quote  Post ReplyReply Direct Link To This Post Posted: 03 Nov 11 at 3:22PM
I got a little further using the code sample project as a guide and this post: http://www.quickpdf.org/forum/using-c-and-the-dll-edition-of-quick-pdf-library_topic1110.html

I tried copying the dll into the root of my own test project (and into the Bin folder but not at the same time) and I can't get the library loaded. Here is my code:

Dim QP As PDFLibrary = New PDFLibrary("/Bin/QuickPDF64DLL0812.dll")
Dim Loaded As Boolean = QP.LibraryLoaded()
If Not Loaded Then
     Throw New Exception("Not Loaded")
End If
Dim Result As Int32 = QP.UnlockKey(QuickPDFKey8)
If Result = 1 Then
     QP.SetOrigin(1)
     QP.DrawText(100, 100, "XOIJSDFOJSDIOFJSODJFOISDJ")

     QP.CompressContent()

     Dim bytes As Byte() = QP.SaveToString()

     Response.Clear()
     Response.ContentType = "application/pdf"
     Response.AddHeader("Content-Disposition", "attachment; filename=test.pdf")
     Response.OutputStream.Write(bytes, 0, bytes.Length)
     Response.OutputStream.Flush()
     Response.OutputStream.Close()
     Response.End()
Else
     Throw New Exception("Not Unlocked.")
End If


Where do I put this dll and how do I reference it?

Thanks,
Dan

Edited by Dan - 03 Nov 11 at 7:46PM
Back to Top
darkv View Drop Down
Team Player
Team Player
Avatar

Joined: 17 Jan 11
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote darkv Quote  Post ReplyReply Direct Link To This Post Posted: 04 Nov 11 at 6:59AM
Dan,

The dll could be anywhere, with any name, as soon as you referenced it correctly

Personnaly what i used is :

lpPdfLib = c:\mypath\zlib.dll
myPdf = New PDFLibrary(lpPdfLib)

and it works perfectly..

to test, copy dll in release and debug directories in your project, in your code just call it by its name only w/o path and should work

Good luck

Eric


Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 04 Nov 11 at 7:35AM
Here is my code sample for VB.NET

The DLL needs to be somewhere where the EXE file can find it.  This can be

1. The same directory as the EXE file
2. You can specify where the DLL is Dim QP As PDFLibrary = New PDFLibrary("C:/Bin/QuickPDF64DLL0813.dll")   // can use absolute or relative path.
2. In C:\Windows\System32 for 32 bit verisions of Windows (32bit DLL or 64bit DLL)
3. In C:\Windows\SysWOW64 for 64 bit verisions of Windows (32bit DLL)

Looking at the above code, you are using the 64 bit DLL with VB.NET but your project was probably targetted to compile a 32b bit EXE.  So you may need to go into the Build Menu then Configuration Manager to make sure you are targeting a 64 bit app. If it is 32bits then you need to use 'QuickPDFDLL0813.DLL' - ie the 32 bit version.

I have successfully tested this with both 32 and 64 bit DLL's.

' ------------------------------------------------------------------------------------------------------------------

Imports QPL_VB_NET.QuickPDFDLL0813   // Replace QPL_VB_NET with the name of your APP.

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim QP As PDFLibrary
        Dim LicenseKey
        Dim Result

        ' Update path to DLL if necessary
        ' Check the Project, Configuration Manager

        QP = New PDFLibrary("QuickPDF64DLL0813.dll")  ' use "QuickPDFDLL0813.dll" for 32 bits

        ' Insert your trial or commercial license key here

        LicenseKey = "<put your license key here>"

        Result = QP.UnlockKey(LicenseKey)
        If Result = 1 Then

            ' This function sets the origin
            ' for the co-ordinates used by
            ' the drawing functions.

            QP.SetOrigin(1)

            ' The DrawText function lets you
            ' draw text onto a page.

            QP.DrawText(100, 100, "Hello Visual Basic! This text has been drawn using the DrawText function.")
            QP.DrawHTMLText(100, 125, 400, "<b>Quick PDF Library Version:</b> " + QP.LibraryVersion())
            QP.DrawHTMLText(100, 140, 400, "<b>License Information:</b> " + QP.LicenseInfo())

            ' The DrawBox function lets you
            ' draw rectangular shapes.

            QP.DrawBox(50, 50, 500, 150, 0)

            ' Save the new file to disk.

            If QP.SaveToFile("Hello_World.pdf") = 1 Then
                lblStatus.Text = "Success! Look in the Test Files folder."
            Else
                lblStatus.Text = "Oh no, the file was not saved correctly."
            End If

        Else
            MsgBox("- Invalid license key -")
        End If
        QP = Nothing
    End Sub
End Class

Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 04 Nov 11 at 7:37AM
We made some fixes to the VB.NET import file in 8.13 so you may also have better success with 8.13 beta which can be downloaded from


Andrew.
Back to Top
Dan View Drop Down
Team Player
Team Player
Avatar

Joined: 21 Oct 11
Location: US
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dan Quote  Post ReplyReply Direct Link To This Post Posted: 04 Nov 11 at 1:56PM
Thanks Eric and Andrew!

I don't think I have an .exe because this is a web page. I got it working with an absolute path to the 32bit version:
Dim QP As PDFLibrary = New PDFLibrary("C:/Bin/QuickPDFDLL0812.dll")


"you may also have better success with 8.13 beta"
I tend to shy away from beta releases because they haven't gone through a complete QA process.

But what exactly was wrong with the VB.Net import file? I may have to make an exception..

Thanks,
Dan

Edited by Dan - 17 Nov 11 at 10:05PM
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store