WPCubed Product Support

Watermark shrinking when printing

I am using a high quality jpeg for our letterheads.

This is loaded in the RichText.OnPaintWatermarkEvent using the following code

if wppInPaintDesktop in PaintMode then //Want to paint on the Canvas and not the Background (can't print if on BackGround)
PaintMode := PaintMode - [wppInPaintDeskTop];
if not Assigned(BackGroundImage) then //i.e. not already loaded
begin
if FileExists(WPRichText1.RTFVariables.Find('BackGround').Text) then
begin
BackgroundImage := TJpegImage.Create;
BackgroundImage.LoadFromFile(WPRichText1.RTFVariables.Find('BackGround').Text);
end;
end;
toCanvas.StretchDraw(PageRect,BackgroundImage);

This looks great on screen and the graphic is correctly positioned for the A4 page.

When I print the letter the graphic shrinks by about 10mm vertically and proportionally horizontally.

How can I get it to print the full size?

Thanks.

Rob.

#1 ♥ 0
9.8k Views 3 users read 4 min
support

Hi,

When I print the letter the graphic shrinks by about 10mm vertically and proportionally horizontally. <<

This is the physical printer margin.

You can of course access the printer.Canvas directly.

You are *printing*when wppInPaintDesktop is not used.

Julian

#2 ♥ 0

Thank you Julian

I will have a look at printer.canvas but expect further questions ;-)

What is the significance of my printing when wppInPaintDesktop is not used?

Rob.

#3 ♥ 0

Julian

I am trying to use the printer.canvas option.

In the OnPaintWatermarkEvent I have the following code

if printer.Printing then
  begin
    PageRect.Left := 6;
    PageRect.Top := -42;
    PageRect.Right  := PageRect.Left + MulDiv(11630, Xres, 1440);
    PageRect.Bottom := PageRect.Top + MulDiv(16900, Yres, 1440);
    Printer.canvas.StretchDraw(PageRect,BackgroundImage);
    exit;
  end;

The above prints correctly. It is an A4 image and the paper is A4

Why do I have to 'fiddle' with the twips as opposed to using RichText.Header.PageWidth and PageHeight?

This works on one printer bu on the other the graphic is 30mm or so too far to the right.

What is the correct weay to get this to work?

Thanks.

Rob.

(Edited 02 May 2006 08:55 BST)

#4 ♥ 0
support

Hi,

Printers have a physical margin - this is always added to the x and y offset. When wptools prints it subtracts those margins from the margins defined for the page.

Those offsets can be retrieved using

GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETX)
and GetDeviceCaps(Printer.Canvas.Handle, PHYSICALOFFSETY)

You need to subtract those values!

Note that the page size is:

presx := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
presy := GetDeviceCaps(Printer.Handle, LOGPIXELSY);

aPageWidth := MulDiv(GetDeviceCaps(aPrinter.Handle, PHYSICALWIDTH), 1440, presx);

aPageHeight := MulDiv(GetDeviceCaps(aPrinter.Handle, PHYSICALHEIGHT), 1440, presy);

Julian

#5 ♥ 0

Julian

I have tried your suggestion and scoured the NGs for further assistance.

I cannot get the correct output.

The graphic I want as the printed background is created at exactly A4. It is a JpegImage. There is sufficient white around it to cater for all printer margins.

I do not want the graphic cropped or anything like that. I want it to sit exactly over the A4 printer page.

Whatever I do I get a large margin at the right and bottom of the printed page. The image is being cropped but as I say, the resulting white space is two to three times the size of the print margins.

Is it possible to line an A4 Jpeg exactly over the A4 page?

Thanks.

Rob.

#7 ♥ 0

Julian

I have found the cause of my problem

I don't know why, but the RichText Pagesize was set as custom and was slightly smaller than A4.

I'm almost there now.

Thanks.

Rob.

#8 ♥ 0

@rRowlands:
The graphic I want as the printed background is created at exactly A4. It is a JpegImage. There is sufficient white around it to cater for all printer margins.

I am just getting started with WPTools, but I'd try removing that white space and controlling the positioning of the graphic from inside WPTools only. An exactly A4 sized image will not print correctly on an A4 page. Depending on the printer, you actually have only an area sized 8" x 10.5", or even smaller on some printers.

#9 ♥ 0
support

Hi,

I cases like this I recomend to first try to print a rectangle at a defined position and the start with an image.

The printer margins are added "in hardware" - you need to remove them in your code (subtract PysicalOffset)

Please note that the PageWidth/PageHeight values defined by "Printer" are not useful. They refere to the printable area, not the size of the paper.

Julian

#10 ♥ 0
This category is archived. No new posts are possible.