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!
Using C# and the DLL edition of Quick PDF Library |
Post Reply |
Author | |
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(0)
Posted: 15 Jun 09 at 10:27AM |
This is a short demo of how to use the DLL edition of Quick PDF Library with C#. // Add the namespaces (first you'll need to. You will need to add a reference to the // C# import file for the DLL edition. using System.IO; using QuickPDFDLL0714; // Put a button onto the form and add this code to the Click event: private void button1_Click(object sender, EventArgs e) { // Create an instance of the class and give it the path to the DLL PDFLibrary qp = new PDFLibrary("...path where the DLL is stored... \\QuickPDFDLL0714.dll"); // Check if the DLL was loaded successfully if (qp.LibraryLoaded()) { // Check the license key if (qp.UnlockKey(" ...license key here... ") == 1) { // Draw some text on the PDF qp.DrawText(100, 500, "Hello world from C#"); // Save the new document to disk qp.SaveToFile("c:\\HelloCSharpDLLWorldWorld.pdf"); } } }
|
|
vijayan
Beginner Joined: 27 Oct 09 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
Hi,
In the example, it says to add a reference to the DLL; however, within Visual Studio 2008 when I do this, I get the error:
"A reference to 'C:\Program Files\Quick PDF Library\DLl\QuickPDFDLL0716.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
How do I get around this?
Even so, in the example the path to the DLL seems to be required:
PDFLibrary qp = new PDFLibrary("...path where the DLL is stored... \\QuickPDFDLL0714.dll");
Is it possible to get a PDFLibrary instance without knowing the path to the DLL? (Assuming of course it is present in the BIN directory of the Windows or ASP.NET application, as normal with other DLL components.)
Thanks,
/vijayan
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
It's possible to use a normal dll with C#, too... But perhaps it's better if you try the activeX-version of the dll (don't forget the wrapper-file!). The other thing: It's okay putting the dll into the system32-directory or into your app-directory and then it's not necessary to know the complete file-path. It's not possible to register the dll 'cause there's no entry-point (that's normal for many dlls out there). Cheers, Ingo Here's the basically content of a form1.cs (from C# 3.5). A "normal" dll was used... using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Text.RegularExpressions; using System.Runtime.InteropServices; namespace H_PDFtext { public partial class Form1 : Form { [DllImport(@"your_dll.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "your_functionname")] public static extern UInt32 your_functionname(your_parameter_type your_parameter); [DllImport(@"your_dll.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "your_next_functionname")] public static extern IntPtr your_next_functionname(your_parameter_type your_parameter, ...); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { nothing = 0; } private void button1_Click(object sender, EventArgs e) { // . . . textBox1.Text = Marshal.PtrToStringAnsi(your_next_functionname(your_parameter, ...)); } private void button2_Click(object sender, EventArgs e) { // . . . } private void button3_Click(object sender, EventArgs e) { textBox1.Text = Convert.ToString(your_functionname(your_parameter)); } } } Edited by Ingo - 27 Oct 09 at 8:46PM |
|
mkinsel
Beginner Joined: 18 Nov 09 Location: Washington St. Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Can you use the same approach with VB 2005? Can you show me a Visual Basic example?
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store