Exporting figures as vector graphics in .pdf-format using HG2-Update and 'painters' renderer is not working properly

前端 未结 2 1846
梦谈多话
梦谈多话 2020-12-19 17:50

I\'m using the still undocumented HG2-Update to create my MATLAB plots, because they just look that much nicer.

2条回答
  •  [愿得一人]
    2020-12-19 18:31

    Exporting vector graphics using the yet not official HG2-Update is quite an issue. The .pdf-export is still totally screwed up. What is working fine is the .svg-export, apart from that the boundary box is not set properly.

    The long workaround would be: Save the plot with '-dsvg' (print-command) or 'svg' (saveas-command) as vector graphic, open the file in the open source application Inkscape and save again as .pdf with the Export area is drawing checkmark set.

    Quite complicated, so I found a way to do it via command-line directly from Matlab (Inkscape still required!):

    filename = 'test';
    inkscapepath = '"C:\Program Files (x86)\Inkscape\inkscape.exe"';
    
    %// save as .svg
    saveas(gcf,filename,'svg')
    %// open and save with "export-area-drawing" set via command line
    system( [inkscapepath ' ' filename ...
             '.svg --export-area-drawing --export-pdf=' filename '.pdf'])
    

    It takes some time, but works without any known issues for now.

    Additionally delete the svg-File afterwards:

    delete([filename '.svg'])
    

提交回复
热议问题