Page 1 of 1
PPV file format

Posted:
May 23rd, 2011, 7:52 am
by array81
I need print invoice on my application. I'd like use your TPrintPreview to do it. However I should like add templete for invoice so I'd like know if it is possible with your TPrinrPreview.
I need save inside the PPV file the information (posizione and name) about the "fields", so I can fill them (like in Fast Report). Is it possible with TPrintPreview? I need print only a small invoice and I don't want use a big report component (like fast report, builder report, ...).
Use PrintPreview with an RTF file as template

Posted:
May 23rd, 2011, 12:03 pm
by Kambiz
TPrintPreview doesn't offer something like a template. PPV file format is nothing useful. It's just a series of Metafiles saved all together as a single file.
But there is a simple solution to this problem:
- Create your own template using WordPad and save it as an RTF file. In the template, enclose variable fields by braces or something similar to distinguish them from the other text.
- Put a rich edit control on the form and set its visible property to false.
- Before printing a new invoice, load the RTF file (template) into the rich edit control.
- Use rich edit's FindText method to find a field in the text and use SelStart, SelLenght, and SelText properties of the control to replace the field with its actual value. Repeat this step for all fields.
- Print the rich edit control using an instance of TPrintPreview.
Hope that it helps.
Re: PPV file format

Posted:
May 26th, 2011, 4:17 pm
by array81
OK I want use Kryvich’s Delphi Reporter (
http://sites.google.com/site/kryvich/reporter) to creare the RTF file. However the official Delphi RTF file not support many RTF "format" (it's orroble), for example table border with color or with background. Do you know a valid RTF component derivated from TCustomRichEdit to use with your component?
Re: PPV file format

Posted:
May 26th, 2011, 9:03 pm
by Kambiz
Try to use RxRichEdit control of
RxLibrary,
Re: PPV file format

Posted:
May 27th, 2011, 7:25 am
by array81
Also RxRichEdit doesn't work for me. TRichView works (I see RTF correct) but I don't know how use it with your component, is it possible? Do you kwnow any other alternatives? Thanks again.
Re: PPV file format

Posted:
May 27th, 2011, 10:10 am
by Kambiz
I never worked with TRichView.
If TRichView provides handle to an underlying windows rich edit control, you can use TPrintPreview to print it. To check it out, just type cast the TRichView instance as TCustomRichEdit and pass it to the PaintRichText method.
Re: PPV file format

Posted:
May 27th, 2011, 10:53 am
by array81
I just have tried it but not work...
Re: PPV file format

Posted:
May 27th, 2011, 1:08 pm
by Kambiz
Apparently TRichView doesn't rely on the Windows rich control.
TPrintPreview uses Windows API to render RTF content.