Scale RTF to fit to one page
Scale RTF to fit to one page
Hello,
here I come with another question/problem:
I get any RTF file (which I can load via RichView or RichViewHelper). How can I scale this to fit to one page for my print out (via RVPrinter)?
Thank you for any hints.
here I come with another question/problem:
I get any RTF file (which I can load via RichView or RichViewHelper). How can I scale this to fit to one page for my print out (via RVPrinter)?
Thank you for any hints.
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I think following is to do:
1) Determin the screen device size (for preview) and printer device size (selected printer and paper size for printing)
2) Determin the "virtual" page height, the page should have to render the whole RichView content into only ONE page
3) Scale the large page proportional to
3a) a screen device for print preview and
3b) to the selected printing device's paper size for printing
Can you give me some hints, how to implement this? Or is there any easier/quicker way?
1) Determin the screen device size (for preview) and printer device size (selected printer and paper size for printing)
2) Determin the "virtual" page height, the page should have to render the whole RichView content into only ONE page
3) Scale the large page proportional to
3a) a screen device for print preview and
3b) to the selected printing device's paper size for printing
Can you give me some hints, how to implement this? Or is there any easier/quicker way?
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You cannot print a scaled document using TRVPrint. Use TRVReportHelper instead.
First, format RVReportHelper (Init + FormatNextPage).
Let PageWidth is a width specified in Init, PageHeight := RVReportHelper.GetLastPageHeight (I assume that the document has only one page).
Let DestRect is a rectangle where you can print.
(i.e., the document originally has the size PageWidth x PageHeight. You print it scaled inside DestRect)
In this code, Canvas is a Printer.Canvas. Do not forget to call Printer.BeginDoc and EndDoc.
See the demo Demos\Delphi\Assorted\Printing\ReportHelper\ for additional information about printing with TRVReportHelper.
First, format RVReportHelper (Init + FormatNextPage).
Let PageWidth is a width specified in Init, PageHeight := RVReportHelper.GetLastPageHeight (I assume that the document has only one page).
Let DestRect is a rectangle where you can print.
(i.e., the document originally has the size PageWidth x PageHeight. You print it scaled inside DestRect)
Code: Select all
SetMapMode(Canvas.Handle,MM_ANISOTROPIC);
SetWindowExtEx(Canvas.Handle, PageWidth, PageHeight, nil);
with DestRect do begin
SetViewportExtEx(Canvas.Handle, Right-Left, Bottom-Top,nil);
SetViewportOrgEx(Canvas.Handle,Left,Top,nil);
end;
rv.DrawPage(1, Canvas, False, False, PageHeight);
SetMapMode(Canvas.Handle,MM_TEXT);
SetViewportOrgEx(Canvas.Handle,0,0,nil);
See the demo Demos\Delphi\Assorted\Printing\ReportHelper\ for additional information about printing with TRVReportHelper.
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: