PPV file format

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

PPV file format

Postby array81 » May 23rd, 2011, 7:52 am

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, ...).
array81
Active Member
Active Member
 
Posts: 7
Joined: January 25th, 2009, 10:58 am

Use PrintPreview with an RTF file as template

Postby Kambiz » May 23rd, 2011, 12:03 pm

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:

  1. 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.
  2. Put a rich edit control on the form and set its visible property to false.
  3. Before printing a new invoice, load the RTF file (template) into the rich edit control.
  4. 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.
  5. Print the rich edit control using an instance of TPrintPreview.
Hope that it helps.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: PPV file format

Postby array81 » May 26th, 2011, 4:17 pm

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?
array81
Active Member
Active Member
 
Posts: 7
Joined: January 25th, 2009, 10:58 am

Re: PPV file format

Postby Kambiz » May 26th, 2011, 9:03 pm

Try to use RxRichEdit control of RxLibrary,
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: PPV file format

Postby array81 » May 27th, 2011, 7:25 am

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.
array81
Active Member
Active Member
 
Posts: 7
Joined: January 25th, 2009, 10:58 am

Re: PPV file format

Postby Kambiz » May 27th, 2011, 10:10 am

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: PPV file format

Postby array81 » May 27th, 2011, 10:53 am

I just have tried it but not work...
array81
Active Member
Active Member
 
Posts: 7
Joined: January 25th, 2009, 10:58 am

Re: PPV file format

Postby Kambiz » May 27th, 2011, 1:08 pm

Apparently TRichView doesn't rely on the Windows rich control.
TPrintPreview uses Windows API to render RTF content.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron