You are not logged in.
Pages: 1
I asked a friend to help
on his xe2, synpdf works no pb
i have xe7
and i copy pasted the event from him (that works)
procedure TForm1.ButtonPrintClick(Sender: TObject);
var
lPdf : TPdfDocumentGDI;
begin
lPdf := TPdfDocumentGDI.Create();
try
lPdf.AddPage;
lPdf.DefaultPaperSize := psA4;
Image1.Canvas.Rectangle(10,10,30,30);
lPdf.VCLCanvas.Draw(10,10,Image1.Picture.Graphic);
lPdf.SaveToFile('1.pdf');
lPdf.SaveToFile('c:\1.pdf');
finally
lPdf.Free;
end;
end;
It works ok in his case.
In my case, rectagle appears in Image1 on screen.
But blank pdf, same.
And, blank pdf appears only with first statement '1.pdf'
second statement doesnt work, 'c:\1.pdf'
did i find a bug, i dont understand what happens
Hi,
I have an TImage, and i fail to add its content to pdf.
this is my code up to now.
the first method with Printer, works.
but synPDF method gives an empty pdf file
Honestly, I am very confused about TImage, TPicture, TGraphic, TBitmap.
I never understood what's each of them's purpose.
And I'm just an amateur here and there programmer in pascal.
I would really love some help, i feel it's not something hard, but it's just my confusion mostly.
i followed this youtube tutorial:
https://www.youtube.com/watch?v=IJSVD-x9mpM
procedure TForm1.ButtonPrintClick(Sender: TObject);
var
ScaleX, ScaleY: Integer;
RR: TRect;
pdf: TPDFDocumentGDI;
begin
with Printer do
begin
BeginDoc;
try
ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
RR := Rect(0, 0, Image1.picture.Width * scaleX, Image1.Picture.Height * ScaleY);
Canvas.StretchDraw(RR, Image1.Picture.Graphic);
finally
EndDoc; //Methode EndDoc beendet den aktuellen Druckauftrag und schließt die
end;
end;
// ---- synPDF
//Image1.Picture.Metafile
pdf := TPDFDocumentGDI.Create();
try
pdf.AddPage;
pdf.DefaultPaperSize := psA4;
pdf.VCLCanvas.Draw(10,10,Image1.Picture.Graphic);
pdf.SaveToFile('pdftest.pdf');
finally pdf.Free;
end;
end;
Pages: 1