Tag Info

Hot answers tagged

44

My preferred method to export graphics to pdf is to do something like Export["figure.pdf", plot, "AllowRasterization" -> True, ImageSize -> 360, ImageResolution -> 600] This uses vectors for simple graphics, but produces a high resolution rasterized image if the plot becomes too complicated.


39

Before you step into the same traps I once stepped, let me point out some key-points. First of all two things: 1. although I spend some time digging in the subject, my knowledge is far from being complete, keep this in mind. 2. as everyone else around here, I would really like to have a fast, good-looking export of vector graphics too. Unfortunately, we have ...


28

The default style sheets set ShowSyntaxStyles -> False for the "Printout" environment. You could change the notebook to use a style sheet that doesn't set this. Probably the easiest way is to copy the definition from Default.nb, and modify it: Cell[StyleData[All, "Printout"], ShowSyntaxStyles->True]


15

Short answer: I hope Export["foo.pdf", plot,Background->None] fixes it. Let's get there step by step. First, Acrobat X Pro on my Mac reports that both your PDF files are fine. They print fine, and pass all tests with flying colors. I uncompressed the PDF (thanks pdftk) and a diff on them reveals that one weird object that only appears in your ...


13

This is because Mathematica exports to PDF in the Printout screen environment. If you change this to the working environment, it'll keep the syntax highlighting, but will also make everything a bit bigger: SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"] You can also change this setting from the GUI using Format -> Option Inspector... ...


12

Mathematica will normally embed the fonts correctly in a PDF. But this only works if the font exists. Papyrus does not have a bold weight. Try with FontWeight->"Bold" deleted and see if this works. I don't have Papyrus on my Windows machine, but I checked that Kristen ITC does not embed if it is bold, and does if the FontWeight option is removed.


12

For 3D graphics, I truly don't think it's worth the effort to attempt exporting as vector graphics. The valiant attempts to keep at least the axes and labels as vector graphics are in my opinion not something an everyday user would consider. With PDF for 3D graphics, you're fighting two problems: not just the file size but also the slow rendering when your ...


11

The "OperatorSubstitution" option does prevent the use of Mathematica fonts, but only for those cases where there were ASCII equivalents. So if your graphic contains expressions which use, for example, parentheses, brackets, braces, or various ASCII operators (plus, minus, asterisk, etc.), then the "OperatorSubstitution" is exactly what you want and you are ...


9

If it's really scanned images, then you could try this: pages = Import["yourfile.pdf", {"PDF", "Images"}] Otherwise, I'd suggest running the file through ghostscript or another distiller to clean up the potentially malformed PDF code first. The command would look like this: gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=newfile.pdf ...


9

