1. Home
  2. Foxit Quick PDF Library
  3. Programmatically convert EMF to PDF

Programmatically convert EMF to PDF

The ImportEMFFromFile function is designed specifically for importing EMF and WMF file formats. Delphi sample code provided below demonstrates how to use this function.

procedure TForm2.btnImportEMFFromFileClick(Sender: TObject);
var
FileName: string;
ImageID: Integer;
ImWidth: Integer;
ImHeight: Integer;
begin
    PDFLibrary := TDebenuPDFLibrary1113.Create;
  try
    UnlockResult := PDFLibrary.UnlockKey('INSERT LICENSE KEY');
    if UnlockResult = 1 then
    begin
      FileName := 'C:\Sample.EMF'
      ImageID := PDFLibrary.ImportEMFFromFile(FileName, 1, 0);
      PDFLibrary.SelectImage(ImageID);
      ImWidth := PDFLibrary.ImageWidth();
      ImHeight := PDFLibrary.ImageHeight();
      PDFLibrary.DrawImage(0, ImHeight, ImWidth, ImHeight);
      PDFLibrary.SetPageDimensions(ImWidth, ImHeight);
      PDFLibrary.SaveToFile('C:\Sample.PDF')
    end;
  finally
    PDFLibrary.Free;
  end;
end;

It is also possible to convert EMF to PDF using the AddImageFromFile function, sample code for doing this can be found in this knowledge base article: Convert an image to PDF programmatically.

Updated on March 22, 2018

Was this article helpful?

Related Articles

Ready to try Foxit PDF SDK?
Click the link below to download your trial
Free Trial