MATLAB: How to change the paper size when I print to a PDF file in MATLAB 6.5 (R13)

customMATLABpaperpapersizepdfsize;

How do I change the paper size when I print to a PDF file in MATLAB 6.5 (R13)?
I am using MATLAB 6.5 (R13) on a UNIX operating system (Sun Solaris).
I have also been able to reproduce the same error on a Windows 2000 operating system.
I want to define a custom paper size when I print a figure to a PDF file. I use the following commands to change the paper size and Print to a PDF file.
 
plot(1:100)
set(gcf,'papersize',[6 8])
print -dpdf adobetest.pdf
When I run the code I get the following error.
  ERROR: ??? Error using ==> print Error using ==> d:/applications/matlab6p5/toolbox/matlab/graphics/private/ghostscript Problem calling GhostScript. System returned error: Unknown paper size: (<custom>). Unrecoverable error: stackunderflow in dup Unexpected interpreter error -17. Error object: (d84)name(0x98b088#388)dup Execution stack at 0x61cdc0: 0xa9d738: 0x0f oper –F—e– 0x0000 0x00462795 = %interp_exit 0xa9d740: 0x03 file –G-rxe– 0x0001 0x00a93d40 0xa9d748: 0x05 mpry –G-rxe– 0x0039 0x00ae6dc2 Dictionary stack at 0x61ce80: 0xa9df68: 0x02 dict –Gwrx— 0x0000 0x00a90088 0xa9df70: 0x02 dict –Gwrx— 0x0000 0x00af5540 0xa9df78: 0x02 dict –Lwrx— 0x005e 0x00a97f80 0xa9df80: 0x02 dict –Gwrx— 0x0000 0x00a90088 gsdll_init returns -17 DLL already in use Error in ==> S:\985588\user_code.m On line 12 ==> print -dpdf adobetest1.pdf

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This has been forwarded to our development staff for further investigation for a future release of MATLAB.
As a workaround, you can try one of the following:
1) Use the Handle Graphics property "PaperType" to specify a default paper size. However, this limits the paper size choices to one of the default values of "PaperType". More information on this property can be found at the following URL:
2) Define a custom paper size using a different format - such as EPS - and then convert it drectly to PDF using Ghostscript to produce a PDF file with the custom paper size.