Documentation

Report Configuration and Setup Commands

Report

new Report(Destination, Options)

Parameters



Report.x

Constants:

Please note; this actually returns the a ReportGroup object; not the Report object -- this is by design since creating a new Report creates the entire structure as such:

Example:

var MyReportObject = new Report("MyCoolReport.pdf", {autoPrint: true});
Would create the report called "MyCoolReport.pdf" and auto print it when it is opened in a pdf reader.




The functions below are methods on the above created and returned ReportGroup object...




.userData( Data )

Description

This allows you to set userData on the report that you might want at some later point in the report -- this is rarely used.

Parameters




.totalFormatter( function(data, callback(err, data) {}) {} )

Description

This allows you to set a formatting function to deal with any total values and formatting

Parameters




.data ( Data )

Description

THIS IS MANDANTORY - you need to set a data object otherwise there is no point to the report.

Parameters
Example:

MyReportObject.data([{id: 1, name: 'Nathanael'}, {id: 2, name: 'Anderson'}]);




.keys ( keys )

Description

This is so you can set a key or keys that get passed to sub-report data query functions/class objects.

Parameters
Example:

MyReportObject.keys("id");




.addReport( Report, options )

Description

This is used to add a sub-report; however you can use the easier method of "new Report(parentReport)" rather this "parentReport.addReport(x)"

Parameters




.info ( info )

Description

This allows you to set the pdf information and can be passed in as one of the Report(..., OPTIONS)

Parameters




.detail ( detailOutput )

Description

This is used so that the report system know how to output each detail record. This is used in most reports; but in some you might not need it.

Parameters




.titleHeader ( headerOutput, options )

Description

This is printed for the FIRST PAGE ONLY (if set); this prints first!

Parameters




.pageHeader ( headerOutput, options )

Description

This is printed for EVERY page except if the titleHeader is set, if the titleHeader is set then this header is skipped on the very first page; this prints first on the page!

Parameters




.header ( headerOutput, options )

Description

This is printed as the header object to any group objects. So while grouping you might need a header for who/what this is grouping on.

Parameters




.finalSummary ( footerOutput, options )

Description

This is printed as the footer object on the final page (if set).

Parameters




Description

This is printed as the footer object on all pages (except for the last page if the finalSummary is set).

Parameters




Description

This is printed as the footer object to any group objects. So while grouping you might need a footer for who/what this is grouping on.

Parameters




.outputType( type )

Description

This allows you to change the output type of the report; this is rarely used as when you create the report you set it at creation.

Parameters




.render(callback)

Description

This is what actually starts the rendering of the document when you are done setting it up with all these class methods.

Parameters




.printStructure ( asRendered )

Description

This prints out the structure of your report for debugging purposes to the console; it can see if you messed up your groupings or some other issues with your layout of the report.

Parameters




.landscape ( landscape )

Description

Gets or sets landscape or portrait mode, This can be passed in as a Report(..., OPTIONS)

Parameters




.paper ( paper )

Description

Gets or sets the paper size, This can be passed in as a Report(..., OPTIONS)

Parameters




.font ( font )

Description

This gets or sets the default font for the report, This can be passed in as a Report(..., OPTIONS)

Parameters




.fontSize ( size )

Description

This sets the Default font size for the report, This can be passed in as a Report(..., OPTIONS)

Parameters




.registerFont ( name, definition )

Description

This allows you to register a external font to use in your report

Parameters




.margins ( margins )

Description

This allows you to set all the margins or some of them, This can be passed in as a Report(..., OPTIONS)

Parameters




.autoPrint ( autoPrint )

Description

This will cause the print dialog to show up when you first open the pdf document, This can be passed in as a Report(..., OPTIONS)

Parameters




.fullScreen ( fullScreen )

Description

This will cause the pdf document to go to full screen on opening it up, This can be passed in as a Report(..., OPTIONS)

Parameters




.negativeParentheses ( negativeParentheses )

Description

This will print negatives as (20) rather than -20, This can be passed in as a Report(..., OPTIONS)

Parameters




.importPDF ( pdfFile )

Description

This will import the "pdfFile" into this report

Parameters

.groupBy ( field, options )

Description

This will allow you to create grouping on fields so that you can have group headers, footers, details for each group of records.
IMPORTANT: this will RETURN a brand NEW ReportGroup object, which will then allow you to customize it with any of these commands listed here. Please keep this in mind when doing function chaining.

Parameters




.sum ( field )

Description

This allows you to have a running Sum of the field; this value is propagated through the totals system allowing access to the correct total value per group.

Parameters




.min ( field )

Description

This allows you to have a running minimum value of the field; this value is propagated through the totals system allowing access to the correct total value per group.

Parameters




.max ( field )

Description

This allows you to have a running maximum value of the field; this value is propagated through the totals system allowing access to the correct total value per group.

Parameters




.count ( field )

Description

This allows you to have a running count of the field; this value is propagated through the totals system allowing access to the correct total value per group.

Parameters




.average ( field )

Description

This allows you to have a running average of the field; this value is propagated through the totals system allowing access to the correct total value per group.

