Print Page | Close Window

Problem with CloseFile

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=3482
Printed Date: 29 Apr 24 at 8:20PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Problem with CloseFile
Posted By: GeorgeS
Subject: Problem with CloseFile
Date 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




Replies:
Posted By: Ingo
Date 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



Posted By: tfrost
Date 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.


Posted By: Ingo
Date 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



Posted By: tfrost
Date 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'?


Posted By: Ingo
Date 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



Posted By: GeorgeS
Date 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




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