hello, we acquired wpviewpdf to add watermark in our pdf documents, I am trying to use the example of DEMO to generate watermark 180 degrees, however unsuccessfully, I await answers.
WaterMark
-
-
- Offizieller Beitrag
Hi,
please quote the code you actually use.
The standard code is this:
Code
Alles anzeigenvar WPPDF: TWPViewPDF; T: TPDFDrawObjectRec; cnt, FTransparencyPercent, FRotationAngle : Integer; .... // loop through all pages of the PDF for cnt := 0 to WPPDF.PageCount-1 do begin FillChar(T, SizeOf(T), 0); T.structsize := SizeOf(T); //!! T.PageNo := cnt; if DrawRect.Checked then begin T.grtyp := 0; T.ColorBrush := clGreen; end else begin T.grtyp := 100; T.ColorText := clRed; end; T.Alpha := Round(FTransparencyPercent / 100 * 255); T.Angle := FRotationAngle; T.ObjectOptions := 64; T.FontSize := StrToIntDef(FontSize.Text,0)*100; // The offset mode is under development: T.CreateOptions := PDFDrawObjectRecPositionArray[PositionMode.ItemIndex] + 2048; // W and H = % T.units_xywh := 10; // 720 dpi T.x := StrToIntDef( XOFF.Text, 0); T.y := StrToIntDef( YOFF.Text, 0); if T.FontSize=0 then begin T.w := StrToIntDef( WPZ.Text, 0); // % due to flag 2048 in CreateOptions T.h := StrToIntDef( HPZ.Text, 0); end; OptionStr := 'FONT=TimesNewRoman'; // CourierNew'; WPPDF.AddDrawObject(wpAddNow, WideString('TEXTOBJECT'), T, WideString(FWatermarkText) , PAnsiChar(OptionStr), Length(OptionStr) ); end;
It is from the manual "VCL: Add text draw object to all pages".
Please note that you need to "render" the objects into the pages before they are saved.
Command(COMPDF_RenderDrawobjects,32+64+4+8)
-
Hello , thanks for replying . We managed to generate the watermark as we needed with the posted code but after calling the method savetofile the watermark does not remain in pdf document that was saved . the code I am using is :
WPPDF.CommandEx(COMPDF_RenderDrawobjects, 4 + 8 + 32 + 64); // Render
WPPDF.ClearDrawObject(-1, -1); // and Clear all
// save the watermarked PDF...
WPPDF.Plus.SaveToFile(FOutputFileName); -
- Offizieller Beitrag
In rare cases a watermark will not be visible since it is hidden by the page contents.
Bit 1 should not be set in CreateOptions, otherwise the object can be hidden.
You may send me the files before and after you applied the text objects.