Print Page | Close Window

LoadFromFile always fails

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=2057
Printed Date: 22 Nov 24 at 5:30PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: LoadFromFile always fails
Posted By: ibeleaf
Subject: LoadFromFile always fails
Date Posted: 28 Nov 11 at 5:11AM
I'm attempting this with the freeware QuickPDF library version 8.12.  All I'm trying do is load an existing PDF, add some text, and save it.  Unfortunately, I cannot open any existing PDF.  The return code is always zero.

The QuickPDF object I'm initiating is good, because I can create a new document from scratch (using QPL.NewDocument), add some text, then save it perfectly.  It's just loading PDFs that won't work it seems.

Here's what I'm doing (in PowerBASIC):

' Variable "QPL" is initiated successfully earlier in the code...

If QPL.LoadFromFile("sample.pdf", "") = 0 Then
    MsgBox "ERROR: File could not be opened."
Else
    ' - add some text
    ' - save edited file
End If

Is this somehow crippled in the freeware version of QuickPDF?



Replies:
Posted By: AndrewC
Date Posted: 28 Nov 11 at 12:27PM
Are you using PowerBasic 9 or 10 ?


Posted By: AndrewC
Date Posted: 28 Nov 11 at 12:49PM
Can you specify the full path to the PDF as the current path may not be set to the location you expect.

If QPL.LoadFromFile("f:\users\fred\downloads\sample.pdf", "") = 0 Then

Andrew.


Posted By: ibeleaf
Date Posted: 28 Nov 11 at 2:38PM
I am using PB 9.05 for this particular project.

As for PDF -- I've tried specifying the full path, but will try again.  I've also tried opening 3 different PDFs now.  The most current one I'm attempting to load is an empty single-page PDF created in LibreOffice Writer (via File -> Export to PDF).  It *should* be a valid PDF.


Posted By: ibeleaf
Date Posted: 29 Nov 11 at 4:14AM
Ok, I've now tried 5 different PDFs (all from different sources), so I don't think it's the PDF file(s) at fault.  I have tried with the full path, and without the full path.  All my PDF viewers/editors can read these 5 PDFs fine too.

I really wish "LastErrorCode" was available in the free version!


Posted By: Ingo
Date Posted: 29 Nov 11 at 7:13AM
Hi!
 
Here you'll find a sample for PowerBasic, too:
http://www.quickpdflibrary.com/samples/index.php - http://www.quickpdflibrary.com/samples/index.php
Perhaps you can adapt the syntax for the free version...
And in case the free version doesn't offer enough for your needs:
Why not use the full test-version (with a testkey) for 30 days for evaluation?
 
Cheers, Ingo


Posted By: AndrewC
Date Posted: 29 Nov 11 at 1:40PM
We will be adding LastErrorCode to the next Lite version.

I will see if I can do some testing tomorrow to see what could be going on.

Andrew.


Posted By: ibeleaf
Date Posted: 30 Nov 11 at 2:02AM
Originally posted by AndrewC AndrewC wrote:

We will be adding LastErrorCode to the next Lite version.

I will see if I can do some testing tomorrow to see what could be going on.

Andrew.


Thanks Andrew, I'd appreciate that!  Good news about adding LastErrorCode too.

Ingo:  I only need to add text to an existing PDF, so the commercial version is overkill at the moment.  I may still install the trial and give that a shot if I cannot get this issue dealt with soon.


Posted By: AndrewC
Date Posted: 30 Nov 11 at 12:59PM
The following C# program is running correctly with the QPL Lite I downloaded from the web page.

1. I installed QPL Lite.
2. CD "\program files (x86)\Quick PDF Library\Lite"
3.  regsvr32 QuickPDFLite0812.dll
4 I started up VS 2010 and here is the code.

5. Add a Reference to the QuickPDFLite812.cs file to your project - It can be found in \Quick PDF Library\Lite\Import\CSharp

LoadFromFile is returning 1 and the save PDF is opening up perfectly.

using System;
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.IO;

using QuickPDFLite0812;

namespace QPL_Lite
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PDFLibrary QP = new PDFLibrary();

            Directory.SetCurrentDirectory("f:\\users\\me\\downloads");

            int ret = QP.LoadFromFile("timeslot.pdf", "");

            QP.SaveToFile("out.pdf");
            System.Diagnostics.Process.Start("out.pdf");

        }
    }
}



