An IDLgrPDF object saves Object Graphics output to a PDF file.

Superclasses


IDLitComponent

Creation


See IDLgrPDF::Init.

Properties


Objects of this class have the following properties. See IDLgrClipboard Properties for details on individual properties.

In addition, objects of this class inherit the properties of all superclasses of this class.

Methods


This class has the following methods:

IDLgrPDF::AddPage

IDLgrPDF::Clear

IDLgrPDF::Draw

IDLgrPDF::Init

IDLgrPDF::Save

In addition, this class inherits the methods of its superclasses (if any).

IDLgrPDF Properties


AUTHOR

The author metadata string for the document.

Property Type

STRING

Name String

Author

Get: Yes

Set: Yes

Init: Yes

Registered: Yes

CREATOR

The creator metadata string for the document.

Property Type

STRING

Name String

Creator

Get: Yes

Set: Yes

Init: Yes

Registered: Yes

DIMENSIONS

A two-element array in the form [width, height] to specify the physical dimensions of the plot on the page. The default is [8, 6].

Property Type

Integer vector

Name String

not displayed

Get: Yes

Set: Yes

Init: Yes

Registered: No

FONT_SCALE

A scalar value specifying the relative size of the text. The default value is 1.0. All text drawn to the device is rescaled by its value. Setting FONT_SCALE to 2.0 draws the font twice as large as the default; 0.5 half as large.

Property Type

FONT_SCALE

Name String

not displayed

Get: Yes

Set: Yes

Init: Yes

Registered: No

GRAPHICS_TREE

An object reference of type IDLgrScene, IDLgrViewgroup, or IDLgrView that specifies the graphic tree of this object. If this property is set to a valid object reference, calling the Draw method on the destination object with no arguments will cause the object reference associated with this property to be drawn. If this object is valid and the destination object is destroyed, this object reference will be destroyed as well. By default the GRAPHICS_TREE property is set equal to the null-object.

Property Type

Object reference

Name String

not displayed

Get: Yes

Set: Yes

Init: Yes

Registered: No

KEYWORDS

The keywords metadata string for the document.

Property Type

STRING

Name String

Keywords

Get: Yes

Set: Yes

Init: Yes

Registered: Yes

LINE_QUALITY

An integer value indicating the rendering quality of lines with a thickness greater than one pixel.

Valid values are:

Value Description
0 Low quality - this setting will result in faster performance, but it may introduce minor defects in the lines.
1 (default) High quality - this setting produces lines with clean joins at corners and intersections, but it may result in slower performance.

LOCATION

 A two-element array in the form [x, y] specifying the location on page (measured from the bottom-left corner) of any following draw operations. The default is [0.25, 2.5].

Property Type

Integer vector

Name String

Location

Get: Yes

Set: Yes

Init: Yes

Registered: No

RESOLUTION

A two-element array in the form [xres, yres] specifying the device resolution in centimeters per pixel. The default value is: [0.035277778, 0.035277778] (72 DPI).

Property Type

USERDEF

Name String

Resolution

Get: Yes

Set: Yes

Init: Yes

Registered: Yes

SUBJECT

The subject metadata string for the document.

Property Type

STRING

Name String

Subject

Get: Yes

Set: Yes

Init: Yes

Registered: Yes

TITLE

The title metadata string for the document.

Property Type

STRING

Name String

Title

Get: Yes

Set: Yes

Init: Yes

Registered: Yes

UNITS

An integer value that indicates the units of measure for the DIMENSIONS property. Valid values are:

  • 0 = Device
  • 1 = Inches (default)
  • 2 = Centimeters

Property Type

Integer

Name String

not displayed

Get: Yes

Set: Yes

Init: Yes

Registered: No

IDLgrPDF::AddPage


Adds a new page to the document.

Syntax


Obj->[IDLgrPDF::]AddPage [, DIMENSIONS=dims] [, /LANDSCAPE]

Keywords


DIMENSIONS

Set this keyword to a two-element array in the form [w, h] specifying the size of the page. Default is [8.5, 11].

LANDSCAPE

Set this keyword to a nonzero value to indicate that the page is in landscape orientation. Default is 0.

IDLgrPDF::Clear


This method clears the working PDF document in memory; after this operation the document contains no pages, just as after initial creation.

Syntax


Obj->[IDLgrPDF::]Clear

Keywords


None

IDLgrPDF::Draw


This method draws a given IDLgrView object to the current page. The view parameter may be omitted if the GRAPHICS_TREE property is set with a default view. If no pages have been added yet, this method returns an error.

Syntax


Obj->[IDLgrPDF::]Draw [, view] [, VECTOR={0,1}] [, VECT_SHADING={0,1}] [, VECT_SORTING={0,1}]

Arguments


View

