Page 1 of 1
Scale RTF to fit to one page
Posted: Tue Oct 25, 2005 10:17 am
by Bulvaye
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.
Posted: Tue Oct 25, 2005 12:46 pm
by Sergey Tkachenko
To fit vertically or horizontally?
Posted: Tue Oct 25, 2005 1:11 pm
by Bulvaye
Vertically!
I have to scale the document as far as it fits to exactly one page, if the content of the rtf is larger than one page. If the content is smaller, fitting will not be nescessary.
Posted: Wed Oct 26, 2005 11:59 am
by Bulvaye
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?
Posted: Sun Oct 30, 2005 10:24 pm
by Sergey Tkachenko
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)
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);
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.
Posted: Mon Nov 07, 2005 3:44 pm
by HighTower
Sergey Tkachenko wrote:I assume that the document has only one page
and how about scaled printing of several pages?
(originally, for example, 2.5 pages scale to 2 pages)
Posted: Wed Nov 09, 2005 9:03 pm
by Sergey Tkachenko
Scale by which ratio?
Posted: Thu Nov 10, 2005 8:14 am
by HighTower
scale by user defined ratio.
if you know product "1C" - it has scale printing - very usefull feature and I (we) wonna smth like this.
Posted: Thu Nov 10, 2005 3:39 pm
by Sergey Tkachenko
Well, you need
1) Repaginate RVReportHelper taking the scaling ratio into account (for example, if you want to shrink the image by half in dimensions, multiply the page wifsh and height by 2 when calling Init and FormatNextPage)
2) Use the code from this topic for scaled printing.