Class: PDF

PDF

A class for writing PDF files.


new PDF( [options])

Parameters:
Name Type Argument Description
options Mapspace.format.local.PDFOptions <optional>

PDF options.

Source:
mapspace/format/pdf.js

Extends

  • ol.Object

Methods


addBackground()

Adds a background to the PDF.

Source:
mapspace/format/pdf.js

addCopyright(copyright)

Adds a copyright in a footer.

Parameters:
Name Type Description
copyright string

Copyright.

Source:
mapspace/format/pdf.js

Adds Field logo to the PDF.

Source:
mapspace/format/pdf.js
Returns:

A promise that adds the Field logo.

Type
Promise

addHeader(title, date)

Adds title and date.

Parameters:
Name Type Argument Description
title string

Title.

date string <nullable>

Date. Optional. Default is current date.

Source:
mapspace/format/pdf.js

Adds Mapspace logo to the PDF.

Source:
mapspace/format/pdf.js
Returns:

A promise that adds the Mapspace logo.

Type
Promise

addPage( [format] [, orientation])

Adds (and transfers the focus to) new page to the PDF document.

Parameters:
Name Type Argument Description
format string <optional>

Format like in Mapspace.format.local.PDFOptions. Default is a4.

orientation string <optional>

Orientation, portrait / p or landscape / l. Default is portrait.

Source:
mapspace/format/pdf.js

addScreenShot(canvas, opt)

Adds an array of screenshots taken from viewers.

Parameters:
Name Type Argument Description
canvas HTMLCanvasElement

Canvas with a screenshot.

opt Object <nullable>

Optional options. An object with any of the following number properties: x, y, width, max_height; and the string property align that can be 'left', 'right' or 'center'.

Source:
mapspace/format/pdf.js

addSVGPath(path, color [, location] [, width])

Adds a path from an SVG. For now it only converts the following SVG path commands: M/m (move to), H/h (horizontal), V/v (vertical), L/l (line), C/c (Beziers curve), S/s (Smooth curve) and Z/z (close).

Parameters:
Name Type Argument Description
path string

SVG path.

color number | Array.<number> | string | undefined

If one number (0.0-1.0), a grey color; if array of three numbers (0-255), the RGB; if a string, a hexadecimal. By default is 0.7 grey color.

location Mapspace.Coordinate <optional>

Location x,y.

width number <optional>

Width.

Source:
mapspace/format/pdf.js

addTable(features, attributes)

Adds a table.

Parameters:
Name Type Description
features Array.<ol.Feature>

Features to show in the table.

attributes Array.<Object>

Attributes to show in the table.

Source:
mapspace/format/pdf.js

addTestText()

Adds a test page to the PDF.

Source:
mapspace/format/pdf.js

addViewerInfo(viewer, desc, opt)

Adds the info of a viewer.

Parameters:
Name Type Argument Description
viewer Mapspace.Viewer

Viewer.

desc string <nullable>

Optional description.

opt Object <nullable>

Optional options. An object with any of the following boolean properties: name, copyright, extent, center, x, y.

Source:
mapspace/format/pdf.js

getCanvasWidthHeight(canvas, width, max_height)

Returns the final height that will be applied when adding a screeshot.

Parameters:
Name Type Description
canvas HTMLCanvasElement

Canvas.

width number

Width to use.

max_height number

Maximum height allowed. If height exceeds this then width will be streched.

Source:
mapspace/format/pdf.js
Returns:

[width, height]

Type
Array.<number>

getTextsHeight(texts, width, lineHeightFactor)

Returns the expected height when adding some texts. Must be called after setting the font size and before adding the text.

Parameters:
Name Type Argument Description
texts Array.<string>

Texts.

width number <nullable>

Optional width for the text. Default is the current width of the page minus a margin of 1cm on both sides.

lineHeightFactor number <nullable>

Optional line height factor. Default is the current line height factor.

Source:
mapspace/format/pdf.js
Returns:
Type
number

writeFile(filename)

Writes the PDF to a file.

Parameters:
Name Type Description
filename string

File name.

Source:
mapspace/format/pdf.js