Error printing plot to PDF
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to save a plot to PDF, but getting an error. In particular, I have a Windows 10 machine running MATLAB 2019a.
I try the following:
plot(1:10,1:10)
set(gcf,'Units','inches');
screenposition = get(gcf,'Position');
set(gcf,...
'PaperPosition',[0 0 screenposition(3:4)],...
'PaperSize',[screenposition(3:4)]);
print -dpdf -painters 20201027_temp
And get the error:
Error using print (line 82)
There was a problem while generating the output: Problem while processing in an OutputHelper.
.\20201027_temp.pdf (A device which does not exist was specified)
com.mathworks.hg.util.OutputHelperProcessingException: Problem while processing in an OutputHelper.
.\20201027_temp.pdf (A device which does not exist was specified)
at com.mathworks.hg.util.HGVectorOutputHelper.open(HGVectorOutputHelper.java:74)
Caused by: com.mathworks.hg.print.OutputProcessingException: .\20201027_temp.pdf (A device which
does not exist was specified)
at com.mathworks.hg.print.BaseVectorStrategy.open(BaseVectorStrategy.java:30)
at com.mathworks.hg.util.HGVectorOutputHelper.open(HGVectorOutputHelper.java:64)
When I try using a different Windows 10 machine running MATLAB 2018b, the same exact code runs without error. The issue is that I need to use the machine running 2019a due to better processing power. I can't figure out what might be causing this error. Any ideas? Thanks!
Réponses (1)
David Hill
le 27 Oct 2020
x=0:.01:2*pi;
y=sin(x);
plot(x,y);
plot2pdf('sin')
Simple function below generates pdf.
function plot2pdf(NAME)
fig = gcf;
fig.Units=fig.PaperUnits;
fig.PaperSize= [fig.Position(3) fig.Position(4)];
print(fig, NAME, '-dpdf' );
end
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!