MATLAB: print the number in pdf format as shown in MATLAB

I am trying to export (save as, print) a shape in .pdf format. However, no matter how I adjust the setting, there are large margins in the figure.

When I export the shape to .eps format, there is no such problem, i.e. the shape just looks the way it is displayed in MATLAB.

How can I export a shape to a .pdf format that looks the same as in MATLAB?

+6
matlab figure export-to-pdf
source share
3 answers

You can try the following:

1) After you build the shape in MATLAB , go to "File-> Export Settings" and enter the size you want. For example, Width: 6 inches, Height: 5 inches. Then click the "Apply to Picture" button.

2) Do not close the "Export Settings" window. Go to "File-> Preview-> Paper", enter the same size in the width and height settings.

3) Do not close the Preview window. Return to the Export Settings window and click Export, then select the PDF format and save it.

4) Check the output PDF file, you will see that it is perfect.

I found a solution on the blog Export shape to PDF in MATLAB .

+3
source share

You can automate the process above by adding the following lines of code immediately after the plot command.

set(gcf,'Units','inches'); screenposition = get(gcf,'Position'); set(gcf,... 'PaperPosition',[0 0 screenposition(3:4)],... 'PaperSize',[screenposition(3:4)]); print -dpdf -painters epsFig 

The first two lines measure the size of your figure (in inches). The next line adjusts the paper size for printing according to the size of the shape. The last line uses the print command and exports the vector pdf document as output.

+5
source share

A two-line script for exporting to PDF in landscape orientation A4 (assuming that your graph is "current drawing"):

% ------------------------------------------------- ------------------

% change the paper size as landscape-A4 and move the picture accordingly

set (gcf, "PaperSize", [29.7 21.0], "PaperPosition", [0 0 29.7 21.0])

% export to PDF file 'YourFileName.pdf'

type -dpdf 'YourFileName'

% ------------------------------------------------- ------------------

Any other tweak: check the properties of Figure - just "get (gcf)" in the command window

0
source share

All Articles