Foxit Quick PDF Library

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.

This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.

Updated on May 16, 2022

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: