WPTools Watermark not showing up when going to wPDF

  • Currently using WPTools 5.x and wPDF 2.x.

    I have the following code to generate watermark when printing to printer from wptools 5.x:

    Code
    if (wppOutputToPrinter in PaintMode) OR (wppInPaintForwPDF in PaintMode) then  begin    if (NOT dmContract.DoPrintAsExecuted) then    begin      imgWidth := imgNotLegal.Picture.Bitmap.Width;      imgHeight := imgNotLegal.Picture.Bitmap.Height;      toCanvas.StretchDraw(Rect((PageRect.Left + Round(PageRect.Right * 0.20)), (PageRect.Top + Round(PageRect.Bottom * 0.35)), (PageRect.Right - Round(PageRect.Right * 0.20)), (PageRect.Bottom - Round(PageRect.Bottom * 0.35))), imgNOTLegal.Picture.Bitmap);    end;  end;

    And here is the code for the printing to pdf:

    Not sure what is wrong here.

    Thanks,

    Greg

  • Zitat von wpsupport

    Hi,

    I would first simplyfy the printing rectnagle. Did You use StretchDraw(PageRect, image) ?

    Julian

    Julian,

    Yes I tried this and it didn't make a difference when printing to wPDF. The only way I could get what would look like a watermark on the wPDF was to do it directly in the MakePDF call of mine and doing a DrawTGraphic. Although I am having some alignment issues it is showing up that way.

    But why will it not use what wpTools properly shows when printing to printer???

  • Zitat von gsaunders

    Julian,

    Yes I tried this and it didn't make a difference when printing to wPDF. The only way I could get what would look like a watermark on the wPDF was to do it directly in the MakePDF call of mine and doing a DrawTGraphic. Although I am having some alignment issues it is showing up that way.

    But why will it not use what wpTools properly shows when printing to printer???

    Well... I say I was able to get it to work with DrawTGraphic, but at the moment I can't for the life of me get the DrawTGraphic to put it on there and be visible. I get an image_id back so wPDF thinks it put it on the PDF, but when you view it you never see it.

    I know it put it in there as I see the file size increases.

    I tried to view it with PDFView Plus and when it opens the file up I get the following error: "Can't allocate the DIB handle". I used the PDFView demo code.

    But after continuing to run the program the PDF finally comes up and I do see the graphic, but obviously something is wrong as PDFView will eventually show it, but NOT Adobe.

  • Zitat von gsaunders

    Well... I say I was able to get it to work with DrawTGraphic, but at the moment I can't for the life of me get the DrawTGraphic to put it on there and be visible. I get an image_id back so wPDF thinks it put it on the PDF, but when you view it you never see it.

    I know it put it in there as I see the file size increases.

    I tried to view it with PDFView Plus and when it opens the file up I get the following error: "Can't allocate the DIB handle". I used the PDFView demo code.

    But after continuing to run the program the PDF finally comes up and I do see the graphic, but obviously something is wrong as PDFView will eventually show it, but NOT Adobe.

    Ok... the reason for the strange problems with the DrawTGraphic is because the OnWatermark for the WPRichText was still active for the wppInPaintForwPDF. Once I told it to not include for wppInPaintForwPDF then the DrawTGraphic started working and I also figured out the right math to get my bmp centered.

    I still don't know why it can't pick up from the OnWaterMark event of the wprichtext. Certainly would save a step.

    For those interested I used this to get the BMP centered:

    Code
    image_id := DrawTGraphic((MulDiv(w, xres, WPScreenPixelsPerInch) - MulDiv(aGraphic.Width, xres, WPScreenPixelsPerInch)) div 2,
    (MulDiv(h, yres, WPScreenPixelsPerInch) - MulDiv(aGraphic.Height, yres, WPScreenPixelsPerInch)) div 2,
    MulDiv(aGraphic.Width, xres, WPScreenPixelsPerInch),
    MulDiv(aGraphic.Height, yres, WPScreenPixelsPerInch),
    aGraphic);

    I was also able to use a RLE compressed BMP which saved in file size as well.

    Again... I think the OnWaterMark issue should be addressed as it should work.