WPCubed Product Support

WPTools Watermark not showing up when going to wPDF

support

Hi,

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

Please try to standardize the canvas property using SetMapMode(MM_TEXT)

Julian

#6 ♥ 0
10.3k Views 2 users read 5 min

@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:

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.

#5 ♥ 0

@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.

#4 ♥ 0

@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???

#3 ♥ 0
support

Hi,

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

Julian

#2 ♥ 0

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:

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:

while i < aWPRichText.CountPages do
  begin
    w := MulDiv(aWPRichText.Memo._PaintPages[i].WidthTw,WPScreenPixelsPerInch,1440);
    h := MulDiv(aWPRichText.Memo._PaintPages[i].HeightTw,WPScreenPixelsPerInch,1440);

    if (w=0) or (h=0) then
    begin
      w := Round(aWPRichText.Memo.PaintPageWidth[i] / aWPRichText.Memo.CurrentZooming );
      h := Round(aWPRichText.Memo.PaintPageHeight[i] / aWPRichText.Memo.CurrentZooming );
    end;

    xres := aWPRichText.Memo.RTFData.RTFProps.FFontXPixelsPerInch;
    yres := aWPRichText.Memo.RTFData.RTFProps.FFontYPixelsPerInch;

    StartPage(MulDiv(w, xres, WPScreenPixelsPerInch),
              MulDiv(h, yres, WPScreenPixelsPerInch),
              xres, yres, 0);

    try
      // Use 0 as w and h to let the function calculate the width and height
      aWPRichText.Memo.PaintRTFPage(i,0,0,0,0,Canvas, [wppInPaintForwPDF] );
    finally
      EndPage;
    end;

    inc(i);
  end;

Not sure what is wrong here.

Thanks,

Greg

#1 ♥ 0