5
$\begingroup$

Exporting PDFs

While it is seemingly obvious how to export higher resolution pdf vector graphics:
https://mathematica.stackexchange.com/search?q=pdf+export+high+resolution

There is nothing to be found on exporting high resolution pdf vector graphics with a lower dimension:
https://mathematica.stackexchange.com/search?q=pdf+export+high+resolution+low+dimension

By this, I mean the export of a high-dpi-graphic, which will display as a certain physical length x width in adobe reader.

This is useful for the creation of scientific graphics and should be an easy task, but there does not seem to be a method to do so.

The impetus for this question is the following:

dataSE = Table[{t, Sin[2 t \[Pi]]}, {t, -10, 18, .0005}];
graphSE = ListLinePlot[dataSE, AspectRatio -> 1.2, 
PlotStyle -> {Thickness[0.007]}, ImageSize -> # 1.15, 
Axes -> False] &;
SEgraphs = graphSE /@ {72, 96, 150, 300}
Export[StringJoin[NotebookDirectory[], 
"\\SEgraphnotext" <> ToString[#] <> ".pdf"], graphSE[#]] & /@ {72, 96, 150, 300}

The issue can clearly be seen below:

Depiction of PDF Export Discrepency

How can we get a smooth output like that of SEgraphnotext300.pdf, which displays at a dimension of 4.79 x 5.75 in, but at the display size of SEgraphnotext72.pdf, which displays at the expected dimension of 1.15 x 1.39 in--in other words, how can we increase the dpi of the pdf export, dictate the physical dimensions of the image, while keeping the file size manageable, from within the WL?

For reference: SEgraphnotext72 stores as 170KB, while SEgraphnotext300 is 290KB, but we should be able to find them at 100KB or less, being such simplistic displays.

Is the understanding of how these graphics work just incorrect, or is there a solution to all of these issues wrapped up into a few easy commands in the WL?

Please note, the idealized output here is low file size, dictated physical dimensions, at a set dpi, in PDF format.

Can anyone make a suggested solution for this issue?

Many thanks, all!

$\endgroup$
8
  • $\begingroup$ Looks like Export makes some weird "optimization" when it is given an ImageSize either directly (Export[...,ImageSize->...]) or indirectly (when ImageSize is embedded in previously generated plot). Probably one way is to make smooth image of large size and then scale it down to the size required. Another observation: there is no such problems with ListPlot (only points, no joining lines), but this gives huge file size. $\endgroup$ – Alx Jul 19 '19 at 4:10
  • $\begingroup$ Thank you @Alx! I agree with your assessment on the higher sizing then rescaling it down, and it would be much easier to rasterize it, but I don’t think either of those options apply here—this is inevitably for a set of graphics within a dissertation that carries certain rules and regulations when it comes to requiring vector graphics with pdf formatting. If I can change the ratio of outputted image dimensions to the resolution, or resize in the Wolfram Language, this would be the preferred method. Maybe with a paid copy of adobe pdf editor? D; $\endgroup$ – CA Trevillian Jul 19 '19 at 5:57
  • 1
    $\begingroup$ I'm not sure I undestand you requirement on dpi for PDF images: PDF is a vector format, so it can be rasterized at any resolution and it can be scaled to any size. I may suppose if you deal with PDF format you probably work in LaTeX. It is of no problem to scale PDF figure to any size in LaTeX paper. If you are not working in LaTeX it also can be used to resize PDF image to desired size: make use of standalone class, place your figure with includegraphics and compile with pdflatex. $\endgroup$ – Alx Jul 19 '19 at 7:07
  • $\begingroup$ @Alx ah yes, you are correct, so there is no effect with ImageResolution due to their being vector graphics, but when you adjust ImageSize, you get the effects I show in this question. That is what is meant by the dpi, so the smoothest graphic at 300 dpi is what is desired. No LaTeX(or pdflatex) is being used this time, as it can often distort some smaller sized images like these, (and time is a limited resource) so wysiwyg methods are being used. Also, the need to not rasterize these graphics exist (so as to not do any post-editing of the data presentation). Tl;dr: University requirements. $\endgroup$ – CA Trevillian Jul 19 '19 at 11:56
  • 1
    $\begingroup$ Made some experiments with Inkscape, PDF and SVG formats, large and small sizes. In some cases rescaling in Inkscape leads to broken lines and other garbage in output, but when it has success the result is the same as in your first picture for small physical size (72). Also tried pdflatex with standalone class: in MMA exported large (300) picture in PDF, then \includegraphics[width=1.15in]{fig.pdf}. Very nice and smooth small image! For me it would be the way to go, but if you have no LaTeX and time ... Increasing number of points may give some improvements. $\endgroup$ – Alx Jul 19 '19 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.