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!
![]() |
Problem with CloseFile |
Post Reply ![]() |
Author | |
GeorgeS ![]() Beginner ![]() Joined: 04 Jul 17 Location: Germany Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
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'?
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
GeorgeS ![]() Beginner ![]() Joined: 04 Jul 17 Location: Germany Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
Thank you
for your response and help. 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 |
|
![]() |
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