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!
Cannot load ActiveX on start programm |
Post Reply |
Author | |
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
Posted: 16 Aug 13 at 8:06AM |
I made a small program to print a pdf , but on a another pc it is not working ?
The error is Cannot load ActiveX , on start of the programm. What am i doing wrong ? The dll's are set to copy local and are in the same folder. The code is : Public Class Form1 Dim QP As DebenuPDFLibraryAX0915.PDFLibrary Dim ClassName = "DebenuPDFLibraryAX0915.PDFLibrary" Dim LicenseKey = "............" ' Insert your trial or commercial license key here Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' This function prints a document ' Setup general parameters Dim fileName As String = "C:\VTS\Pomp11.pdf" ' Load the document that you want to print into memory Dim docID As Integer = QP.LoadFromFile(fileName, "") ' Set the paramters for the PrintDocument function Dim PrinterName As String = QP.GetDefaultPrinterName() Dim StartPage As Integer = 1 ' Set first page number Dim EndPage As Integer = QP.PageCount() ' Set last page number ' Set the paramters for the PrintOptions function Dim PageScaling As Integer = 0 Dim AutoRotateCenter As Integer = 1 Dim Title As String = fileName ' Assign the options for printing to an int variable Dim Options As Integer = QP.PrintOptions(PageScaling, AutoRotateCenter, Title) ' Print the document with the required paramters and options specified QP.PrintDocument(PrinterName, StartPage, EndPage, Options) QP.PrintDocument(PrinterName, StartPage, EndPage, Options) ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load QP = CreateObject(ClassName) If QP.UnlockKey(LicenseKey) = 0 Then MsgBox("- Invalid license key: Have you included your license key? -") QP = Nothing End If End Sub End Class |
|
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load QP = CreateObject(ClassName) If QP.UnlockKey(LicenseKey) = 0 Then MsgBox("- Invalid license key: Have you included your license key? -") QP = Nothing End If End Sub When i remove this from the code , en push the button to print there is a error with the answer = 1 Do i make the dll active on every new pc with cmd ??????
|
|
Wheeley
Senior Member Joined: 30 Oct 05 Location: United States Status: Offline Points: 146 |
Post Options
Thanks(0)
|
You have to register the ActiveX on every computer you intend to use it on (meaning your program runs on). That's one reason to try using just the plain DLL instead.
Wheeley |
|
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Thanks Wheely for the answer.
But the problem is , i cannot get it to work To activate de DLL libary en print a pdf. Do You have a example how to activate the DLL with my serial nr ?
|
|
Mike_R
Beginner Joined: 17 Aug 13 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
Hi,
The point is you must register an ActiveX on a machine before using it. But you may have issues with it, because it's impossible to write to the registry under usual (non admin) user. I would suggest to either use a DLL form, or virtualize the ActiveX using e.g. boxedapp. Hope this helps. |
|
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
|
On the other pc's i don't have adminstator so ActiveX is not going to work
I can't install anything on the other pc's. But Printing with the Dll is a problem , can't get it to work Problem with activating the DLL , with the trail code ! |
|
Wheeley
Senior Member Joined: 30 Oct 05 Location: United States Status: Offline Points: 146 |
Post Options
Thanks(0)
|
What do you mean by "can't get the printing to work"? What's the return code from the function? What version of QuickPDF are you using?
Wheeley |
|
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Wheeley,
I start again with a new one. Dowloaded the example for DLL from the site. Added the 2 dll file's to the dir and import the DebenuPDFLibraryDLL0915.vb from to the project in vb2010 With add new item , the to the dir imports , vb.net. Ok no more errors . When 1 put the serial nummer in en run the error is : Invalid license key: Have you included your license key? so it returns 0 en the programm start but won't work but this step i can't get it to work Do The code is : Imports visual_basic_dll_sample.DebenuPDFLibraryDLL0915 ' The DebenuPDFLibraryDLL0915.vb import file must be added to the project Public Class Form1 Dim QP As PDFLibrary Dim LicenseKey = "j69ke7sf8uz6f83co7sk68j4y" ' Insert your trial or commercial license key here Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load QP = New PDFLibrary("DebenuPDFLibraryDLL0915.dll") If QP.UnlockKey(LicenseKey) = 0 Then MsgBox("- Invalid license key: Have you included your license key? -") QP = Nothing End If End Sub Private Sub btnDrawText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDrawText.Click ' This function draws text onto a document ' Setup the parameters Dim fileName As String = "..\..\Test Files\drawText.pdf" ' Set origin co-ordinates to top left of page QP.SetOrigin(1) ' Call the DrawText function QP.DrawText(100, 100, "Hello world from Visual Basic .NET and the DLL edition of Quick PDF Library") ' Save the changes to the document on the local disk (in the debug folder) QP.SaveToFile(fileName) ' Open PDF automatically System.Diagnostics.Process.Start(fileName) End Sub Private Sub btnDrawHTMLText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDrawHTMLText.Click ' This function draws text using HTML tags onto a document ' Setup the parameters Dim fileName As String = "..\..\Test Files\drawHTMLText.pdf" ' Create a new document in memory with one blank page Dim docID As Integer = QP.NewDocument() ' Call the DrawHTMLText function and specify the necessary settings. QP.DrawHTMLText(40, 760, 200, "Here is some <b>bold</b>, <i>italic</i> and <u>underlined</u> text") QP.DrawHTMLText(40, 730, 200, "<ul><li>This</li><li>is</li><li>a</li><li>bullet</li><li>list</li></ul>") ' Save the changes to the document on the local disk (in the debug folder) QP.SaveToFile(fileName) ' Remove document from memory QP.RemoveDocument(docID) ' Open PDF automatically System.Diagnostics.Process.Start(fileName) End Sub Private Sub btnGetPageText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetPageText.Click ' This function extracts text from a page in a document ' Setup the parameters Dim fileName As String = "C:\VT\Pomp11.pdf" ' Create a new document in memory with one blank page Dim docID As Integer = QP.NewDocument() ' Load the document that you want to extract text from into memory QP.LoadFromFile(fileName, "") ' Select the page that you want to extract text from (first page in ' a document is always 1) QP.SelectPage(1) ' Specify the variable that the text should be added to and call ' the GetPageText function (with the appropriate option selected) Dim pageText As String = QP.GetPageText(1) ' Display the extracted text in a message box MessageBox.Show(pageText) ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub btnExtractPages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExtractPages.Click ' This function extracts pages from a document ' Setup the parameters Dim fileName As String = "C:\VT\Pomp11.pdf.pdf" Dim StartPage As Integer = 1 Dim PageCount As Integer = 1 Dim OutputFile As String = "C:\VT\Pomp111.pdf" ' Load the document that you want to extract text from into memory Dim docID As Integer = QP.LoadFromFile(fileName, "") ' The ExtractPages requires two paramters. The first paramter ' tells the library where to start extracting pages from and ' the second paramter tells the library how many pages from the ' starting point should be extracted. Dim extractPageSuccess As Integer = QP.ExtractPages(StartPage, PageCount) ' You can find out if the extraction process was successfull by ' checking the returned value of the ExtractPages function. If ' it returns 0 then it means the page(s) could not be extracted, ' other wise it will return a new document ID. If extractPageSuccess = 0 Then MessageBox.Show("Page(s) could not be extracted.") Else MessageBox.Show("Page(s) successfully extracted.") ' First check to see if the extraction process worked ' and if it did, then save the results to a new file. QP.SaveToFile(OutputFile) System.Diagnostics.Process.Start(OutputFile) End If ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub btnPrintDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintDocument.Click ' This function prints a document ' Setup general parameters Dim fileName As String = "C:\VT\Pomp11.pdf.pdf" ' Load the document that you want to print into memory Dim docID As Integer = QP.LoadFromFile(fileName, "") ' Set the paramters for the PrintDocument function Dim PrinterName As String = QP.GetDefaultPrinterName() Dim StartPage As Integer = 1 ' Set first page number Dim EndPage As Integer = QP.PageCount() ' Set last page number ' Set the paramters for the PrintOptions function Dim PageScaling As Integer = 0 Dim AutoRotateCenter As Integer = 0 Dim Title As String = fileName ' Assign the options for printing to an int variable Dim Options As Integer = QP.PrintOptions(PageScaling, AutoRotateCenter, Title) ' Print the document with the required paramters and options specified QP.PrintDocument(PrinterName, StartPage, EndPage, Options) ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub btnGetPrinterNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetPrinterNames.Click ' This function retrieves a list of all the local printers ' Setup general parameters ' Assign all of the printers to a string variable Dim printers As String = QP.GetPrinterNames() ' Display the printer names in a message box MessageBox.Show(printers) End Sub Private Sub btnDARenderPageToString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDARenderPageToVariant.Click ' This function renders a page in a PDF to a variant which can be used ' to display the PDF in a window ' Setup general parameters Dim fileName As String = "C:\VT\Pomp11.pdf" Dim password As String = "" Dim pageNumber As Integer = 1 ' Open the file, get a file handle Dim fileHandle As Integer = QP.DAOpenFile(fileName, password) ' Get a reference to the first page Dim pageReference As Integer = QP.DAFindPage(fileHandle, pageNumber) ' Height and width in points (1/72 inch) Dim pageHeight As Double = QP.DAGetPageHeight(fileHandle, pageReference) Dim pageWidth As Double = QP.DAGetPageWidth(fileHandle, pageReference) ' Work out the smallest DPI needed to fit the entire ' page into the PictureBox Dim horizontalDPI As Integer = Convert.ToInt32((PictureBox1.Width / pageHeight) * 72) Dim verticalDPI As Integer = Convert.ToInt32((PictureBox1.Height / pageHeight) * 72) Dim smallestDPI As Integer If horizontalDPI < verticalDPI Then smallestDPI = horizontalDPI Else smallestDPI = verticalDPI End If ' Render the page to BMP format into the byte array Dim bitmapData = QP.DARenderPageToString(fileHandle, pageReference, 0, smallestDPI) ' Put the byte array into a stream Dim stream As New System.IO.MemoryStream(bitmapData) ' Create a new Image from the stream PictureBox1.Image = Image.FromStream(stream) ' Close the file QP.DACloseFile(fileHandle) End Sub Private Sub btnNewOptionalContentGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewOptionalContentGroup.Click ' This function creates a new Optional Content Group (known as a Layer in Acrobat) ' Setup general parameters Dim OutputFileName As String = "C:\VT\Pomp11.pdf" ' Load the document that you want to print into memory Dim docID As Integer = QP.NewDocument() ' Create the new Optional Content Group and assign it a name Dim OCG1 As Integer = QP.NewOptionalContentGroup("OCG 1") Dim ContentStream As Integer = QP.NewContentStream() QP.SelectContentStream(ContentStream) QP.DrawText(100, 750, "This text belongs to OCG1") QP.SetContentStreamOptional(OCG1) QP.SetOptionalContentGroupVisible(OCG1, 1) ' Save the new OCG to the specified file on the local disk QP.SaveToFile(OutputFileName) ' Remove document from memory QP.RemoveDocument(docID) System.Diagnostics.Process.Start(OutputFileName) End Sub Private Sub btnOptionalContentGroupCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptionalContentGroupCount.Click ' This function counts the number of Optional Content Groups (aka Layers) in a document ' Setup general parameters Dim FileName As String = "C:\VT\Pomp11.pdf" ' Load the document that you want to print into memory ' and assign the Document ID to an int variable Dim docID As Integer = QP.LoadFromFile(FileName, "") ' Select the document using the Document ID QP.SelectDocument(docID) ' Initiate the OptionalContentGroupCount function ' and assign the returned value to an int variable Dim OCGs As Integer = QP.OptionalContentGroupCount() ' Convert the int value to a string Dim CountOCGs As String = Convert.ToString(OCGs) ' Display the number of OCGs from the file in the message box MessageBox.Show(CountOCGs) ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub btnNewOutline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewOutline.Click ' This function creates a new outline (aka bookmark) in a document ' Setup general parameters Dim InputFileName As String = "C:\VT\Pomp11.pdf" Dim OutputFileName As String = "..\..\Test Files\NewOutline.pdf" ' Load the document into memory Dim docID As Integer = QP.LoadFromFile(InputFileName, "") ' Get the page height value for the position paramter in the NewOutline function Dim pageHeight As Double = QP.PageHeight() ' Initiate the NewOutline function and set paramters Dim nOutline As Integer = QP.NewOutline(0, "New Bookmark", 1, pageHeight) ' Check the value returned from the NewOutline function to see ' if it was successful. If nOutline = 0 Then MessageBox.Show("Sorry, the bookmark could not be added.") Else ' Save the new outline to the document. QP.SaveToFile(OutputFileName) System.Diagnostics.Process.Start(OutputFileName) End If ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub btnOutlineCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOutlineCount.Click ' This function counts the number of outlines (aka bookmarks) in a document ' Setup general parameters Dim FileName As String = "C:\VT\Pomp11.pdf" ' Load the document into memory Dim docID As Integer = QP.LoadFromFile(FileName, "") QP.SelectDocument(docID) Dim numberOfOutlines As Integer = QP.OutlineCount() Dim Outlines As String = Convert.ToString(numberOfOutlines) MessageBox.Show(Outlines) ' Remove document from memory QP.RemoveDocument(docID) End Sub Private Sub btnMergeDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMergeDocument.Click ' This function merges two documents together ' Setup general parameters Dim firstDoc As String = "..\..\Test Files\sample1.pdf" Dim secondDoc As String = "..\..\Test Files\sample2.pdf" Dim DestFileName As String = "..\..\Test Files\merged_samples.pdf" ' Load the document into memory QP.LoadFromFile(firstDoc, "") Dim MainDoc As Integer = QP.SelectedDocument() QP.LoadFromFile(secondDoc, "") Dim Append As Integer = QP.SelectedDocument() QP.SelectDocument(MainDoc) QP.MergeDocument(Append) QP.SaveToFile(DestFileName) System.Diagnostics.Process.Start(DestFileName) ' Remove document from memory QP.RemoveDocument(MainDoc) End Sub Private Sub btnMergeFileList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMergeFileList.Click ' This function merges a list of documents together ' Setup general parameters Dim ListName As String = "..\..\Test Files\Sample" Dim firstFile As String = "..\..\Test Files\sample1.pdf" Dim secondFile As String = "..\..\Test Files\sample2.pdf" Dim OutputFile As String = "..\..\Test Files\MergeFileListSample.pdf" ' Add the first file to the file list QP.AddToFileList(ListName, firstFile) ' Add the second file to the file list QP.AddToFileList(ListName, secondFile) ' Merge all files in the file list and output a new file QP.MergeFileList(ListName, OutputFile) System.Diagnostics.Process.Start(OutputFile) End Sub Private Sub btnGetInformation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetInformation.Click ' This function retrieves document information ' Setup general parameters Dim FileName As String = "C:\VT\Pomp11.pdf" ' Load and select document Dim DocumentID As Integer = QP.LoadFromFile(FileName, "") QP.SelectDocument(DocumentID) ' Retrieve information from document Dim PDFversion As String = QP.GetInformation(0) Dim Author As String = QP.GetInformation(1) Dim Title As String = QP.GetInformation(2) ' Display retrieved information Dim infoArray As String() = {PDFversion, Author, Title} For Each info As String In infoArray MessageBox.Show(info) Next End Sub Private Sub btnFindImages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFindImages.Click ' This function counts the number of images in a document ' Setup general parameters Dim FileName As String = "..\..\Test Files\sample3.pdf" ' Load and select document Dim DocumentID As Integer = QP.LoadFromFile(FileName, "") QP.SelectDocument(DocumentID) ' Find all images in selected document Dim images As Integer = QP.FindImages() ' Show number of images found in documents Dim numberOfImages As String = Convert.ToString(images) MessageBox.Show(numberOfImages) ' Remove the document from memory QP.RemoveDocument(DocumentID) End Sub End Class |
|
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
|
When i push print the error is :
System.NullReferenceException was unhandled Object reference not set to an instance of an object on this line Dim docID As Integer = QP.LoadFromFile(fileName, "") I think what it means that the file is not there ??? , but it is there
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
If you're using the ActiveX-version you have to register. For this use regsvr32.exe it's in the system32 and syswow64 as well. If you don't find the registered path/filename in the registry then it won't work. If you're using the dll please keep in mind: 32 bit version into syswow64 / 64 bit version into system32 / or the dll into the app-path where your program works. If you want your app work with 32 bit dll then don't compile your app with option "any cpu" but "x86". If there are still problems: Work in your program with FULL path and filename and try again. Cheers, Ingo Edited by Ingo - 18 Aug 13 at 2:26PM |
|
BASSIES
Beginner Joined: 15 Aug 13 Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Thanks All for the support.
I made a mistake and put the dll in the wrong directory and not in the Bin directory where the Exe is. This answer " the dll into the app-path where your program works" Works great now , thanks.
|
|
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