Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
PDF orientation

Subject: PDF orientation

From: Andy McAllister

Date: 19 Sep, 2006 13:08:11

Message: 1 of 4

Hello, I searched, but did not find anything to solve my problem, so my
hope is someone here might have the answer.

I've got a plot which I want to save as PDF. I'd like the plot to be
landscape and saved to PDF.
%Command I use:
Orient landscape;
%Command to print to PDF:
print(figure_id, '-dpdf', figure_name);

Good news is, when I open my PDF, the plot is indeed landscape with
respect to the paper. But the paper itself is rotated 90 degrees CCW
(a portrait paper orientation, with the long edge of the paper being
vertical), which makes the plot hard to read once it's opened.


Question is: Is there any way I can save to PDF such that the ouput
file is oriented landscape, and the paper opens in a landscape
orientation when I open the PDF? I know Acrobat Pro can rotate, but I
have a million plots to create/view, and rotating them all at the
Matlab source would be a huge boon.

Thanks in advance.

Subject: PDF orientation

From: Scott Seidman

Date: 19 Sep, 2006 21:02:53

Message: 2 of 4

"Andy McAllister" <drsmartz@yahoo.com> wrote in
news:1158696490.937834.106680@k70g2000cwa.googlegroups.com:

> Hello, I searched, but did not find anything to solve my problem, so my
> hope is someone here might have the answer.
>
> I've got a plot which I want to save as PDF. I'd like the plot to be
> landscape and saved to PDF.
> %Command I use:
> Orient landscape;
> %Command to print to PDF:
> print(figure_id, '-dpdf', figure_name);
>
> Good news is, when I open my PDF, the plot is indeed landscape with
> respect to the paper. But the paper itself is rotated 90 degrees CCW
> (a portrait paper orientation, with the long edge of the paper being
> vertical), which makes the plot hard to read once it's opened.
>
>
> Question is: Is there any way I can save to PDF such that the ouput
> file is oriented landscape, and the paper opens in a landscape
> orientation when I open the PDF? I know Acrobat Pro can rotate, but I
> have a million plots to create/view, and rotating them all at the
> Matlab source would be a huge boon.
>
> Thanks in advance.
>

I've spent hours on similar problems, and in the long run solved it by
creating a new paper type in the print spooler that was 11x8.5 instead of
8.5x11, and printing portrait. There are probably a half dozen
combinations of where you can check landscape or portrait boxes, and I
can't remember which one worked. I re-solve the problem each time
(n=infinity learning!)

--
Scott
Reverse name to reply

Subject: PDF orientation

From: Peter Boettcher

Date: 19 Sep, 2006 18:24:32

Message: 3 of 4

"Andy McAllister" <drsmartz@yahoo.com> writes:

> Hello, I searched, but did not find anything to solve my problem, so my
> hope is someone here might have the answer.
>
> I've got a plot which I want to save as PDF. I'd like the plot to be
> landscape and saved to PDF.
> %Command I use:
> Orient landscape;
> %Command to print to PDF:
> print(figure_id, '-dpdf', figure_name);
>
> Good news is, when I open my PDF, the plot is indeed landscape with
> respect to the paper. But the paper itself is rotated 90 degrees CCW
> (a portrait paper orientation, with the long edge of the paper being
> vertical), which makes the plot hard to read once it's opened.
>
>
> Question is: Is there any way I can save to PDF such that the ouput
> file is oriented landscape, and the paper opens in a landscape
> orientation when I open the PDF? I know Acrobat Pro can rotate, but I
> have a million plots to create/view, and rotating them all at the
> Matlab source would be a huge boon.

I fought with this a while ago, and came up with the following
modification to MATLAB's ghostscript.m. You must restart after you
make the modification, and remember to save this for future versions.
Since it is in a private directory, it will not work to duplicate the
file in a different directory.

"which -all ghostscript" to find the location of the file

The modification is the following, to tell Ghostscript to output the
page in landscape mode. In R14, it goes at line 139, just after the
line that sets -sOutputFile, but before the line that closes rsp_fid.

if(strcmp(get(pj.Handles{1}, 'PaperOrientation'), 'landscape'))
  fprintf(rsp_fid, '-c "<</Orientation 3>> setpagedevice" -f\n');
end

I'll be interested to know if this works for you.

--
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/

Subject: PDF orientation

From: Heinrich Acker

Date: 20 Sep, 2006 07:32:41

Message: 4 of 4

Peter Boettcher wrote:
>
>
> "Andy McAllister" <drsmartz@yahoo.com> writes:
>
>> Hello, I searched, but did not find anything to solve my
problem,
> so my
>> hope is someone here might have the answer.
>>
>> I've got a plot which I want to save as PDF. I'd like the plot
> to be
>> landscape and saved to PDF.
>> %Command I use:
>> Orient landscape;
>> %Command to print to PDF:
>> print(figure_id, '-dpdf', figure_name);
>>
>> Good news is, when I open my PDF, the plot is indeed landscape
> with
>> respect to the paper. But the paper itself is rotated 90
degrees
> CCW
>> (a portrait paper orientation, with the long edge of the paper
> being
>> vertical), which makes the plot hard to read once it's opened.
>>
>>
>> Question is: Is there any way I can save to PDF such that the
> ouput
>> file is oriented landscape, and the paper opens in a landscape
>> orientation when I open the PDF? I know Acrobat Pro can
rotate,
> but I
>> have a million plots to create/view, and rotating them all at
the
>> Matlab source would be a huge boon.
>
> I fought with this a while ago, and came up with the following
> modification to MATLAB's ghostscript.m. You must restart after you
> make the modification, and remember to save this for future
> versions.
> Since it is in a private directory, it will not work to duplicate
> the
> file in a different directory.
>
> "which -all ghostscript" to find the location of the file
>
> The modification is the following, to tell Ghostscript to output
> the
> page in landscape mode. In R14, it goes at line 139, just after
> the
> line that sets -sOutputFile, but before the line that closes
> rsp_fid.
>
> if(strcmp(get(pj.Handles{1}, 'PaperOrientation'), 'landscape'))
> fprintf(rsp_fid, '-c "<</Orientation 3>> setpagedevice"
-f\n');
> end
>
> I'll be interested to know if this works for you.
>
> --
> Peter Boettcher <boettcher@ll.mit.edu>
> MIT Lincoln Laboratory
> MATLAB FAQ: <http://www.mit.edu/~pwb/cssm/>
>

I also like to create PDFs from my plots. The problems I had were
perhaps as well connected to Matlab's Ghostscript. Now I'm happy with
the following approach:

1) print with the -dpsc2 option (which means no Ghostscript according
to Matlab documentation. Orient landscape works as expected. It's
also nice to be able to create multi-page files.

2) use a free program to convert Postscript to PDF, which retains
properties of the Postscript file if done properly. I had good
success with freePDF, which is actually only a wrapper for
Ghostscript, but you have the choice which version of Ghostscript you
use.

Heinrich

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us