#1 2021-01-01 13:40:07

liam1983
Member
Registered: 2021-01-01
Posts: 10

PDF as Background Image

Hi,

I found a way to make Pictures as a Background or Watermark Image, but how to do this with a PDF?

Offline

#2 2021-01-01 17:11:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: PDF as Background Image

Draw first the picture, then write the text and the main content over it.

Online

#3 2021-01-05 10:17:29

liam1983
Member
Registered: 2021-01-01
Posts: 10

Re: PDF as Background Image

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

#4 2021-01-05 10:38:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: PDF as Background Image

Embedding PDF is not supported.

Try to convert the input into an EMF, then render it on the page...

Online

#5 2021-01-05 11:04:39

liam1983
Member
Registered: 2021-01-01
Posts: 10

Re: PDF as Background Image

The same way like the jpg?

Offline

Board footer

Powered by FluxBB