Convert PDF with embedded fonts to EMF for PowerPoint

8,203

Solution 1

I had been facing the same problem as you: I had a number of .pdf files (two pages each) that I wanted to transform into something that I could import into a Word file; something just happened to be an .emf in the end (all other formats were not accepted).

This answer assumes you are comfortable in using the console.

The tool of choice to convert vector format X into vector format Y seems to be inkscape. However, when importing a .pdf file directly into inkscape

  • you can only access the first page on console (to the best of my knowledge)
  • even if you select the text-to-paths option flag -T, the text is not well-transformed.

Therefore, I found it necessary to pre-convert the .pdf file into something inkscape is able to use. I found this answer very useful, especially the mention of pdf2svg. My final sequence was the following:

pdf2svg input_filename.pdf interim_filename_%d.svg all
inkscape -T interim_filename_1.svg --export-emf=interim_filename_1.emf
(repeat for all additional pages of the .pdf)

To the best of what I can see on screen, transferring those .emf files to a Windows machine and opening them using the Windows image viewer, the result is identical to the input. Plus, having tried a test case with a custom-made LaTeX document using a font not present on my Windows machine, I also found the result identical. Skipping the initial pdf2svg step meant that the spacing was completely messed up after inkscape’s conversion.

In my case, I did not need to remove the .pdf page boundaries (I was dealing with full-page files). You may require such an intermediate step if you are interested in only a small part of the .pdf page. Pulling from this answer, pdfcrop seems to be able to do that.

Solution 2

Despite the title mentioning EMF, it sounds like the OP's actual goal is to include PDF files into PowerPoint while keeping everything as vector graphics, and EMF is only a means to do so, not an end. IguanaTex now supports import of vector graphics formats (PDF/PS/EPS/EMF) into PowerPoint.

Using IguanaTex also saves the user the trouble of preparing the EMF file for further editing. EMF files normally inserted in PowerPoint appear as pictures. They can be ungrouped into PowerPoint objects, but this creates extraneous shapes that need to be deleted. IguanaTex takes care of cleaning that up.

Internally, IguanaTex does in fact convert the PDF to EMF to then include it in PowerPoint. It does so using pdfiumdraw, which is part of TeX2img. The actual command is (see IguanaTex's source code on Github:

pdfiumdraw.exe --extent=50 --emf --transparent --pages=1 input.pdf

Full disclosure: I'm the developer of IguanaTex.

Share:
8,203
MvG
Author by

MvG

Dr. Martin von Gagern. Studied computer sciences, obtained a PhD in mathematics, currently a Google site reliability engineer.

Updated on September 18, 2022

Comments

  • MvG
    MvG over 1 year

    Is there a free (i.e. gratis) way to convert a PDF file to Windows EMF (Enhanced Meta File) in such a way that text which uses fonts embedded in the PDF will be rendered the same way in MS Office PowerPoint? I guess one would have to replace the text with a filled path, but that would be all right since I only want to show the result, not edit it.

    I tried pstoedit, but the font embedding seems to be tricky. Looking at the manual on font handling it seems as if -dt should turn text into filled paths, but in this case the paths are apparently really just polygons, connecting segment end points but not doing any Bézier curves in between. So the result looks strange, e.g. with diamonds as the dots of all the ‘i’.

    I've read in several places (e.g. here) that inkscape could be used to convert PDF to EMF. But on Windows the PDF import hangs without showing a dialog. On Linux, I get an import dialog but the only option for text handling is to leave text as text; I can't convert to paths so without the embedded fonts I'm forced to use system fonts instead.

    I've also tried ImageMagick convert, but that seems to rasterize the image so the result looks blurry.

    For one application, namely embedding LaTeX formulas into PowerPoint, this post suggests alternatives (at least some of which work via DVI instead of PDF, and MHTML instead of EMF. But there are many more tools which can create PDF but not EMF, so the general problem remains.

    I have access to Windows, Linux and OS X, so a suggested answer may use any combination of OS if that helps. If you don't have a complete solution, then a partial solution may still help. E.g. some PDF-to-PDF converter which replaces text with filled paths. Or some tool to extract fonts from PDF and save them in separate files, where other tools (like pstoedit or inkscape) might pick them up and use them to render the texts. Or anything else you consider a significant step towards a solution.

  • MvG
    MvG over 8 years
    I'm really looking for a scaleable vector WMF, not a raster PNG, so IguanaTex doesn't seem to fit my requirements. The standalone class is nice for its cropping, but not that different from calling pstoedit manually. On my system, the code you gave results in a message No output format specified (-f option) and format could not be uniquely deduced from suffix .wmf of output file followed by a list of supported formats which lacks wmf but contains emf. Using that instead, I get an EMF file which refers to fonts like CIWQJE+CMMI10. Won't work without the fonts in question.
  • josarn
    josarn almost 8 years
    maybe you have to update your pstoedit.
  • MvG
    MvG about 7 years
    Nice. I already had pdf2svg installed, but hadn't realized it can handle fonts. Looking at its output, I see that the glyphs from the font get expressed as <symbol>s in the svg. Bad for copy&paste, but good for font fidelity, so this is what I'm after here. Great!
  • NichtJens
    NichtJens about 5 years
    For me, inkscape always adds a small white margin (bottom and right side) in the svg to wmf step. It's not there in the svg. Any idea why? And how to suppress that?
  • Friedrich
    Friedrich over 3 years
    MS Word meanwhile has added support of .svg files, hence pdf2svg input_filename.pdf interim_filename_%d.svg all was sufficient to solve this for me
  • robit
    robit over 2 years
    I found from wiki.inkscape.org/wiki/Using_the_Command_Line, that the inkscape command should be inkscape -T interim_filename_1.svg --export-type="emf".