#1 2010-09-12 20:49:11

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

How to add a bmp or jpeg format from a file.

In the example below, how can I import a jpg or bmp file?
I tried several form but got no success.

procedure TForm1.btn1Click(Sender: TObject);
var i: integer;
begin
  with TGDIPages.Create(self) do
  try
    // the title of the report
    Caption := self.Caption;
    // now we add some content to the report
    BeginDoc;
    // header and footer
    AddTextToHeader(paramstr(0));
    SaveLayout;
    Font.Style := [fsItalic];
    TextAlign := taRight;
    AddTextToFooterAt('http://synopse.info',RightMarginPos);
    RestoreSavedLayout;
    AddTextToFooter(DateTimeToStr(Now));
    // main content (automaticaly split on next pages)
    NewHalfLine;
    DrawTitle(edt1.Text,true);
    for i := 1 to 10 do
      DrawText('This is some text '+IntToStr(i));
    NewLine;
    AddColumns([10,20,50]);
    AddColumnHeaders(['#','Two','Three'],true,true);
    for i := 1 to 100 do
      DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'Some text here']);
    NewLine;
    DrawTitle('This is your text:');
    DrawText(mmo1.Text);
    EndDoc;
    // this method will show a preview form, and allow basic actions
    // by using the right click menu
    ShowPreviewForm;
  finally
    Free;
  end;
end;

Offline

#2 2010-10-03 09:04:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: How to add a bmp or jpeg format from a file.

Use TGDIPages.DrawBMP method.

Then when you export as PDF, select the following TPdfDocument property:

published
    /// this property can force saving all canvas bitmaps images as JPEG
    // - handle bitmaps added by VCLCanvas/TMetaFile and bitmaps added as TPdfImage
    // - by default, this property is set to 0 by the constructor of this class,
    // meaning that the JPEG compression is not forced, and the engine will use
    // the native resolution of the bitmap - in this case, the resulting
    // PDF file content will be bigger in size (e.g. use this for printing)
    // - 60 is the prefered way e.g. for publishing PDF over the internet
    // - 80/90 is a good ration if you want to have a nice PDF to see on screen
    // - of course, this doesn't affect vectorial (i.e. emf) pictures
    property ForceJPEGCompression: integer read fForceJPEGCompression write fForceJPEGCompression;

Offline

Board footer

Powered by FluxBB