You are not logged in.
Pages: 1
Hi,
I found a way to make Pictures as a Background or Watermark Image, but how to do this with a PDF?
Offline
Sorry here is a better description of my problem.
I export a Quickreport file to PDF.
Pdf := TPdfDocument.Create();
try
Pdf.DefaultPaperSize := psA4;
Pdf.UseUniscribe := False;
Pdf.EmbeddedTTF := true;
Pdf.EmbeddedWholeTTF := False;
Pdf.UseOptionalContent := True;
Pdf.StandardFontsReplace := False;
Pdf.CompressionMethod := cmFlateDecode;
// pic := TPicture.Create;
// pic.LoadFromFile('C:\tmp\img_snow.jpg');
// background := TPdfImage.Create(PDF, pic.Graphic, true);
// PDF.AddXObject('BackgroundImage',background);
TDesignQuickReport(qrd.ParentControl).Prepare;
for i := 1 to TDesignQuickReport(qrd.ParentControl).QRPrinter.PageCount do begin
aMeta := TDesignQuickReport(qrd.ParentControl).QRPrinter.GetPage(i);
try
Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,Pdf.ScreenLogPixels);
Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,Pdf.ScreenLogPixels);
page := Pdf.AddPage;
// PDF.Canvas.DrawXObject(0,0,page.PageWidth,page.PageHeight,'BackgroundImage');
Pdf.Canvas.RenderMetaFile(aMeta, 1,0, 0,0, tpExactTextCharacterPositining, 0, 0, tcNeverClip);
finally
aMeta.Free;
end;
end;
Pdf.SaveToFile(SaveFileName);
it works with images, but I need to use it with a pdf file
Offline
The same way like the jpg?
Offline
Hi
Is there no complete example on how to add a watermark? I'm new to SyncPDF
Thanks,
Eric
Offline
Is there no complete example on how to add a watermark? I'm new to SyncPDF
(maybe this should have been a separate question...)
What do you mean by watermark? Just text is the easiest. With GDI you can just write the text at an angle with a grayscale.
Small example (I hope this is ok here instead of a external clip-site):
Make sure to call the watermark text first before writing anything else to the page so it appears in the background.
// call with WriteTextAngled(pdf, 100, 600, 'CONFIDENTIAL');
procedure WriteTextAngled(pdf: TPdfDocumentGDI; x, Y: Integer; Text: string);
var
LogFont: TLogFont;
Font: HFONT;
OldFont: HFONT;
OldBkMode: Integer;
OldColor: COLORREF;
begin
FillChar(LogFont, SizeOf(LogFont), 0);
LogFont.lfFaceName := 'Arial';
LogFont.lfHeight := -60; // Font size
LogFont.lfEscapement := 60 { angle } * 10; // Rotation in tenths of a degree
LogFont.lfOrientation := LogFont.lfEscapement;
LogFont.lfQuality := ANTIALIASED_QUALITY;
Font := CreateFontIndirect(LogFont);
OldFont := SelectObject(pdf.VCLCanvas.Handle, Font);
OldBkMode := SetBkMode(pdf.VCLCanvas.Handle, TRANSPARENT);
OldColor := SetTextColor(pdf.VCLCanvas.Handle, RGB(180, 180, 180));
pdf.VCLCanvas.TextOut(x, Y, Text);
SelectObject(pdf.VCLCanvas.Handle, OldFont);
SetBkMode(pdf.VCLCanvas.Handle, OldBkMode);
SetTextColor(pdf.VCLCanvas.Handle, OldColor);
DeleteObject(Font);
end;
Offline
Pages: 1