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 SaveToString / LoadFromString
  FAQ FAQ  Forum Search   Register Register  Login Login

Problem SaveToString / LoadFromString

 Post Reply Post Reply
Author
Message
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Topic: Problem SaveToString / LoadFromString
    Posted: 17 May 06 at 8:56AM
I need to write/read PDF files into/from a database (Interbase/Firebird).

The best way I see with quicPDF is to convert the PDF into a string (SaveToString), then write this into a BLOB. With LoadFromString it should be possible to recreate the PDF.

The first step was no problem (I created a text file as output, and this really contained the content of the PDF). But when I try to load the "text-PDF", the LoadFromString functions returns an error and the TiSEDQuickPDF is empty.

Where is my mistake?
Back to Top
JanN View Drop Down
Senior Member
Senior Member


Joined: 29 Oct 05
Location: Germany
Status: Offline
Points: 116
Post Options Post Options   Thanks (0) Thanks(0)   Quote JanN Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 06 at 10:29AM
Just a thought: Did you try to save that string to file? Is that pdf file accessible by Adobe Reader?
Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 06 at 10:58AM
Hello Jan!

My project exported and saved the original PDF to an ASCII string. This file is accessible with Acrobat/Acrobat Reader (both are complaining the 'file is damaged', but they do open correctly).

I think I found another (WORKING) way saving PDFs into database (RenderDocumentToFile -> JPG and ExtractFilePageText -> TXT); when reading the "PDF", the JPG will be displayed instead...

Main problem is increase of file size (PDF 4kb, JPG 135kb with 150dpi).
__________________
Best Regards,
Volker
Best Regards,
Volker
Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 06 at 11:59AM
Finally I found the solution for my problem:

1) Saving each page of the PDF as ASCII with function ExtractFilePageText(sFileName, '', iPage, 2)
-> infos for text position, fontsize/font are exported too!
2) Writing this string into database.
3) When reading from database, each line of PDF is added with DrawText.
-> a virtual copy of original PDF is displayed!

This works fine for me, because my PDF do not contain pictures!
Best Regards,
Volker
Back to Top
cpri View Drop Down
Team Player
Team Player


Joined: 17 Feb 06
Location: Netherlands
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpri Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 06 at 8:59AM

Why don't you save the pdf as a BLOB in your database with SaveToStream.

code for reading and writing the pdf to and from the database

/code

procedure TMydbase.read_datasheet(indexnummer:integer);
var  blob : tstream;
begin
query_open('select * from Table where indexnummer = '+ ''''+inttostr(indexnummer)+'''');
blob:=query.createblobstream(query.Fieldbyname('datasheet'),bmread);
blob.seek(0,sofrombeginning);  //I always save the current pdf to my HD but you cal load it in your quickpdf object as well
with tfilestream.create('c:\default.pdf',fmcreate) do
     try
     copyfrom(blob,blob.size);
     finally
     free;
     end;
blob.free;
query.Close;
end;

procedure TMydbase.write_datasheet(type_meting,tekeningnr,operator,datum,tijd,bewerking,kommentaar:string;pijp_nr,array_nr,indexnummer_meting:integer);
var sql_:string;
begin
sql_:='insert into Tabel(indexnummer,datasheet) ';
sql_:=sql_+'values(:indexnummer,:datasheet)';
Query.SQL.Clear;
query.sql.add(sql_);
query.prepare;
query.parambyname('indexnummer_meting').value:=indexnummer;
Query.ParamByName('datasheet').LoadFromFile('c:\default.pdf',ftblob); //you should use load fromstream instead
execute_sql;
end;


code

Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 06 at 10:03AM
Thanks Christian, I'll try that next!
Best Regards,
Volker
Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 06 at 12:56PM
Hello Christian!

The importing with "SaveToStream"/"LoadFromStream" did NOT work at all, but I sneaked through Interbase/FireBird/IBO documentation and found another possibility...
Now I don't need QuickPDF for writing/saving; I can do this like

with IB_QWORK do
TRY
   active := FALSE;
   ParamByName('aID').AsInteger := IDX;
   ParamByName('aFNAME').AsString := ExtractFileName(sTMP);
   ParamByName('aDATA').LoadFromFile(sTMP);
   execSQL;
   ...
EXCEPT
   ...
END;

For loading the PDF I can act similar ( FieldByName('DATA').SaveToFile(...))

But Your idea was the final solution (writing BLOB directly)!
THANKS!
Best Regards,
Volker
Back to Top
cpri View Drop Down
Team Player
Team Player


Joined: 17 Feb 06
Location: Netherlands
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpri Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 06 at 1:33AM

Ok glad you worked it out.

I will try the SaveToFile as well. It takes less code and memory

So thanks for the tip

Back to Top
cpri View Drop Down
Team Player
Team Player


Joined: 17 Feb 06
Location: Netherlands
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpri Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 06 at 4:18AM

Hello

ParamByName('Data').LoadFormFile works great but I can't find the function FieldByName('Data').SaveToFile.

am I missing something. I'm using the standard Interbase components

Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 06 at 6:33AM
Hello!

Our company is using Interbase/FireBird as default SQL server database. For database access we have Jason Wharton's great 'IBO' components (InterBase Objects) and these allow FieldByName('xx').SaveToFile.
Best Regards,
Volker
Back to Top
cpri View Drop Down
Team Player
Team Player


Joined: 17 Feb 06
Location: Netherlands
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpri Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 06 at 8:36AM

ok

It's a pitty the standard interbase components from borland don't support the function. But the methode I use works fine

Thanks anyway

Back to Top
swb1 View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 05 Dec 05
Location: United States
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote swb1 Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 06 at 1:33PM

I have never used the interbase components… so I ignorantly ask… Couldn’t you just cast the field component as TBlobfield? i.e.:

 

Table.FieldByName(‘xyz’) as TBlobField.SaveToFile(FileName);

Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 06 at 2:41AM
Hi swb1,

of course I could. But inside our BLOBs there are/can be german special characters and with IBO I'm sure (has been tested!) the input and output is correct without additional work.

Besides: IBO is very stable, quick and well supported!!!

We have been using the "BDE" for some (horrible) years and since we have (mostly) replced BDE with IBO, things have become much better!
Best Regards,
Volker
Back to Top
ECPVFR View Drop Down
Beginner
Beginner
Avatar

Joined: 17 May 06
Location: Germany
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote ECPVFR Quote  Post ReplyReply Direct Link To This Post Posted: 01 Jun 06 at 5:06AM
Hi swb1,

I have tested TBlobField(Query.FieldByName('PDFBLOB')).SaveToFile(sFileName) (with BDE components) and it doesn't work at all!
It is showing 'cannot transliterate characters between character sets' even if I set 'transliterate' to FALSE!

So I have to use the IBO components (or waste hours/days to get BDE components working somehow...)
Best Regards,
Volker
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. About — Contact — Blog — Support — Online Store