# Tag Info

## Hot answers tagged pdf-format

68

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.

48

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 ...

46

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]

24

The suggestion to use Antialiasing->False doesn't really solve the problem. I don't have a single solution that's appropriate in all cases, but I think one of the approaches I list on the following web page will work: Avoiding artifacts in shaded contour and density plots Edit: The following method from the linked article solves the problem: Instead ...

23

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... ... 23 A simple workaround is to use Export instead of right clicking and choosing Save As ... The result will look like this: Much better. It's not clear to me why this difference exists between saving from the front end or using Export, but there is a significant difference in the quality of the output. Notice that the line widths are different too (the ... 22 Proof of the Szabolcs's idea: Graphics[{PointSize[0.001], Point@RandomReal[1, {1000, 2}]}, ImageSize -> 30] After Save As (28x28 grid): After Export Another workaround is printing the graphic to a file. 22 The better solution that I have found so far shown as below: SetOptions[ SelectedNotebook[], PrintingStyleEnvironment -> "Printout", ShowSyntaxStyles -> True] Response to Algohi's comment: This solution could also capture the errors style 22 The package and all code of this answer can be found on my GitHub account. A solution that takes only small amount of time is to follow this route: take the first usable java library for accessing and changing PDF files you find do one of the following: write a small amount of Java code to create a simple interface to the functionality (if you are ... 19 I actually like your own solution as a way to generalize the RegionPlot approach, and the answer by @tkott! Edit with improved version of RegionPlot trick Since @tkott's solution was still rough around the edges, I hacked together a version of it that should be able to emulate all the features of ContourPlot - i.e., be usable as a drop-in replacement with ... 16 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" ... 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 ... 15 Merging polygons in ContourPlot A seven-hour train ride and a coach with an electric outlet gave me an opportunity to implement a ContourPlot fixer. This method heavily relies on the precise structure of the output that ContourPlot produces. It relies on version 8 features, and I won't be surprised if it break in future versions. But it works pretty well ... 15 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 ... 14 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, ... 13 From the PDF file definitions (7.5.4 - 7.5.6) you don't need to modify the inner structure of a PDF file to make changes, its enough to append the new definitions of the components (New or old) and suitable cross-reference section with pointers to the shift positions of some relevant components for random access. Here I attempt some code to do all the work ... 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 One workaround I've discovered is to export as SVG, open in Inkscape, and save as PDF. The default parameters there (which I have not explored thoroughly) result in a PDF file size of 324KB. 12 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 ... 12 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 ... 12 I had the same problem after switching to Mathematica 10. The issue here is the following: Export uses Rasterize to create the png image. The StyleEnvironement, which is used in Rasterized, cannot be specified as an option but is given by the$FrontEnd object (not by the EvaluatingNotebook[]!). You can change the StyleEnvironement by SetOptions[\$FrontEnd, ...

12

Indeed, 3D plots like this were exported as vector graphics with generally huge numbers of polygons in version 8. But even then, the export was automatically rasterized whenever there were VertexColors present in the plot. I described this as a trick for getting smaller PDF files here, and also used it e.g. here. So in general, I think it's actually a good ...

11

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, ...

11

Surely this is a manifestation of the problem described in: Antialiasing option behaves weird (polygon edges visible in ContourPlot) Therefore, you should try using Style[plot, Antialiasing -> False] or other methods to disable anti-aliasing. The cause is as I thought but my suggestion Antialiasing -> False was naive as that would only affect the ...

11

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 ...

11

Why this happens? The reason for this behaviour is that Mathematica works with two kinds of units: plot coordinates---the same thing you see on the axes offset coordinates---these are in printer's points Plot coordinates scale with the figure: if you print the figure (or export to PDF) at twice the size, objects specified on plot coordinates double in ...

11

The reason why this overhang appears is that the Thickness of the line marking the edge of the Disk is not counted as something that needs to be clipped (although it should). The line itself (the center of the thick red line) is clipped correctly. But of course the result looks very clumsy, and it can only be eliminated if the line thickness is made as ...

11

This is actually a complex problem because different journals and papers have different names for the bibliography (e.g. "Bibliography" versus "References") and different referencing formats that are hard to parse. Also some papers put other material (e.g. appendices) after the bibliography rather than before. That said, here is something to get you ...

10

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", ...

10

You should investigate in the Scaled function: lots = GraphicsGrid[ Table[With[{a = RandomInteger[{1, 17}], b = RandomInteger[{1, 17}]}, ParametricPlot[Sin[t^2] {Cos[a t], Sin[b t]}, {t, 0, 2 \[Pi]}, PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True, ImageSize -> Scaled[1]]], {15}, {7}]]; Export["lots.pdf", lots]

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