Hi, I'm trying to add text to an existing pdf file and save the result to new pdf file.
I used this source code:
Code
function dicituraFissa(szNomeFile:pchar):boolean;
var StampMetaCan : TMetafileCanvas;
aForm : TXForm;
x,y,nrP: integer;
lst :TStringlist;
n,idx:integer;
sz:String;
wp :TWPViewPDF;
StampMeta : TMetaFile;
begin
wp:=TWPViewPDF.CreateParented(application.handle);
wp.LoadFromFile(strpas(szNomeFile)) ;
if true then
begin
StampMeta:=TmetaFile.create;
StampMetaCan := TMetafileCanvas.Create(StampMeta,0);
try
StampMetaCan.Font.Height := -10;
StampMetaCan.Font.Color := clBlack;
StampMetaCan.Font.Name := 'Arial';
StampMetaCan.Brush.Style := bsClear;
aForm.eM11 := 1;
aForm.eM12 := 1;
aForm.eM21 := 1;
aForm.eM22 := 1;
aForm.eDx := Screen.PixelsPerInch;
aForm.eDy := Screen.PixelsPerInch*2;
SetWorldTransform(StampMetaCan.Handle, aForm);
nrP:=wp.CommandEx(COMPDF_GetPageCount,0);
y:=WPCentimeterToPixel(28,72);
x:=WPCentimeterToPixel(1,72);
lst:=TStringlist.create;
lst.text:=strpas('Try write text on pdf');
idx:=0;
for n := lst.count - 1 downto 0 do
begin
StampMetaCan.TextOut(x,y-(15*(n+1)), lst[idx]);
inc(idx);
end;
lst.free;
finally
StampMetaCan.Free;
end;
wp.CommandStrEx(495,inttostr(nrP)+'-'+inttostr(nrP), StampMeta.Handle)
wp.Plus.SetSecurityMode(wpNoSecurity);
wp.Plus.SaveToFile('C:\tmp\test.pdf');
StampMeta.free;
end;
wp.free;
end;
Alles anzeigen
But in the new file created there is no trace of text.
Why?
Thanks