Posted By: ibeleaf
Date Posted: 01 Dec 11 at 4:43AM
I've never used C#, but I downloaded and installed Visual C# 2010 Express to give your code a try.

I also unregistered and re-registered QuickPDFLite0812.dll successfully (using an administrative rights command prompt).  Opened up VS 2010 Express, created a new "Windows Forms Application" project, added a button called "button1", and pasted your code verbatim to the code view.  Ran the project, and it stopped with the following error:

The type or namespace name 'QuickPDFLite0812' could not be found (are you missing a using directive or an assembly reference?)

I'm certain QuickPDFLite0812.dll is registered properly, since in PowerBASIC I can create a PDF from scratch fine.  I just can't load one and alter it.


Posted By: AndrewC
Date Posted: 01 Dec 11 at 8:31AM
You need to add the QuickPDFLite812.cs file to the project.

It can be found in  Quick PDF Library\Lite\Import\CSharp - QuickPDFLite812.cs

In Solution Explorer in the right, right click on your project name (top item in the treelist) and then choose, Add, then Existing Item.  It should then compile.


Posted By: AndrewC
Date Posted: 01 Dec 11 at 8:32AM
Can you send us a link to one of your PDF files.  I can check to see if the file is loading correctly on my system.


Posted By: ibeleaf
Date Posted: 01 Dec 11 at 6:37PM
Andrew -- below are links for two different PDFs I've tried:

http://dl.dropbox.com/u/38719496/blank.pdf - http://dl.dropbox.com/u/38719496/blank.pdf
http://dl.dropbox.com/u/38719496/sample.pdf - http://dl.dropbox.com/u/38719496/sample.pdf


Posted By: ibeleaf
Date Posted: 12 Dec 11 at 7:22PM
Guy guys -- just wondering if you had a chance to check into this any further.

In the meantime, is there a different Lite version I can download and try?  The download.com link for version 7.25 on your Freeware page actually goes to version 8.

Thanks!


Posted By: AndrewC
Date Posted: 13 Dec 11 at 6:36AM
The files are loading properly into QPL 8.xx. 

Have you managed to get the C# project running ?

Version 8 was a major change to using Unicode strings internally but we have PowerBasic customers using the v8.xx library without problems.

Have you tried the 30 day trial evaluation version ?  I will see if I can find a link to the 7.25 Lite Version that you can download.

Andrew.


Posted By: ibeleaf
Date Posted: 13 Dec 11 at 12:49PM
Sorry, I completely forgot to follow up on the C# test.  I just tried again... and it worked!

This must be a PowerBASIC issue then...  let me check that code again and see if anything stands out.


Posted By: ibeleaf
Date Posted: 14 Dec 11 at 2:27PM
I'm still trying a few tests here, but nothing successful yet.

Not sure if this helps -- but here's a link to the PowerBASIC include file I generated (using QuickPDFLite0812.dll):

http://dl.dropbox.com/u/38719496/QuickPDFLite0812.inc - http://dl.dropbox.com/u/38719496/QuickPDFLite0812.inc



Posted By: ibeleaf
Date Posted: 14 Dec 11 at 3:00PM
Stop the presses..... success!!!

I went back and read over this entire thread, and noticed you mentioned unicode was introduced in version 8.  I neglected to recall that in PowerBASIC, you need to explicitly use the UCODE$ function on a string in order to pass it as unicode.  So I passed the filename argument to LoadFromFile() using UCODE$, and it worked!!

I'm going to do some more tests, but it's looking good.  I'll report back shortly with final confirmation...


Posted By: ibeleaf
Date Posted: 14 Dec 11 at 5:34PM
Well I have confirmed it was a missing UCODE$ call.  Thanks for the attention guys, definitely appreciated!

As a reference, for those of you using PowerBASIC -- be sure to UCODE$ the filename argument when passing it to LoadFromFile()!


Posted By: AndrewC
Date Posted: 15 Dec 11 at 2:45AM
Just to confirm  -  was it the UCODE$ or the UCASE$ function that fixed the problem or does it require both functions.

Andrew.


Posted By: ibeleaf
Date Posted: 15 Dec 11 at 4:34AM
Whoops, sorry -- UCODE$ is the solution.  I've corrected my earlier post to reflect this.

Thanks again guys!



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