trichview.support
Re: screen <-> printer |
Author |
Message |
Sergey Tkachenko |
Posted: 07/22/2003 19:15:33 Hi, If you want to create the same image on printer and paper, you need: 1) Format reporthelper in printer resolution. You need to create printer-compatible canvas and use it for reporthelper.Init() Creating: var PrnCanvas: TCanvas; PrnDC: HDC; PrnCanvas := TCanvas.Create; PrnDC := RV_GetPrinterDC; // from PtblRV unit PrnCanvas.Handle := PrnDC; PrnCanvas.Font.PixelsPerInch := GetDeviceCaps(PrnDC, LOGPIXELSY); Destroying (when all drawing is finished) PrnCanvas.Handle := 0; DeleteDC(PrnDC); PrnCanvas.Free; 2) When printing, use rvhelper.DrawPageAt(... Printer.Canvas ...), as I guess you currently do 3) When drawing preview, you need to scale image. There is a simple method for previewing: using TRVPrintPreview showing some fake (empty) document. You can draw preview in OnPagePrepaint event. Example: http://www.trichview.com/support/files/preview.zip > > Hi, > > I use TRVReportHelper to print multiple records of a report on one or more > pages. > TRVReportHelper draws the pages onto the printercanvas and as a preview to > a TImage as in one of your demos. Of course it would be nice if the preview > would look like the print. But this is not the case. > > If I e.g. draw on the printercanvas in a given region of lets say 15 cm the > printer fits approx. 30 lines of text into this area. If I do the same with > the TImage it only fits 27-28 lines of text in the same region of 15 cm. > > This can leed to different number of pages send to the printer, and created > on the TImage as a preview. This can be pretty annoying. > > I calculate the width and height of my area in pixel with: > > function mmToPixel(mm:extended;dpi:integer):integer; > begin > Result := round( (mm / 25.4) * dpi ); > end; > > Where for the TImage dpi = GetDeviceCaps(TImage.Canvas.Handle, LOGPIXELSX) > and for the printer dpi = GetDeviceCaps(printer.Handle, LOGPIXELSX). > > I assume it might have something to do with the difference in resolution > ( 96 dpi <-> 600 dpi ) but I'm not sure. > > Furthermore in the TImage more characters can be fit in one line. > > To make it short: A page drawn to a printercanvas does not look like a page > drawn to an imagecanvas. > > Am I missing something or am I making something wrong? > > Perhaps you could enlighten me. > > Tia > > Frank Kroeger |
Powered by ABC Amber Outlook Express Converter