Re: how to change the page size of pdf?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 26 Mar 2007 09:24:21 -0600

Xie Xin,

I have modified your code to use vp* resources to position and resize
your plots, rather than using gsn_panel to panel your plots. This is
necessary since your plots are different sizes.

In order to get some good vp* values to start with however, I went
and ahead and called gsn_panel with the additional resource
"panelres_at_gsnPanelDebug = True". This echos the X and Y position for
each plot, as well as the height and width. From this, I can find
some nice values to start with for vpXF, vpYF, vpHeightF, and vpWidthF.

I then increased the width and height of each plot the same amount by
applying a small scale factor to the vpWidthF/vpHeightF values. I
also adjusted the vpXF position for the second plot slightly.

Finally, to maximize all of this, I called an (as yet) undocumented
procedure "maximize_output".

Please give this new script a try. You may want to tweak the vp* and/
or scale values yourself.

Good luck,

--Mary

On Mar 24, 2007, at 8:41 AM, xiexin163_at_zju.edu.cn wrote:

>
> Hi,
>
> Thank you very much for your help.
> Oh, I just forgot to paste my code the last time.
>
> I noticed that the resource you mentioned in the mail
> gsnPanelXWhiteSpacePercent and gsnPanelYWhiteSpacePercent
> can adjust the white space between the plots but setting
> these two resoureces to 0 won't adjust the white space just out of
> the whole one plots(actually the margin). So I didn't use them in
> my code.
>
> The data is from the NCL web.
> My code is as followings:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> f = addfile("./data/sst8292a.nc", "r")
> T = f->SSTA
>
> wks = gsn_open_wks("pdf", "output")
>
> res = True
> res_at_cnFillOn = True
> res_at_gsnSpreadColors = True
> res_at_lbOrientation = "Vertical"
>
> res_at_gsnDraw = False
> res_at_gsnFrame = False
>
> plot1 = gsn_csm_contour_map(wks, T(1,:,:),res)
> plot2 = gsn_csm_contour_map(wks, T(2,:,:),res)
>
> a4_height = 29.7
> a4_width = 23
> cm_per_inch = 2.54
> panelres = True
> panelres_at_gsnPaperWidth = a4_width/cm_per_inch
> panelres_at_gsnPaperHeight = a4_height/cm_per_inch
> panelres_at_gsnMaximize = True
>
> gsn_panel(wks, (/plot1, plot2/),(/1,2/), panelres)
>
> end
>
> and I got output.pdf in the attachment.
> But when I open the this PDF with Acrobat Reader,
> I check the document properties and found that the page size
> is still 21.5cmx27.9cm(looks like letterpaper)
> but not 23cmx29.7cm as specified in gsnPaperWidth and
> gsnPaperHeight. There is too much margin
> in right and left sides of the plot.I tried to trim them and
> change the gsnPaperWidth to 10cm but when I open it it is still a
> 21.5cmx27.9cm one not 10cmx27.9cm. The only difference between
> the two is that the latter plot is on the left of page not like
> the former one(in the center). But there is still too much white
> space on the right this time.
>
> I doubt that the resource gsnPaperWidth does not actually change
> the page
> size but a virtual page size which is used to the position the plot
> is that so?
>
> I noticed that there have been many asking about solving this
> unwanted white space problem. But it seems that only external
> tools can solve this. The eps2eps or the ImageMagick convert
> tool with -trim option will trim the the area containing
> nothing. So they trim the unrelevant white space out of the
> plot which we usually do not need when we want to insert the
> plot into slides or documents.
>
> I wonder if there is a way to change the actual page size of PDF.
> If so, I can change it to a some like 10cmx29.7cm narrow one and
> set the gsnMaximize resource. Then the plot can fully fill the
> page, right?
>
> Another problem is that I found that wkOrientation does change the
> page orientation. However, the gsnPaperOrientation does not. Either
> "portrait" and "landscape" output are the same.
>
> I really appreciate your help!
>
> Xie Xin
>
> In your mail:
>> From: Mary Haley <haley_at_ucar.edu>
>> Reply-To:
>> To: xiexin163_at_zju.edu.cn
>> Subject: Re: how to change the page size of pdf?
>> Date:Mon, 19 Mar 2007 13:49:00 -0600
>>
>> Xie Xin,
>>
>> I would need to see your code, or, if this is not possible, then if
>> you could email me your PS or PDF file, then I will take a look at
>> it. I might be able to tell how to fix the white space problem.
>>
>> --Mary
>>
>> On Mar 19, 2007, at 9:22 AM, xiexin163_at_zju.edu.cn wrote:
>>
>>>
>>> Hi,Mary
>>>
>>> The advice you gave me:
>>>> The other thing that might work to trim white space is to use the
>>>> "-trim" option with the ImageMagick tool "convert"
>>> did work! It trims the unrelevant white space what I want to get
>>> rid of.
>>>
>>> But this method also depends on the ImageMagick to trim the white
>>> space.
>>> Is there any way to get rid of the white space directly without
>>> using any
>>> other softare package?
>>>
>>> Thank you very much!
>>>
>>> Xie Xin
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Mon Mar 26 2007 - 09:24:21 MDT

This archive was generated by hypermail 2.2.0 : Mon Mar 26 2007 - 09:25:27 MDT