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 - Problem with CloseFile
  FAQ FAQ  Forum Search   Register Register  Login Login

Problem with CloseFile

 Post Reply Post Reply
Author
Message
GeorgeS View Drop Down
Beginner
Beginner


Joined: 04 Jul 17
Location: Germany
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote GeorgeS Quote  Post ReplyReply Direct Link To This Post Topic: Problem with CloseFile
    Posted: 04 Jul 17 at 11:18AM
Hi All,

I do have such a basic problem with CloseFile that I know, I must do something wrong. After trying all possible changes I’m lost and I would try to ask for help.

I use PowerBasic Vers. 10.04, PDF-Library Vers. 13.12


FUNCTION PBMAIN () AS LONG

 

LOCAL oLib                                    AS IDISPATCH

LOCAL hPdf, lResult, lPageCount               AS LONG

LOCAL wLib, wPassword, wPageText, wClsId,     AS WSTRING

 

wLib       = EXE.PATH$ + "DebenuPDFLibraryAX1312.dll"

wClsId     = GUID$("{6393DAEA-334E-4410-9582-5BE46DC383C2}")      'Version 13.12

vUnlockKey = “your key goes here”

 

oLib = NEWCOM CLSID wClsId LIB wLib                               'yes, works

OBJECT CALL oLib.UnlockKey(vUnlockKey) TO lResult                 'yes, works

           

OBJECT CALL oLib.LoadFromFile(wPdfFile, wPassword) TO hPdf ‘yes, works

'…..   Some more functions or even nothing (doesn’t matter!)

'i.e.  OBJECT CALL oLib.PageCount() TO lPageCount                 'yes, works

 

OBJECT CALL oLib.CloseFile(hPdf)  TO lResult                      'NO gives Object Error

OBJECT CALL oLib.ReleaseLibrary() TO lResult                      'ERROR:

'if you don’t do a CloseFile it gives you identical Object Error with ReleaseLibrary

 

END FUNCTION



If I do the same functions with direct library calls (= none ActiveX Functions), I get read or write to invalid address errors on CloseFile.

I tried everything I could think about to declare vars as Variant as DWords as WStringsZ, but the error still remains.

I hope somebody would see what I did wrong.


Cheers,

George


PS: already did send the problem to support, but no reaction since last week



Edited by GeorgeS - 04 Jul 17 at 11:33AM
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 17 at 8:45PM
Hi George,

i think you have to do the "Free" first, before your CloseFile ...
This is how i would do it (Delphi):

   QP := TDebenuPDFLibrary1211.Create;
   try
      QP.LoadFromFile(Edit1.Text, '');

      If ( QP.EncryptionStatus > 0 ) Then
         QP.Decrypt;

//    . . .

      Save_Cursor := Screen.Cursor;
      Screen.Cursor := crHourglass;    { Show hourglass cursor }

//    Some file processing ...

      QP.SaveImageListItemDataToFile(...);

//    . . .

   finally
      Screen.Cursor := Save_Cursor;
      QP.Free;
//    Starting from here with your CloseFile...
   end;

Cheers and welcome here,
Ingo


Cheers,
Ingo

Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jul 17 at 11:39AM
I hate to disagree with Ingo, and I know less than zero about PowerBasic.  But why are you calling a non-existent QPDF function named CloseFile at all?  LoadFromFile returns a 0 or 1 result code, not a handle; and the PDF file is already closed by this function, so no close is needed.  There is no CloseFile or ReleaseLibrary function in QPDF, and this may be why they both return an error.
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jul 17 at 8:38PM
Hi TFrost,

i know that the functions are not from inside QuickPDF ;-)
From my opinion the prob exists cause CloseFile can't get control on the file cause the file is still under control of QuickPDF.
The Free from QuickPDF frees the instance and the file and after this CloseFile should work.
But i think you're right that it's not necessary ;-)

Cheers,
Ingo

Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 13 Jul 17 at 11:30PM
The PowerBasic syntax is unfamiliar to me, but my point was that if olib.LoadFromFile 'works' and olib.PageCount 'works' (because both are QPDF functions) then 'olib' seems to be analogous to what I know as 'qpdf'. Given this fact, olib.CloseFile and olib.ReleaseLibrary are never going to be successful calls (unless 'olib' magically has two meanings at once).  We agree that the functions are not QPDF functions, so how can they be called as methods of 'olib'?
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jul 17 at 9:12AM
Hi :)

it seems to me that you're right ;-)
I didn't see these "olib" - so this syntax from George have to be wrong.
I'm not familiar with PowerBasic but with the knowing we have now i would try CloseFile with "wlib"?
Anyway... i'm pretty sure that George is on the right way now...

Cheers,
Ingo

Back to Top
GeorgeS View Drop Down
Beginner
Beginner


Joined: 04 Jul 17
Location: Germany
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote GeorgeS Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jul 17 at 8:38AM

Thank you for your response and help.

You are right, CloseFile and ReleaseLibrary don't exist in the ActiveX version of the QuickPDF Lib.
In the DLL-version of the library, there exists the ReleaseLibrary function. Within the ActiveX version this function does not exist. As Ingo mentioned releasing the instance is just enough.

CloseFile is only used for the direct access file function and have to be used as oLib.DACloseFile(hPDF) after a DAOpenFile. If I do it this way, everything works fine!

Problem solved.

 

@tfrost

You are right, LoadFile returns a result code. DAOpenFile returns a handle that I can close with DACloseFile.

Just as Info: oLib is a name I used as object name. You can name it “qpdf”, “QuickPDF” or almost anything you like in the line:

qPdf = NEWCOM CLSID wClsId LIB wLib                       

 In the way I have declared the QuickPDF library, I don’t have to register the library. The DLL just has to be in the application directory or within the system search path.

 

Cheers,

George

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