Skip to content

Instantly share code, notes, and snippets.

@maxanier
Last active September 12, 2024 07:57
Show Gist options
  • Select an option

  • Save maxanier/12452923aeef67c7faf95d66e7f3d4ba to your computer and use it in GitHub Desktop.

Select an option

Save maxanier/12452923aeef67c7faf95d66e7f3d4ba to your computer and use it in GitHub Desktop.
TikzImageToPowerpoint - Batch convert Tikz images (or any PDF probably) to PowerPoint EMF using ghostscript and inkscape
@echo on
setlocal enabledelayedexpansion
set "inkscape_path=C:\Program Files\Inkscape\bin\inkscape"
::set "poppler_path=C:\Program Files (x86)\poppler-23.11.0\Library\bin\pdfseparate.exe" ::Could use poppler instead of GhostScript, but need GhostScript for Inkscape EMF anyways
set "gs_path=C:\Program Files\gs\gs10.02.1\bin\gswin64c.exe"
set "pdf_dir=pdf"
set "convert_dir=files"
cd %pdf_dir%
for %%i in (*.pdf) do (
set "input_file=%%i"
set "output_file=%convert_dir%/%%i_%%d.pdf"
::"%poppler_path%" "!input_file!" "!output_file!"
"%gs_path%" -dNOPAUSE -dBATCH -dQUIET -sDEVICE=pdfwrite -sOutputFile="!output_file!" "!input_file!"
)
cd %convert_dir%
for %%i in (*.pdf) do (
set "input_file=%%i"
set "output_file=!input_file:.pdf=.emf!"
"%inkscape_path%" --pdf-poppler --export-type=emf --export-filename "!output_file!" "!input_file!"
)
echo Conversion completed.
endlocal

PDF vector image to Powerpoint

The goal here is to conviniently get your nice Tikz vector graphics from your paper into PowerPoint without making screenshots of it.

Prequisites

How to get a image only PDF

You first need a PDF which only contains the desired images tightly cropped:

\documentclass{article}
\usepackage[active,tightpage]{preview}
\setlength{\PreviewBorder}{0pt}
\usepackage{tikz}
\PreviewEnvironment[{[]}]{tikzpicture}


\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}



%\usetikzlibrary{external}
%\tikzexternalize[prefix=tikz/]


\begin{document}

\input{content/fig/chip}
\input{content/fig/evm_all}
\input{content/fig/evm}
\input{content/fig/fsweep}
\input{content/fig/psweep}
\input{content/fig/sparam}
\input{content/fig/top_level_schematic}
\input{content/fig/schematic_wo_bias}
\input{content/fig/schematic_bias}
\input{content/fig/inductors}
\input{content/fig/tlines}

\end{document}

Usage

  1. Place the image PDF file in the pdf directory

  2. Run the script

  3. Drag and drop the .emf files from the convert directory to PowerPoint

Possible adjustments

Text Font

If you want to convert the Text elements to PowerPoint fonts and make them editable, remove the --pdf-poppler from the inkscape conversion line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment