Background Image Superprint

  • Hi,

    i try to print out an image using the backgound image function of the superprint component.

    I use a bitmap of about 500 x 400 px and the following code to print.

    Whatever try, superprint is ignoring the background.

    Does anybody know what to do?

    Code
    Printer.BeginDoc;
    WPSuperPrint1.Paint(
    Printer.Canvas,
    -GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX), // Offset in pixels
    -GetDeviceCaps(Printer.Handle, PHYSICALOFFSETy), // Offset in pixels
    GetDeviceCaps(Printer.Handle, LOGPIXELSY) / 1440, // Multiplicator for Parameters
    []); // Options
    Printer.EndDoc;
    • Offizieller Beitrag

    I just verified that it works (V5.20.2)

    Code
    procedure TWPSuperPrintTest.WPRichText1PaintWatermark(Sender: TObject;  RTFEngine: TWPRTFEnginePaint; toCanvas: TCanvas; PageRect: TRect;  PaintPageNr, RTFPageNr: Integer; WaterMarkRef: TObject; XRes,  YRes: Integer; CurrentZoom: Single; PaintMode: TWPPaintModes);begin  if DemoWater.Checked then  begin     //also works: toCanvas.StretchDraw(PageRect, Image1.Picture.Graphic);     WPPrintTiledBackground(toCanvas,PageRect,Image1.Picture.Graphic);  end;end;

    I think you are trying to tile an image - I would rather recommend to start with something simple, for example a metafile with stretchdraw

    end of course you could draw the background before SuperPrint prints the page contents - directly on the PrinterCanvas. For tiling this would be the far better approach since otherwise you dont get an even filling.

    Code
    while n < WPSuperPrint1.EditBox.PageCount do
        begin
          WPPrintTiledBackground(Printer.Canvas,Printer.Canvas.ClipRect,Image1.Picture.Graphic,
             GetDeviceCaps(Printer.Handle, LOGPIXELSY)/WPScreenPixelsPerInch);
    
    
          n := WPSuperPrint1.Paint(...)

    WPPrintTiledBackground works ok on my printer, but since it uses simple StretchDraw it is possible that it does not work with printerst. As already posted - you need to use StretchDIBS API for printers to print images reliably.

    Julian

  • Hi Julian,

    thats what I intended to do. Printing a watermark works fine now.

    Is there a way not to show a watermark but printing it, thus?

    And... can I use a high res vector image for watermarks or just bitmaps?

    Best Regards...

    Mirko

  • This worked. cool thanks a lot!!!

    What kind of filetype is useful for vector images concerning WPTools.

    Since I use TImage there is just wmf as an option. Or can I use something else?

    Greets

    Mirko

  • There is one other thing that is really strange.

    I load a background image (bmp) in the superprint component. And the same as watermark in the bacground.

    Why do I still have to load an image into superprint and not just print the loaded waterkark?

    Greets

    Mirko