Hello,
Our application reads some PDF files, use them as watermarks and add some information simulating a header and footer.
The problem is that it works fine with some PDF’s and it does not with others. I am sure that I am missing something but I cannot identify it, can you help me out so that my application can read whatever kind of PDF.
Here is the piece of code I am using...
Code
...
const
PDFHeight = 792; //Round((279.4 * 72)/25.4);
PDFWidth = 612; //Round((215.9 * 72)/25.4);
...
procedure TfrmMain.btnFile1Click(Sender: TObject);
var
i : integer;
fdc : smallint;
begin
if (Sender as TButton).Tag = 1 then
begin
WPPDFPrinter1.Filename := stxFile1.Caption;
WPPDFPrinter1.InputFile := edtFile1.Text;
end
else
begin
WPPDFPrinter1.Filename := stxFile2.Caption;
WPPDFPrinter1.InputFile := edtFile2.Text;
end;
fdc := 1;
WPPDFPrinter1.InputFileMode := wpConvertInputToWatermark;
WPPDFPrinter1.CompressStreamMethod := wpCompressFlate;
WPPDFPrinter1.FontMode := wpEmbedSubsetTrueType_UsedChar;
WPPDFPrinter1.BeginDoc;
for i:= 1 to WPPDFPrinter1.InputPageCount do
begin
WPPDFPrinter1.StartPage(PDFWidth,PDFHeight,72,72,0);
WPPDFPrinter1.UseWatermark('inpage' + IntToStr(i));
WPPDFPrinter1.Canvas.Font.Name := 'Arial';
WPPDFPrinter1.Canvas.Font.Size := 14*fdc;
WPPDFPrinter1.Canvas.Font.Style := [fsBold];
WPPDFPrinter1.Canvas.Font.Color := clRed;
WPPDFPrinter1.Canvas.TextOut(Round(PDFWidth/2)-(WPPDFPrinter1.Canvas.Textwidth('DOCUMENTO OBSOLETO') div 2),95,'DOCUMENTO OBSOLETO');
WPPDFPrinter1.Canvas.TextOut(35,PDFHeight-45,'Tipo de Copia');
WPPDFPrinter1.Canvas.TextOut(round(PDFWidth/2)-(WPPDFPrinter1.Canvas.Textwidth('Emision') div 2),PDFHeight-45,'Emision');
WPPDFPrinter1.Canvas.TextOut(PDFWidth-120,PDFHeight-45,'Numero de copia');
WPPDFPrinter1.EndPage;
end;
WPPDFPrinter1.EndDoc
end;
Alles anzeigen
If you need me to send you an example of a PDF that works and other that does not, let me know.
Thank you,
Ernesto