This shows you how you can use Microsoft Visio diagrams in LateX as vector diagrams. One may always save diagrams as JPG or PNG and use them in Latex. But to keep them freely resizable takes a bit more of work.
You need to do this in 2 steps:
1) Save as PDF: Visio doesn't directly let you save images as PDF. Instead one may use a PDF printer driver such as PrimoPDF. This is a free printer driver that one may install on Windows and it works rather well. Here is a the URL:
http://www.primopdf.com/
Once PrimoPDF is installed, you can selected a diagram in your Visio document and hit CTRL+P to print it. When the print dialog appears make sure that the current selection is only printed and that it prints to PrimoPDF. Once hit OK to print, PrimoPDF will pop up a dialog box asking for the filename of the pdf to be saved. Hence you generate a PDF from the Visio diagram.
Though this step seems a little elaborate, in practice this is only as much effort as saving an image selection to a file.
Update
As pointed out by Pandu in the comments, you can install 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS to help create a PDF out of the visio image, instead of intalling PrimoPDF. If you go this route, you will find an expore to PDF or XPS option under your file menu and you dont have to print to a PDF driver. (This approach maybe a little more tedious that the previous because you often want to save one image on your page, the selected one - if you choose to Print, the option for "selection" in on the print dialog box; if you choose to export to pdf, the option for "selection" is in a nested dialog box. (aah, the pleasure of GUIs))
The amount of effort involved is the same and step two hold regardless of what approach you choose. Thanks Pandu!
2) Including in the Tex file: You may include the PDF in a Tex file using the graphicx package. There are many handy online tutorials about this package. Each image is included in the latex file use a \includegraphic statement.
The real difficulty is this: The pdf file generated has the image at some position on the page. Including the whole file includes all of the white space on the page. This messes up the pdf you generate from the latex file. There are two possible solutions:
- Use a tool to remove whitespace: pdftrimwhite or pdfcrop might work. They are bot included with MikteX. Neither however worked for me as I couldn't get them to run. They both failed to run with the error: perl script not found. Does anyone know what the matter is? I have the latest ActivePerl in my path.
- Specify a Viewport: This is what worked for me. A viewport is a specification of what region of the pdf file to display in the latex document you are creating. Most websites I found tell you that you have to guess at the viewport - here is a better way.
You can use pdf2ps (ships with MikteX) to generate a ps file. If you open the ps file in a text editor, among the first few lines, you will see a comment about the bounding box.
%%BoundingBox: 28 779 142 809
This is the viewport information, you need on the basis on which you can type the command:
\includegraphics[viewport = 28 779 142 809]{file.pdf}
That's it. If this step seems a little tedious, here is a ruby script:
$stdin.each_line{|fn| fn = fn.strip if fn =~ /.*\.pdf/ `pdf2ps #{fn} #{fn}.ps` File.new(fn + ".ps").each_line{|line| if /%%BoundingBox: (.*)/i =~ line puts "\\includegraphics[viewport = #{$1}]{#{fn}}" break end } end }
You may use the script as follows:
> echo file.pdf | ruby pdfimage.rb\includegraphics[viewport = 28 779 142 809]{file.pdf}
If you use subcode, then you can abstract this whole step away into a filter and then just include pdf file directly into your latex and let it insert the viewport during compilation.
There you go. If you can help improvise on any of this, let me know.
Remember Me
a@href@title, strike
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Roshan James
E-mail