Print Page | Close Window

PDF from SQLite

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=3909
Printed Date: 18 Apr 24 at 7:14AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: PDF from SQLite
Posted By: vetal.kw
Subject: PDF from SQLite
Date Posted: 08 Apr 21 at 7:13AM
Hello!
the file is located in the SQLite database (blob).
how do I save this file to a folder on my computer in Delphi?

procedure TForm3.TabItem4Click(Sender: TObject);
var
  QP: TDebenuPDFLibrary1811;
begin
QP:= TDebenuPDFLibrary1811.Create;
try
  QP.UnlockKey('***************');
  QP.DAOpenFromStream(UniTable1.Fields[2].asString,'');
 QP.SaveToFile('C:\test002.pdf');
finally
  QP.Free;
end;

how can I specify a file from SQLite in "QP. DAOpenFromStream"?







Replies:
Posted By: tfrost
Date Posted: 08 Apr 21 at 10:29AM
I would be surprised if your sample code even compiled, because DAOpenFromStream does not take a string as the first parameter. And QPDF has a 'golden rule' not to mix DA and non-DA functions, so if you actually need to use and modify the loaded file in QPDF you would need eventually to save it with DASaveAsFile to match a DA open function.

Your first question, how to save the file to a folder, is not really a QPDF issue. Unfortunately I am not familiar with the UniTable component (perhaps another user here is). But one suggestion would be to try to treat the data as TBytes (an array of bytes), and write that into a MemoryStream which you can SaveToFile, remembering to set the stream position back to 0 before you do. There may well be way get a stream more directly from the blob but you would find examples in your database documentation.

Your second question, how to load it into QPDF, is then simple: once you have the content in a stream, you can then use DAOpenFromStream. I would try to avoid using strings in this process, because this then starts to involve Unicode.



Posted By: Ingo
Date Posted: 08 Apr 21 at 11:47AM
Hi Vetal,

Here you'll find an older post having to do with SQLite. The posted code will give you few hints how to do:
http://www.quickpdf.org/forum/mac-loadfromstring-bug_topic3099_post12428.html?KW=SQLite+Blob#12428

Here's a larger sample with blobs from oracle:
http://www.quickpdf.org/forum/delphi-7-how-to-open-pdf-from-oracle-database_topic2653.html

If you don't need the DA-functions you shouldn't use them cause these functions are only a subset of the large bunch of functions and mixing DA- and normal functions should be avoided.

This is a good starting point to search in the QuickPDF-ressources:
https://www.debenu.com/docs/pdf_library_reference/Search.php

This is a good starting point to learn more about the library:
http://www.quickpdf.org/

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo




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