EMF to PDF as vector image

Images
7/12/2016

EMF is the Windows Meta file file format for images. More information on this file format can be found here. One of the advantages of the Windows Meta File is, that it is vector based and therefor the images are scalable. With the PDFkit tool it is possible to convert these EMF images to PDF or to include them in a PDF while preserving the scalability.

Sample: Convert EMF to PDF with MetafileShape

string intput = @"input.emf";
string output = @"output.pdf";

TallComponents.PDF.Shapes.MetafileShape shape = new TallComponents.PDF.Shapes.MetafileShape(input);
TallComponents.PDF.Document doc = new TallComponents.PDF.Document();
TallComponents.PDF.Page page = new TallComponents.PDF.Page(shape.Width, shape.Height);

doc.Pages.Add(page);
page.Overlay.Add(shape);

using (var file = new FileStream(output, FileMode.Create))
{
    doc.Write(file);
}

In rare and unforseeable occasions, these images may not be converted correctly. In that case it is possible to include the images in PDF as raster images. See our blogpost on EMF to PDF as a raster image.