You are not logged in.
Pages: 1
Hello,
I like to create a background imagefile for every page of the pdf.
I tried to use this code
PDF := TPDFDocument.Create;
Image := TPdfImage.CreateJpegDirect(pdf, 'BackgroundImage.jpg');
Pdf.AddXObject('BackgroundImage', Image);
for i := 0 to PageCount-1 do
begin
page := PDF.AddPage;
Pdf.Canvas.DrawXObject(0, 0, page.PageWidth, page.PageHeight, 'BackgroundImage');
end;
this generates an exception on the AddObject statement
how can i resolve this?
Offline
I just tried the following code:
program Project4;
{$APPTYPE CONSOLE}
uses
SynPdf;
procedure Test;
var Image: TPdfImage;
PDF: TPDFDocument;
Page: TPdfPage;
i: integer;
begin
PDF := TPDFDocument.Create;
Image := TPdfImage.CreateJpegDirect(pdf, 'Pingoo_s.jpg');
Pdf.AddXObject('BackgroundImage', Image);
for i := 0 to 10-1 do
begin
page := PDF.AddPage;
Pdf.Canvas.DrawXObject(0, 0, page.PageWidth, page.PageHeight, 'BackgroundImage');
end;
PDF.SaveToFile('test.pdf');
PDF.Free;
end;
begin
Test;
end.
Which worked like a charm - at least with the current trunk version from http://synopse.info/fossil
Offline
Pages: 1