One possible solution is to do as I suggested in this MathGroup post (see also the follow-ups). I think one can simplify it by doing the following: g = Graphics[{Inset[ Plot[10^5 x^2, {x, -2, 2}, Frame -> True, Axes -> None], ImageScaled[{0, 0}], ImageScaled[{0, 0}], ImageScaled[1]]}, ImageSize -> {400, 400}, PlotRange -> {{0, 1}, {0, ...


9

I suggest exporting to a raster format with high resolution. The ImageResolution option is very useful for controlling the resolution. I wrote a little tutorial on how to export images for LaTeX in this answer (since I would just repeat the same thing here, I am linking to it instead). Note: High resolution raster images will take up a lot of space, but ...


8

To make nicer PDFs, you could adapt the answer here as follows. Before making any plots, execute the command Map[SetOptions[#, Prolog -> {{EdgeForm[], Texture[{{{0, 0, 0, 0}}}], Polygon[#, VertexTextureCoordinates -> #] &[{{0, 0}, {1, 0}, {1, 1}}]}}] &, {Graphics3D, ContourPlot3D, ListContourPlot3D, ListPlot3D, ...


8

Please try adding some space around the plot: Plot[2 Sin[x] + x, {x, 0, 15}, Filling -> Bottom, ImageMargins -> 10] ImageMargins gives a margin around the existing plot that can be seen by selecting the graphic (the outer orange frame): By comparison ImagePadding is used by Plot itself to make room for the axes labels (the inner orange frame).


8

This is a problem with Preview, the PDF reader included in OS X. The problem does not show when using other PDF readers (not based on PDFKit) such as Adobe Reader. To prevent blurring you just need to untick the "Smooth text and line art" checkbox under "Viewing documents" in Preview's preferences: However, this will lower the quality of text and line ...


8

What Verbeia said in her answer is not entirely correct — Mathematica indeed does embed the font, regardless of whether a particular font weight/slant exists or not. The real culprits are the PDF viewers on Macs, which do not use the base font if the specified weight is not available. It took some digging around to get to the reason though. The clues that ...


7

Mathematica uses two differen sets of styles for displaying graphics on screen and for exporting: ScreenStyleEnvironment for displaying and exporting in raster formats and PrintingStyleEnvironment for printing and exporting to EPS and PDF formats (see here for more details). One way to achieve consistent export to PostScript is to set ...


7

Not knowing in what other external application you plan to process the exported PDF, I'm focusing mainly on the last paragraph of the question which asks for a way to outline fonts. To do this, you can simply define the function outlinedExport[name_, gr_, opts : OptionsPattern[]] := Export[name, First@ImportString[ExportString[gr, "PDF"], "PDF", ...


7

This issue seems to affect all PDFKit based viewers on OS X, but it doesn't appear to point to anything intrinsically wrong with Mathematica's PDF export. A work-around that allows you to view the exported PDF without color bands in PDFKit viewers such as Preview would be to use the following command when creating the PDF in Mathematica: Export["py.pdf", ...


7

You can adjust page size, page number style, headers, footers, etc from items under File -> Printing Settings menu. Or you can programmatically modify them by manipulating Notebook's options: PrintingCopies, PrintingStartingPageNumber, PrintingPageRange, PageHeaderLines, PageFooterLines, PrintingOptions. Note: It seems "PaperSize" and "PrintingMargins" ...


7

To get nice looking PDF export in this case is not easy. Export is really doing something wrong here. The best option I think would be to do the following: regionplot = RegionPlot[x^2 + y^2 < 1, {x, -1, 1}, {y, -1, 1}, PlotStyle -> Opacity[0.5, Black]]; Export["region.pdf", Show[regionplot, Prolog -> {Opacity[0], Texture[{{{0, 0, 0, ...


7

Please let me compile answers from the comments so that this topic can be marked as answered. Yes, this is a bug. A better solution than having rectangles of slightly different sizes and slightly larger than desired is to export the figure as EPS first and then convert it to PDF later. The cut corners are still there though.


7

You can export animations to SWF: movie = Animate[Plot[Sin[x + a], {x, 0, 10}], {a, 0, 5}]; Export["movie.swf", movie] You can import them in LaTeX (see TeX SE): \documentclass{article} \usepackage{media9} \begin{document} \includemedia[ activate=pageopen, width=405pt,height=292pt, ]{}{movie.swf} \end{document} (I had to insert ...


6

Update As @VCL pointed out in his comment, just exporting a list of graphics does not work since the braces and commas of the list a exported as well. Additionally, the pdf is one single page. Here is an updated approach, which takes all imported pdf-pages and inserts them into a new notebook where every page is separated by a pagebreak. The resulting pdf ...


6

This seems to be a problem with the "Preview" application from Mac OSX. Viewing both at 100%, Preview renders the points very large while Acrobat does not. I blame Preview. I'm not sure how to fix it for Preview only. This should be a comment but I can't post those yet. Using the built in "Save as PDF" dialog from the print menu works fine for me. ...


5

Solution The problem seems to be that the polygonal regions in the exported PDF file do not have edge strokes. It can be partially solved by reimporting the figure and correct this. (* FILENAME.pdf contains an exported BarChart3D figure *) (* 't' gives the desired edge thickness *) chart = Import["FILENAME.pdf"]; chart = chart /. {FaceForm[n__] :> ...


5

In my opinion you don't have many options here and honestly, I would not try to achieve this with Mathematica and Linux because the font-rendering was, is and will at least for some time be crappy. In the examples, I use the "Liberation Serif" which is the default serif font on my system. Let me give some ideas: The easiest thing I know is to use ...


5

The symbols { and [ are taken from the font "Mathematica2Mono" (decimal codes 56 and 64), symbol → (\[Rule] and \[RightArrow]) - from "Mathematica1Mono" (decimal code 174). You can easily see which symbols correspond to these codes in the standard ASCII table: FromCharacterCode[{174, 56, 64}] "®8@" You can display them using Mathematica font: ...


5

You can use Print@Row instead of Grid. However by default output cells have PageBreakWithin->False option. So you can avoid it by CellPrint@ExpressionCell[..., PageBreakWithin -> True]. Example: f[a_] := Plot[#[x], {x, 0, a}, AspectRatio -> 1, ImageSize -> 200] & /@ {Sin, Cos, Tan} f /@ {10, 30, 100} // Grid ...


4

This problem of not printing Exported PDFs originated when upgrading from version 7 to version 8. In version 7 it worked fine. In February 2011, I complained to Wolfram Research, as a Premier Service Member, but they could not fix this at the time. By trial and error I have stumbled upon a workaround. Export the graphics as a Postscript file: ...


4

Here is my original suggestion using ImagePadding: p = Plot[Cos[x], {x, 0, 2}, AxesStyle -> Arrowheads[.1], PlotRange -> {0, 1}, TicksStyle -> Large, RotateLabel -> False, ImagePadding -> 70] And here is an example of how to use ImageMargins in the plot command: p = Plot[Cos[x], {x, 0, 2}, AxesStyle -> Arrowheads[.1], ...



Only top voted, non community-wiki answers of a minimum length are eligible