14

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.

3 Answers 3

18

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.

5
  • 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!
    – MvG
    Feb 7, 2017 at 8:38
  • 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?
    – NichtJens
    Feb 19, 2019 at 10:38
  • 1
    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
    – Friedrich
    Dec 21, 2020 at 15:12
  • 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".
    – robit
    Dec 31, 2021 at 0:57
  • I first used qpdf to slice my PDF into single pages for inkscape. But the result of inkscape (PDF to EMF) was not perfect (some fonts and images looked wrong). I then switched to pdf2svg, which delivered perfect SVGs. And I also realized that Word 2019 can already display SVGs. So no need to go further. So pdf2svg is the way to go, I think. Mar 4, 2023 at 18:04
3

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.

0

If you need to write formulars in PPT you could use IguanaTex Add-In for PPT.

It depends on a Latex Distribution and if you want to also generate Tikz Plots it will need ImageMagick. Which is used to convert the resulting PDF of PDFLatex to an PNG which looks fairly nice in the PPT.

If you need Higher Quality Pictures you can use the Standalone Class and use convert ( also needs ImageMagick). Here you can generate PNG or JPG with defined DPI. Or a PDF as Vector Format.

Or you can use Standalone and call pstoedit to generate WMF Files.

\documentclass[
   convert={command=\unexpanded{
     pstoedit\space-v \space -f\space emf \space convert.pdf \space convert.emf
   }}]{standalone}

seems you have to edit the output and input filename from hand.

2
  • 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.
    – MvG
    Sep 10, 2015 at 15:43
  • maybe you have to update your pstoedit.
    – josarn
    May 12, 2016 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .