Unit MainForm;

{$I ..\..\..\Lib\PDFlibDefines.inc}

Interface

Uses
{$IFDEF XE2+}
  Winapi.Windows,
  System.Classes,
  System.SysUtils,
  Vcl.Controls,
  Vcl.StdCtrls,
  Vcl.Forms,
  Vcl.Dialogs,
{$ELSE}
  Windows,
  Classes,
  SysUtils,
  Controls,
  StdCtrls,
  Forms,
  Dialogs,
{$ENDIF}
  PDFlibrary;

Type
  TForm1 = Class(TForm)
    btn1: TButton;
    Procedure btn1Click(Sender: TObject);
  Private
    { Private declarations }
  Public
    { Public declarations }
  End;

Var
  Form1: TForm1;

Implementation

{$R *.dfm}

Procedure TForm1.btn1Click(Sender: TObject);
Var
  FileName, StrMessage: String;
  ImageID: Integer;
  ImWidth: Integer;
  ImHeight: Integer;
Begin
  With TPDFlib.Create Do
  Begin
    FileName := 'Sample.emf';
    // CompressImages(1);
    ImageID := ImportEMFFromFile(FileName, 1, 1);
    // ImportEMFFromFile(FileName: WideString; FontOptions, GeneralOptions: Integer), see PDFlibReference page 518
    // GeneralOptions set to 1 means import as bitmap image, the result PDF usually smaller and not need invoke CompressImages
    SelectImage(ImageID);
    ImWidth := ImageWidth();
    ImHeight := ImageHeight();
    DrawImage(0, ImHeight, ImWidth, ImHeight);
    SetPageDimensions(ImWidth, ImHeight);
    SaveToFile('Sample.pdf');
      strMessage := 'Sample.pdf created' + chr(10) + 'Library version: ' + LibraryVersion + chr(10);
      MessageBox(Handle, PChar(strMessage), 'Information:', MB_OK or MB_ICONINFORMATION);
  End;
End;

End.