The view (an instance of an IDLgrView object), viewgroup (an instance of an IDLgrViewgroup object), or scene (an instance of an IDLgrScene object) to be drawn.

Keywords


VECTOR

Set this keyword to indicate the type of graphics primitives generated. The default value is 1. Valid values are:

  • 0 = generate bitmap graphics. The bitmap retains the quality of the original image, but may not be effectively scaled on all devices. For example, a bitmap graphic retains the transparency and shading, but if you zoom in on a bitmap graphic, it may appear pixelated. This bitmap option creates much larger files than generating vector graphics.
  • 1 = generate vector graphics (default). Render the scene using simple vector operations that result in a representation of the scene that is scalable. The vector representation does not retain all the attributes of the original image, but it can be effectively scaled on other devices (without pixelation).

VECT_SHADING

This keyword has an effect only when generating vector output (VECTOR=1).

This keyword controls the appearance of smooth (Gouraud) shaded IDLgrPolygon and IDLgrSurface objects. Valid values are:

  • 0 = disable smooth shading. This causes all polygons and surfaces to be rendered with flat shading. This may result in much smaller files.
  • 1 = enable smooth shading (default). This renders smooth (Gouraud) shaded polygons and surfaces in the PDF file.

VECT_SORTING

This keyword has an effect only when generating vector output (VECTOR=1).

This keyword controls the way object primitives in a picture appear in the destination. Valid values are:

  • 0 = disable sorting. This causes the object primitives to appear in the vector output file in the same order they are drawn on the display device. This is the order in which they appear in the graphics tree.
  • 1 = enable sorting (default). Objects are ordered from back to front based on each primitive object’s average depth value.

IDLgrPDF::Init


Initializes the class with default values or any provided property values, and creates an empty document in memory.

Syntax


Obj = OBJ_NEW('IDLgrPDF' [, PROPERTY=value])

or

Result = Obj->[IDLgrPDF::]Init( [, PROPERTY=value])     (In a lifecycle method only.)

Return Value


When this method is called indirectly, as part of the call to the OBJ_NEW function, the return value is an object reference to the newly-created object.

When called directly within a subclass Init method, the return value is 1 if initialization was successful, or zero otherwise.

Arguments


None

Keywords


None

IDLgrPDF::Save


Saves the working PDF document in memory out to a file with the given name.

Syntax


Obj->[IDLgrPDF::]Save, filename

Arguments


Filename

The file name and location to save the PDF file.

Keywords


None

Example


This example creates some sample data to output to a PDF file. It then sets up the PDF pages and saves the output to PDF. You can copy the entire code example into the IDL editor, then save and run it. After it runs, view the example.pdf file in the current IDL directory.

PRO PDF_Example
 
; Create some data to plot
dataX = Findgen(200)
dataY = Sin(dataX*2*!PI/25.0)*Exp(-0.01*dataX)
 
; Set up the graphics tree
oModel    = OBJ_NEW('IDLgrModel')
oView     = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-50,-1.5,300,3])
oPlot     = OBJ_NEW('IDLgrPlot', dataX, dataY)
oXAxis    = OBJ_NEW('IDLgrAxis', 0, LOCATION=[0,-1], RANGE=[0,200], $
TICKINTERVAL=50, TICKDIR=1)
oYAxis    = OBJ_NEW('IDLgrAxis', 1, RANGE=[-1,1], TICKINTERVAL=0.5, $
TICKLEN=10, TICKDIR=1)
oTitle    = OBJ_NEW('IDLgrText', LOCATION=[100,1.2], ALIGNMENT=0.5)
oModel->Add, oPlot
oModel->Add, oXAxis
oModel->Add, oYAxis
oModel->Add, oTitle
oView->Add, oModel
 
oPDF = OBJ_NEW('IDLgrPDF')
 
; Add a PDF page.
oPDF->AddPage       ; Default layout is portrait, 8.5"x11"
oTitle->SetProperty, STRING='Page 1 - vector plot'
oPDF->Draw, oView
 
oPDF->SetProperty, UNITS=2, LOCATION=[2, 9], DIMENSIONS=[14, 10]
oPDF->AddPage, DIMENSIONS=[21.0, 29.7], /LANDSCAPE  ; A4 paper size
oTitle->SetProperty, STRING='Page 2 - This one is a vector plot'
oPDF->Draw, oView
 
oPDF->SetProperty, LOCATION=[15, 2], RESOLUTION=[2.54/300, 2.54/300]
oTitle->SetProperty, STRING='...and this one is rasterized at 300 DPI'
oPDF->Draw, oView, VECTOR=0
 
; Save the output to a PDF file in the current directory.
oPDF->Save, 'example.pdf'
 
END

Version History


8.0

Introduced

8.2 Added LINE_QUALITY property