Class RMDocument

  • All Implemented Interfaces:
    RMArchiver.Archiving, java.lang.Cloneable
    Direct Known Subclasses:
    RBDocument

    public class RMDocument
    extends RMShape
    The RMDocument class represents a ReportMill document and is also an RMShape subclass, so it can be a real part of the document/shape hierarchy. RMDocuments are also what ReportMill refers to as templates, and is commonly used like this:

       RMDocument template = RMDocument.getDoc(aSource); // Load from path String, File, byte array, etc.
       RMDocument report = template.generateReport(aDataset); // Any Java dataset: EJBs, custom classes, collctns, etc.
       report.writePDF("MyReport.pdf");
     

    On rare occasions, you may also want to create a document dynamically. Here's an example:

       RMDocument doc = new RMDocument(612, 792); // Standard US Letter size (8.5" x 11"), in points
       RMTable table = new RMTable(); // Create new table ...
       doc.getPage(0).addChild(table); // ... and add to first page
       table.setBounds(36, 36, 540, 680); // Position and size table
       table.getRow("Objects Details").getColumn(0).setText("Title: @getTitle@"); // Configure first text
     

    • Constructor Detail

      • RMDocument

        public RMDocument()
        Creates a plain empty document. It's really only used by the archiver.
      • RMDocument

        public RMDocument​(float aWidth,
                          float aHeight)
        Creates a document with the given width and height (in printer points).
      • RMDocument

        public RMDocument​(java.lang.Object aSource)
        Creates a new document from the given source (throws error if source was invalid).
    • Method Detail

      • getDoc

        public static RMDocument getDoc​(java.lang.Object aSource)
        Creates a new document from aSource (returns null if source is invalid).
      • getDocForPDF

        public static RMDocument getDocForPDF​(java.lang.Object aSource)
        Creates a new document from a PDF source.
      • getFilename

        public java.lang.String getFilename()
        Returns the filename associated with this document, if available.
      • setFilename

        public void setFilename​(java.lang.String aPath)
        Sets the filename associated with this document.
      • getVersion

        public float getVersion()
        Returns the version this document was loaded as.
      • getPageCount

        public int getPageCount()
        Returns the number of pages in this document.
        Overrides:
        getPageCount in class RMShape
      • getPage

        public RMPage getPage​(int index)
        Returns the page at the given index.
      • getPageLast

        public RMPage getPageLast()
        Returns the last page (convenience).
      • getPages

        public java.util.List getPages()
        Returns the list of RMPages associated with this document.
      • setPages

        public void setPages​(java.util.List aList)
        Sets the list of RMPages associated with this document.
      • addPage

        public void addPage​(RMPage aPage)
        Adds a given page to this document (at end).
      • addPage

        public void addPage​(RMPage aPage,
                            int anIndex)
        Adds a given page to this document (at the given index).
      • removePage

        public void removePage​(int anIndex)
        Removes the page at the given index from this document.
      • addPages

        public void addPages​(java.util.List aList)
        Add the given list of pages to this document (at end).
      • addPages

        public void addPages​(RMDocument aDoc)
        Add the pages in the given document to this document (at end) and clears the pages list in the given document.
      • addPageReferenceShapes

        public void addPageReferenceShapes​(RMDocument aDoc)
        Add the page reference shapes from given document to this document.
      • getSelectedPageIndex

        public int getSelectedPageIndex()
        Returns the current page index of this document.
      • setSelectedPageIndex

        public void setSelectedPageIndex​(int anIndex)
        Selects the currently selected page by index.
      • getSelectedPage

        public RMPage getSelectedPage()
        Returns the currently selected page of this document.
      • setSelectedPage

        public void setSelectedPage​(RMPage aPage)
        Selects the given page.
      • getPageLayout

        public byte getPageLayout()
        Returns the page layout for the document.
      • setPageLayout

        public void setPageLayout​(byte aValue)
        Sets the page layout for the document.
      • getDataSource

        public RMDataSource getDataSource()
        Returns the RMDataSource associated with this document.
      • setDataSource

        public void setDataSource​(RMDataSource aDataSource)
        Sets the RMDataSource associated with this document.
      • getDataSourceSchema

        public RMSchema getDataSourceSchema()
        Returns the schema for the RMDataSource associated with this document (convenience).
      • getUnit

        public int getUnit()
        Returns the units used to express sizes in the current document (POINTS, INCHES, CENTIMETERS).
      • setUnit

        public void setUnit​(byte aValue)
        Sets the units used to express sizes in the current document (POINTS, INCHES, CENTIMETERS).
      • getUnitString

        public java.lang.String getUnitString()
        Returns the units used to express sizes in the current document as one of the strings: point, inch or cm.
      • setUnitString

        public void setUnitString​(java.lang.String aValue)
        Sets the units used to express sizes in the current document with one of the strings: point, inch or cm.
      • getPointsFromUnits

        public float getPointsFromUnits​(float aValue)
        Converts given value from document units to printer points (1/72 of an inch).
      • getUnitsFromPoints

        public float getUnitsFromPoints​(float aValue)
        Converts given value to document units from printer points (1/72 of an inch).
      • getUnitsMultiplier

        public float getUnitsMultiplier()
        Returns the multiplier used to convert printer points to document units.
      • getShowGrid

        public boolean getShowGrid()
        Returns whether the document should show an alignment grid.
      • setShowGrid

        public void setShowGrid​(boolean aValue)
        Sets whether the document should show an alignment grid.
      • getSnapGrid

        public boolean getSnapGrid()
        Returns whether the document should snap to an alignment grid.
      • setSnapGrid

        public void setSnapGrid​(boolean aValue)
        Sets whether the document should snap to an alignment grid.
      • getShowMargin

        public boolean getShowMargin()
        Returns whether the document should show a margin rect.
      • setShowMargin

        public void setShowMargin​(boolean aValue)
        Sets whether the document should show a margin rect.
      • getSnapMargin

        public boolean getSnapMargin()
        Returns whether the document should snap to a margin rect.
      • setSnapMargin

        public void setSnapMargin​(boolean aValue)
        Sets whether the document should snap to a margin rect.
      • getMarginRect

        public RMRect getMarginRect()
        Returns the margin rect for this document.
      • setMarginRect

        public void setMarginRect​(RMRect aRect)
        Sets the margin rect for this document.
      • setMargins

        public void setMargins​(float left,
                               float right,
                               float top,
                               float bottom)
        Sets the margin rect for this document.
      • getMarginLeft

        public float getMarginLeft()
        Returns the margin rects left value.
      • getMarginRight

        public float getMarginRight()
        Returns the margin rects right value.
      • getMarginTop

        public float getMarginTop()
        Returns the margin rects top value.
      • getMarginBottom

        public float getMarginBottom()
        Returns the margin rects bottom value.
      • getGridSpacing

        public float getGridSpacing()
        Returns the grid spacing for the document's grid.
      • setGridSpacing

        public void setGridSpacing​(float aValue)
        Sets the grid spacing for the document's grid.
      • getPublishUrl

        public java.lang.String getPublishUrl()
        Returns the URL this document should be uploaded to.
      • setPublishUrl

        public void setPublishUrl​(java.lang.String aValue)
        Sets the URL this document should be uploaded to.
      • getNullString

        public java.lang.String getNullString()
        Returns the string used to replace any occurrances of null values in a generated report.
      • setNullString

        public void setNullString​(java.lang.String aValue)
        Sets the string used to replace any occurrances of null values in a generated report.
      • getPaginate

        public java.lang.Boolean getPaginate()
        Returns whether the document should paginate generated reports by default.
      • setPaginate

        public void setPaginate​(java.lang.Boolean aValue)
        Sets whether the document should paginate generated reports by default.
      • getCompress

        public boolean getCompress()
        Returns whether the document should compress images in generated file formats like PDF.
      • setCompress

        public void setCompress​(boolean aValue)
        Sets whether the document should compress images in generated file formats like PDF.
      • getCalibrateColors

        public boolean getCalibrateColors()
        Returns whether the document should calibrate colors in generated file formats like PDF.
      • setCalibrateColors

        public void setCalibrateColors​(boolean aValue)
        Sets whether the document should calibrate colors in generated file formats like PDF.
      • getDocListener

        public RMDocument.DocListener getDocListener()
        Returns the DocListener associated with this document.
      • setDocListener

        public void setDocListener​(RMDocument.DocListener aListener)
        Sets the DocListener associated with this document.
      • generateReport

        public RMDocument generateReport​(java.lang.Object objects)
        Returns a generated report from this template evaluated against the given object.
      • generateReport

        public RMDocument generateReport​(java.lang.Object objects,
                                         java.lang.Object userInfo)
        Returns a generated report from this template evaluated against the given object and userInfo.
      • generateReport

        public RMDocument generateReport​(java.lang.Object objects,
                                         boolean paginate)
        Returns a generated report from this template evaluated against the given object with an option to paginate.
      • generateReport

        public RMDocument generateReport​(java.lang.Object objects,
                                         java.lang.Object userInfo,
                                         boolean paginate)
        Returns generated report from this template evaluated against given object/userInfo (with option to paginate).
      • getBytes

        public byte[] getBytes()
        Returns the document as an XML byte array.
      • getBytesPDF

        public byte[] getBytesPDF()
        Returns the document as a byte array of a PDF file.
      • getBytesHTML

        public byte[] getBytesHTML()
        Returns the document as a byte array of an HTML file.
      • getBytesFlash

        public byte[] getBytesFlash()
        Returns the document as a byte array of a Flash file.
      • getBytesCSV

        public byte[] getBytesCSV()
        Returns the document as a byte array of a CSV file.
      • getBytesDelimitedAscii

        public byte[] getBytesDelimitedAscii​(java.lang.String fieldDelimiter,
                                             java.lang.String recordDelimiter,
                                             boolean quoteFields)
        Returns the document as a byte array of a delimited ASCII file (using given field, record separator strings).
      • getBytesJPEG

        public byte[] getBytesJPEG()
        Returns the document as byte array of a JPEG file.
      • getBytesPNG

        public byte[] getBytesPNG()
        Returns the document as byte array of PNG file.
      • getMapHTML

        public java.util.Map getMapHTML​(java.lang.String anImageRoot)
        Returns the document as a Map of an HTML file and image resources.
      • getStringCSV

        public java.lang.String getStringCSV()
        Returns the document as a string of a CSV file.
      • getStringDelimitedText

        public java.lang.String getStringDelimitedText​(java.lang.String fieldDelimiter,
                                                       java.lang.String recordDelimiter,
                                                       boolean quoteFields)
        Returns the document as a string of a delimited text file.
      • write

        public void write​(java.lang.String aPath)
        Writes the document out to the given path String (it extracts type from path extension).
      • writePDF

        public void writePDF​(java.lang.String fname)
        Writes the document to the given path String as PDF.
      • writeHTML

        public java.util.Map writeHTML​(java.lang.String fname)
        Writes the document to the given path String as HTML.
      • writeHTML

        public java.util.Map writeHTML​(java.lang.String fname,
                                       java.lang.String anImageRoot)
        Writes the document to the given path String as HTML (referenced images are written at the given relative path).
      • writeFlash

        public void writeFlash​(java.lang.String fname)
        Writes the document to the given path String as Flash.
      • writeFlashHTML

        public void writeFlashHTML​(java.lang.String fname)
        Writes the document to the given path String as Flash/HTML.
      • writeCSV

        public void writeCSV​(java.lang.String fname)
        Writes the document to the given path String as a CSV file.
      • writeDelimitedAscii

        public void writeDelimitedAscii​(java.lang.String fname,
                                        java.lang.String fieldDelimiter,
                                        java.lang.String recordDelimiter,
                                        boolean quoteFields)
        Writes the document to the given path String as a delimited ASCII file.
      • writeJPG

        public void writeJPG​(java.lang.String fname)
        Writes the document to the given path String as a JPEG file.
      • rebuild

        public void rebuild()
        Rebuilds the document according to the selected page and page layout.
      • getPageSize

        public RMSize getPageSize()
        Returns the size of a document page.
      • setPageSize

        public void setPageSize​(float aWidth,
                                float aHeight)
        Sets the size of the document (and all of its pages).
      • getMaxTime

        public float getMaxTime()
        Returns the total time needed to animate this document (total of all page animators).
      • getDocument

        public RMDocument getDocument()
        Returns the document itself (over-ridden from RMShape).
        Overrides:
        getDocument in class RMShape
      • getAnimator

        public RMAnimator getAnimator​(int anIndex)
        Returns the animator for a specific page.
      • getAnimatorLast

        public RMAnimator getAnimatorLast()
        Returns the animator for the last page.
      • getLoops

        public boolean getLoops()
        Returns whether the last animator loops.
      • getUndoer

        public RMUndoer getUndoer()
        Returns the RMUndoer for this document.
        Overrides:
        getUndoer in class RMShape
      • setUndoer

        public void setUndoer​(RMUndoer anUndoer)
        Sets the RMUndoer for this document.
      • undoerAddDirtyObject

        public void undoerAddDirtyObject​(RMObject anObj)
        Overrides RMShape implementation to actually add dirty object to notify doc listner and actually add to undoer.
        Overrides:
        undoerAddDirtyObject in class RMShape
      • willChange

        public void willChange​(RMShape aShape)
        This is a notification call-back for impeding shape attribute changes.
        Overrides:
        willChange in class RMShape
      • setNeedsRepaint

        public void setNeedsRepaint​(RMShape aShape)
        This is a notification call for impending visual shape attribute changes.
        Overrides:
        setNeedsRepaint in class RMShape
      • boundsChanged

        public void boundsChanged​(RMShape aShape)
        Notifies this shape that a given shape's bounds have changed (presumably a descendant).
        Overrides:
        boundsChanged in class RMShape
      • resolvePageReferences

        public void resolvePageReferences()
        Performs page substitions on any text fields that were identified as containing @Page@ keys.
      • equals

        public boolean equals​(java.lang.Object anObj)
        Standard equals implementation.
        Overrides:
        equals in class RMShape
      • clone

        public java.lang.Object clone()
        Copies basic document attributes (shallow copy only - no children or pages).
        Overrides:
        clone in class RMShape
      • cloneDeep

        public RMShape cloneDeep()
        Copies the complete document, including document pages and all their children.
        Overrides:
        cloneDeep in class RMShape
      • undoClone

        public RMObject undoClone()
        Returns a copy of the document for undo (page list is copied shallow).
        Overrides:
        undoClone in class RMShape
      • copy

        public void copy​(java.lang.Object anObj)
        Copies the attributes of the given object.
        Overrides:
        copy in class RMShape
      • superSelectable

        public boolean superSelectable()
        Editor method indicates that document is super selectable.
        Overrides:
        superSelectable in class RMShape
      • childrenSuperSelectImmediately

        public boolean childrenSuperSelectImmediately()
        Editor method indicates that pages super select immediately.
        Overrides:
        childrenSuperSelectImmediately in class RMShape
      • acceptsChildren

        public boolean acceptsChildren()
        Editor method indicates that document accepts children (should probably be false).
        Overrides:
        acceptsChildren in class RMShape
      • pdfBytes

        public byte[] pdfBytes()
        Obsolete method for old pdfBytes() method.