#1 Re: PDF Engine » Convert a Jpeg file to pdf » 2010-09-03 10:12:52

I  modify the code :

procedure TForm1.Button2Click(Sender: TObject);
var
  testpdf:TPdfDocumentGDI;
  tmprect:TRect;
begin
  testpdf:=TPdfDocumentGDI.Create;
  try
    testpdf.NewDoc;
    try
      testpdf.AddPage;
      image1.Picture.LoadFromFile('c:\pictest.jpg');  //Image1: TImage;
      testpdf.ForceJPEGCompression:=30;
    tmprect.Left:=0;
    tmprect.Top:=0;
    tmprect.Bottom:=image1.Height;
    tmprect.Right:=image1.Width;
    testpdf.VCLCanvas.StretchDraw(tmprect,image1.Picture.Graphic);
   
    finally
      testpdf.SaveToFile('test.pdf');
    end;
  finally
    testpdf.Free;
  end;
end;


the file of test.pdf isn't correct(The size of test.pdf is only 1k and  Adobe Reader 9 can't open test.pdf);

#2 PDF Engine » how to open a pdf file and append some content? » 2010-09-03 09:45:44

fish
Replies: 2

I want to append a page to an exists pdf file ,how can i do?

#3 PDF Engine » Convert a Jpeg file to pdf » 2010-08-28 08:57:26

fish
Replies: 2

Hello:

      My software need convet some jpg file to a pdf file,i try it to use the code:

procedure TForm1.Button2Click(Sender: TObject);
var
  testpdf:TPdfDocumentGDI;
begin
  testpdf:=TPdfDocumentGDI.Create;
  try
    testpdf.NewDoc;
    try
      testpdf.AddPage;
      image1.Picture.LoadFromFile('c:\pictest.jpg');  //Image1: TImage;
      testpdf.VCLCanvas.Draw(0,0,image1.Picture.Graphic);
    finally
      testpdf.SaveToFile('test.pdf');
    end;
  finally
    testpdf.Free;
  end;
end;

but i don't know the way is correct?

btw: should write more example to show how to use the componet

Board footer

Powered by FluxBB