Parameters





Rendering Commands

These commands are available to the header, title header, page header, page summary, page footer, footer, and detail functions while the report is running. The first object passed to your function is the ReportRenderer object; this object has the following methods you can run.

.image ( name, options )

Description

This displays a image on the current page

Parameters




.font ( name, [size] )

Description

This allow you to get or change the default font (and optionally change the font size)

Parameters




.fontSize ( [size] )

Description

This allows you to get or change the current font size

Parameters




.fontBold ( )

Description

This sets the font to be Bold; if the font supports Bold & Italic at the same time and you already have Italic set, it will set it to bold-italic.




.fontItalic ( )

Description

This sets the font to be Italic; if the font was already set to bold AND the font supports Bold and Italic it will add italic to the bold fond, otherwise it will just make it italic.




.fontNormal ( )

Description

This resets the font back to normal; eliminating any Bold and Italic attributes




.fillAndStroke ( fillColor, [strokeColor] )

Description

This sets the fill & stroke colors

Parameters




.fill ( [color] )

Description

Forces a fill with either the current color or the optionally provided color.

Parameters




.fillColor ( [color] )

Description

Gets or sets the fill color

Parameters




.fillOpacity ( [opacity] )

Description

Gets or sets the current fill opacity

Parameters




.strokeColor ( [color] )

Description

This set or gets the stroke color

Parameter




.setNegativeParentheses ( [negativeParentheses] )

Description

This is used to switch between -30 and (30) for display of negative numbers.

Parameters




.setMargins ( margins )

Description

This will allow you to override the default margins and set the margins for the NEXT page

Parameters




.paper ( [paper] )

Description

This allows you to get or change the paper for the NEXT page

Parameters




.landscape ( [landscape] )

Description

This allows you to get or change the landscape mode for the NEXT page

Parameters




.saveState ( )

Description

Allows you to save the current state of the engine -- This saves font, colors, and the x coordinate. This is a STACK, so you can save multiple states; and then restore them. Make sure any state you save you use a resetState or deleteState on afterwords, as the engine uses this code a lot to keep things correct.




.resetState ( )

Description

This resets the state of the engine to the last saved state in the saved stack.




.deleteState ( )

Description

This deletes the last saved state of the engine.




.hasChanges ( [includeHeader] )

Description

This can tell you if the page has any changes on it.

Parameters




.currentPage ( )

Description

this returns the current page that is being worked on.




.newPage ( [saveOptions], [callback] )

Description

This adds a new page for you to start working on. Please note; if you are using ASYNC functions then you must have a callback function for when the newPage is done, it will call your callback so you can continue.

Parameters




.standardHeader ( text, [callback] )

.standardFooter ( text, [callback] )

Description

This runs the standard header or footer code so you can keep the default header/footers but make some minor changes

Parameters




.getCurrentX ( )

.getCurrentY ( )

Description

This returns the current X or Y coordinate




.setCurrentX ( new )

.setCurrentY ( new )

Description

This sets the current X or Y coordinate

Parameters




currentX ( [new] )

currentY ( [new] )

Description

This sets or gets the current X or Y coordinates

Parameters




addX ( new )

addY ( new )

Description

This adds a number to either the X or Y coordinate

Parameters




newLine ( [count], [callback] )

Description

This adds a newLine or multiple new lines

Parameters




widthOfString ( string )

Description

This calculates how long this string will be with the current font and font size.

Parameters




heightOfString ( )

Description

This tells you how big a current string will be using the current font and font size; it doesn't actually need a string to tell you this as all string printed using this font & font size will use this space.




bandLine ( [thickness], [verticalGap] )

Description

This allow you to print a line the size of the last band command

Parameters




line ( startX, startY, endX, endY, options )

box ( startX, startY, endX, endY, options)

Description

This prints a line or box from startX,startY to endX,endY

Parameters




circle ( startX, startY, radius, options )

Description

This prints a circle from startX,startY using the radius

Parameters




lineWidth ( width )

Description

This sets or gets the gap between lines

Parameters




getLastBandWidth ( )

Description

Gets the last width of the band that was printed.




maxX ( )

maxY ( )

minX ( )

minY ( )

Description

This returns the minimum or maximum X or Y coordinate allowed.




printedAt ( options )

Description

This will print the date time at the current location or header or footer locations

Parameters




pageNumber ( options )

Description

This will print the current page number at the current location, or the header / footer locations

Parameters




importPDF ( name )

Description

Imports a PDF in the current location, if this page has any printing on it - it will end this page and import after it.

Parameters




Description

This is one of the primary methods to put any text of the page; you pass it your text and any options you want applied to the text

Parameters




band ( dataIn, options, callback )

Description

This is the other primary method of displaying data on a report; this creates bands of cells like a spreadsheet

Parameters




suppressionBand ( dataIn, options, callback )

Description

This is exactly the same as the band() command; other than it will skip printing any repeated data; so if row 1 has the name "Nathanael" and row 2 has the name "Nathanael" it will skip printing row 2's "Nathanael".

Parameters