0

How to produce an postscript output in IDL such that the title window (i.e. the Title field in the header of the postscript file) is set to the filename or to an arbitrary string? By default, it is set to "Graphics produced by IDL":

%%Title: Graphics produced by IDL

Is is possible to change this from within IDL, without using scripts after the .ps is produced?


For reference, one may produce a .ps file in the following way. PRO test_2 device,decomposed=0 set_plot, 'ps' device,filename="~/filename.ps",/isolatin1,xsize=8.,ysize=10.5,inches=1,$ xoffset=0.25,yoffset=0.25,landscape=0 !p.font=0 device, /helvetica, font_size=7 ; a classic sans-serif font ; x = indgen(100) plot, x, sin(x) ; device,/close set_plot,'x' !p.thick=1 & !p.charthick=1 & !p.font=-1 & !x.thick=1 & !y.thick=1 END

Gene Arboit
  • 183
  • 1
  • 1
  • 11

2 Answers2

1

You could open it like a text file, find the line containing %%Title:, modify it, and write the new file out. I don't think there's an easier way to do it without using external programs.

sappjw
  • 373
  • 1
  • 14
  • That is exactly what I would like to avoid, since I have many files to process. Using a script to do this is indeed the backup plan. – Gene Arboit Jun 26 '14 at 13:55
  • 1
    I agree with sappjw, I don't think there is any way to do it directly. IDL doesn't have a very fancy postscript interface, and this is pretty low level. – Ajean Jun 26 '14 at 15:42
1

This is the nice thing about IDL - there is always a way!

After opening the PS-file with set_plot, do the following:

IDL> printf, 100, "%!PS-Adobe-3.0"
IDL> printf, 100, "%% Created with: IDL> "+(recall_commands())(0)
IDL> printf, 100, "%", form='(A0,$)'

The 1st line makes a new declaration that this is a PS-file. Check that this is the actual PS-version that your IDL version creates.

The 2nd line is your comment - this prints the command you used before opening the PS-file.

The 3rd line out-comments the PS-file declaration that IDL will print next. So there'll be two of those lines, with the second being a comment by way of the resulting "%%".

You might want to check that the LUN of PS-files is indeed 100. Good luck!

cchapman
  • 3,269
  • 10
  • 50
  • 68
AstroArtie
  • 34
  • 3
  • Indeed I get the error : "PRINTF: File unit is not open: 100." So I applied https://www.harrisgeospatial.com/docs/get_lun.html with OPENW instead to get the LUN and to write to file, and it works! – Gene Arboit May 30 '16 at 16:04