Paper size not as specified! Print to PDF

  • Follow


Hi,
I'm starting to get very frustrated about the print tools in Matlab. To illustrate my problem, I have the following code

I = rand(200,250,3);
imshow(I);
set(gcf,'PaperUnits','points');
set(gcf,'PaperSize',[250 200]);
print(gcf,'test.pdf','-dpdf');

i.e. I plot something with imshow, set the paper size to be 250 x 200 points and then print to 'test.pdf'. When I check the pdf in Acrobat Reader the size is 70.6 x 70.6 mm corresponding to 200 x 200 points.

Why is the paper size set to 200 x 200 instead of 250 x 200 as I have specified? If I fiddle around with the specified paper size, sometimes I get the correct size and sometimes I don't.

Any help is most welcome!
Regards,
Fredrik
0
Reply Fredrik 4/22/2010 7:27:24 PM

It seems that the pdf printer does not process the PaperSize settings properly. A workaround is to create an eps file first, and then convert it to pdf, e.g.:

function exportFigure(fileName, resolution)

print('-depsc2', sprintf('-r%d', resolution), [fileName '.eps']);
system( ...
sprintf( ...
'epstopdf --gsopt=-dPDFSETTINGS=/prepress --outfile=%s.pdf %s.eps', ...
fileName, fileName));
system(sprintf('del %s.eps', fileName)); % delete temporary .eps file

end
0
Reply Twan 3/5/2011 5:19:04 PM


1 Replies
496 Views

(page loaded in 0.24 seconds)

Similiar Articles:













7/22/2012 1:53:37 PM


Reply: