Recent

Author Topic: [ SOLVED ] Print TVirtualStringTree to pdf  (Read 3330 times)

superc

  • Jr. Member
  • **
  • Posts: 89
[ SOLVED ] Print TVirtualStringTree to pdf
« on: August 03, 2021, 11:29:01 am »
Hello,

I've created my TVirtualString and I must print the tree on pdf (and save it to file), how would you proceed? What components or methodologies would you use?

Thanks in advance.
« Last Edit: August 04, 2021, 09:13:49 am by superc »

GetMem

  • Hero Member
  • *****
  • Posts: 3452
Re: Print TVirtualStringTree to pdf
« Reply #1 on: August 03, 2021, 03:04:50 pm »
Hello,

I've created my TVirtualString and I must print the tree on pdf (and save it to file), how would you proceed? What components or methodologies would you use?

Thanks in advance.
This is a tough one. You can certainly save/load a VST to/from a file, but that's a binary format. In order to print a tree to a pdf, first you have to draw the tree canvas to a bmp, then via LazReport and PDFExport(alternatively FPReport/fcl-pdf) to a pdf file. Maybe there are other methods too that I'm unaware of. 

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Print TVirtualStringTree to pdf
« Reply #2 on: August 03, 2021, 04:13:51 pm »
Maybe there are other methods too that I'm unaware of.

Using fcl-pdf (or PowerPDF) would probably be the easier, wouldn't it? Or maybe relying on a PDF "printer" ... though that would force users to install one. :-\
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

GetMem

  • Hero Member
  • *****
  • Posts: 3452
Re: Print TVirtualStringTree to pdf
« Reply #3 on: August 03, 2021, 06:58:11 pm »
My brain hurts, but I did it.  :)
I'm using the same project from your previous thread(https://forum.lazarus.freepascal.org/index.php/topic,55461.msg412695.html#msg412695).
Lazarus 2.0.12(32 bit)/FPC 3.2.0/Zeos 7.2.14.0/Power PDF 1.4.0.0
Please do the following:
   1. Extract attachment
   2. Copy sqlite3.dll(32 bit) to the project folder
   3. Install Zeos from OPM
   4. Install PowerPDF from OPM
   5. Go to "Install/Uninstall Packages" dialog, install Lazreport and LazreportPDFExport, don't forget to rebuild the IDE
   6. Open then run the project, press the "Tree to PDF" button

PS: The above method should also print the non-visible part of the tree(in case you have horizontal/vertical scrollbars).
« Last Edit: August 04, 2021, 07:23:20 am by GetMem »

superc

  • Jr. Member
  • **
  • Posts: 89
Re: Print TVirtualStringTree to pdf
« Reply #4 on: August 04, 2021, 09:13:29 am »
My brain hurts, but I did it.  :)
I'm using the same project from your previous thread(https://forum.lazarus.freepascal.org/index.php/topic,55461.msg412695.html#msg412695).
Lazarus 2.0.12(32 bit)/FPC 3.2.0/Zeos 7.2.14.0/Power PDF 1.4.0.0
Please do the following:
   1. Extract attachment
   2. Copy sqlite3.dll(32 bit) to the project folder
   3. Install Zeos from OPM
   4. Install PowerPDF from OPM
   5. Go to "Install/Uninstall Packages" dialog, install Lazreport and LazreportPDFExport, don't forget to rebuild the IDE
   6. Open then run the project, press the "Tree to PDF" button

PS: The above method should also print the non-visible part of the tree(in case you have horizontal/vertical scrollbars).

it seems to me a fitting solution to my problem, now let's see how it behaves with 1000 node....
Thank you again



GetMem

  • Hero Member
  • *****
  • Posts: 3452
Re: [ SOLVED ] Print TVirtualStringTree to pdf
« Reply #5 on: August 04, 2021, 01:22:34 pm »
Unfortunately Lazreport does not increase the size of the image properly, so for a very large tree the generated pdf is wrong. You can try other report generating tools like: 
 - FPReport
 - Fortes4Lazarus
 - FortesReport-CE
 - Fastreport
All of the above has PDF export built in.
I ran a few test for large trees, in each case the generated Bmp(see FBitmap in the code) is correct, however the bitmap size is very large. In my opinion the tree to pdf conversion is not practical. You should filter the tree or use some kind of pagination and only export the relevant data or perhaps switch to a formated text file?

 

TinyPortal © 2005-2018