Class PdfExporter

    • Field Detail

      • ACCOUNT_UNDERLINE_OFFSET

        protected static final float ACCOUNT_UNDERLINE_OFFSET
        See Also:
        Constant Field Values
      • _wb

        protected SBook _wb
      • _writer

        protected com.lowagie.text.pdf.PdfWriter _writer
      • _colBreaks

        protected int[] _colBreaks
      • _rowBreaks

        protected int[] _rowBreaks
      • _firstCol

        protected int _firstCol
      • _endCol

        protected int _endCol
      • _firstRow

        protected int _firstRow
      • _endRow

        protected int _endRow
      • _printCol1

        protected int _printCol1
      • _printCol2

        protected int _printCol2
      • _printRow1

        protected int _printRow1
      • _printRow2

        protected int _printRow2
      • _pageCount

        protected int _pageCount
      • _pageNumber

        protected int _pageNumber
      • _sheetName

        protected String _sheetName
      • _bookName

        protected String _bookName
      • _docStandardFont

        protected com.lowagie.text.Font _docStandardFont
      • _paperSize

        protected com.lowagie.text.Rectangle _paperSize
      • _totalHeaderFooterWidth

        protected double _totalHeaderFooterWidth
      • _leftMargin

        protected double _leftMargin
      • _rightMargin

        protected double _rightMargin
      • _topMargin

        protected double _topMargin
      • _bottomMargin

        protected double _bottomMargin
      • _headerMargin

        protected double _headerMargin
      • _footerMargin

        protected double _footerMargin
      • _totalPrintWidth

        protected double _totalPrintWidth
      • _totalPrintHeight

        protected double _totalPrintHeight
      • _repeatColLeft

        protected double[] _repeatColLeft
      • _repeatRowTop

        protected double[] _repeatRowTop
      • _colLeft

        protected double[] _colLeft
      • _rowTop

        protected double[] _rowTop
      • _repeatColLeftPx

        protected int[] _repeatColLeftPx
      • _repeatRowTopPx

        protected int[] _repeatRowTopPx
      • _colLeftPx

        protected int[] _colLeftPx
      • _rowTopPx

        protected int[] _rowTopPx
      • _currentSheetIndex

        protected int _currentSheetIndex
      • _currentShiftX

        protected double _currentShiftX
      • _currentShiftY

        protected double _currentShiftY
      • _firstPage

        protected boolean _firstPage
      • _currentSheet

        protected SSheet _currentSheet
      • _titleCol1

        protected int _titleCol1
      • _titleCol2

        protected int _titleCol2
      • _titleRow1

        protected int _titleRow1
      • _titleRow2

        protected int _titleRow2
      • _printGridlines

        protected boolean _printGridlines
      • _printHeadings

        protected boolean _printHeadings
      • _hcenter

        protected boolean _hcenter
      • _vcenter

        protected boolean _vcenter
      • _customPaperSize

        protected com.lowagie.text.Rectangle _customPaperSize
      • _scale

        protected int _scale
      • _pageRow1

        protected int _pageRow1
      • _pageRow2

        protected int _pageRow2
      • _pageCol1

        protected int _pageCol1
      • _pageCol2

        protected int _pageCol2
      • ZSS_IGNORE_COLUMN_BREAK_PROPERTY_KEY

        protected static final String ZSS_IGNORE_COLUMN_BREAK_PROPERTY_KEY
        See Also:
        Constant Field Values
    • Constructor Detail

      • PdfExporter

        public PdfExporter()
    • Method Detail

      • export

        public void export​(SBook book,
                           File file)
                    throws IOException
        Description copied from interface: SExporter
        Export a book
        Specified by:
        export in interface SExporter
        Parameters:
        book - the book to export
        file - the output file to store data
        Throws:
        IOException
      • export

        public void export​(SSheet worksheet,
                           OutputStream outputStream)
                    throws IOException
        Exports Keikai Spreadsheet SSheet into another format written to a
        Parameters:
        worksheet - sheet instance that contains selected area
        outputStream - outoutStream to which exported contents to be written
        Throws:
        IOException
      • export

        public void export​(SheetRegion sheetRegion,
                           OutputStream outputStream)
                    throws IOException
        Exports selected area of Keikai Spreadsheet active sheet represented by io.keikai.model.sys.XRange
        Parameters:
        worksheet - sheet instance that contains selected area
        area - area representing selected area to be exported
        outputStream - outoutStream to which exported contents to be written
        Throws:
        IOException
      • throwIOException

        protected void throwIOException​(com.lowagie.text.ExceptionConverter ex)
                                 throws IOException
        Throws:
        IOException
      • setupExporter

        protected com.lowagie.text.Document setupExporter​(SSheet sheet,
                                                          OutputStream outputStream,
                                                          com.lowagie.text.Document document)
                                                   throws com.lowagie.text.DocumentException
        Parameters:
        outputStream -
        Throws:
        com.lowagie.text.DocumentException
      • printScalePages

        protected void printScalePages​(float scale,
                                       com.lowagie.text.Document doc,
                                       byte[] pdfIn)
                                throws IOException
        Throws:
        IOException
      • normalizeScale

        protected int normalizeScale​(int scale)
      • prepareFitPageScale

        protected int prepareFitPageScale​(SSheet sheet,
                                          int fitWidth,
                                          int fitHeight)
      • prepareScaleY

        protected int prepareScaleY​(SSheet sheet,
                                    int fitHeight)
      • prepareScaleX

        protected int prepareScaleX​(SSheet sheet,
                                    int fitWidth)
      • exportSheetSelection

        protected void exportSheetSelection​(SSheet sheet,
                                            int sheetIndex,
                                            CellRegion area,
                                            com.lowagie.text.Document doc)
                                     throws com.lowagie.text.DocumentException,
                                            IOException
        converts POI SSheet to Pdf page(s)
        Parameters:
        sheet -
        Throws:
        com.lowagie.text.DocumentException
        IOException
      • initRowColumnPositions

        protected void initRowColumnPositions​(SSheet sheet)
      • exportSheet

        protected void exportSheet​(SSheet sheet,
                                   int sheetIndex,
                                   com.lowagie.text.Document doc)
                            throws com.lowagie.text.DocumentException,
                                   IOException
        converts POI SSheet to Pdf page(s)
        Parameters:
        sheet -
        Throws:
        com.lowagie.text.DocumentException
        IOException
      • getPictureData

        protected void getPictureData​(SSheet sheet)
        retrieve all zkpictures for given sheet
        Parameters:
        sheet -
      • prepareRowBreaks

        protected void prepareRowBreaks​(SSheet sheet,
                                        boolean ignoreManualBreaks)
        Sets column/row breaks if not defined already
        Parameters:
        sheet -
      • prepareColBreaks

        protected void prepareColBreaks​(SSheet sheet,
                                        boolean ignoreManualBreaks)
      • setupRowBreaks

        protected void setupRowBreaks​(SSheet sheet)
        sets auto row breaks based on row heights and available total page height
        Parameters:
        sheet -
      • setupColumnBreaks

        protected void setupColumnBreaks​(SSheet sheet)
        sets auto column breaks based on column width and available page width
        Parameters:
        sheet -
      • isColPageBreak

        protected boolean isColPageBreak​(int col)
      • isRowPageBreak

        protected boolean isRowPageBreak​(int row)
      • convertIntegers

        protected static int[] convertIntegers​(List<Integer> integers)
        converts List to primitive int[]
        Parameters:
        integers -
        Returns:
      • setCustomPaperSize

        protected void setCustomPaperSize​(float width,
                                          float height)
      • initDocument

        protected void initDocument​(SSheet sheet,
                                    com.lowagie.text.Document doc)
        Set pdf page common properties such as margins and document standard font
        Parameters:
        SSheet - sheet
      • initDocumentForSheet

        protected void initDocumentForSheet​(SSheet sheet,
                                            com.lowagie.text.Document doc)
      • printSheet

        protected void printSheet​(SSheet sheet,
                                  com.lowagie.text.Document doc)
                           throws com.lowagie.text.DocumentException,
                                  IOException
        Throws:
        com.lowagie.text.DocumentException
        IOException
      • printPage

        protected void printPage​(int bRow,
                                 int eRow,
                                 int bCol,
                                 int eCol,
                                 SSheet sheet,
                                 com.lowagie.text.Document doc)
                          throws com.lowagie.text.DocumentException
        Throws:
        com.lowagie.text.DocumentException
      • printRow

        protected void printRow​(com.lowagie.text.pdf.PdfPTable pdfTable,
                                int rowIdx,
                                int bRow,
                                int eRow,
                                int bCol,
                                int eCol,
                                SSheet sheet,
                                float rowHeight,
                                CellRegion outlineRegion)
      • printCell

        protected int printCell​(com.lowagie.text.pdf.PdfPTable pdfTable,
                                int rowIdx,
                                int colIdx,
                                SSheet sheet,
                                double rowHeight,
                                int bRow,
                                int eRow,
                                int bCol,
                                int eCol,
                                CellRegion outlineRegion)
      • createEmptyRowSpanCell

        protected com.lowagie.text.pdf.PdfPCell createEmptyRowSpanCell​(SSheet sheet,
                                                                       CellRegion outlineRegion,
                                                                       double rowHeight,
                                                                       CellRegion renderRegion,
                                                                       int rowIdx,
                                                                       int colIdx,
                                                                       boolean printOutline,
                                                                       boolean printGridline)
      • splitRegionsInBoundaries

        protected CellRegion splitRegionsInBoundaries​(CellRegion region,
                                                      int bRow,
                                                      int eRow,
                                                      int bCol,
                                                      int eCol)
      • getExtendRegion

        protected CellRegion getExtendRegion​(int rowIdx,
                                             int colIdx)
      • addExtendRegion

        protected void addExtendRegion​(CellRegion region)
      • createPdfTable

        protected com.lowagie.text.pdf.PdfPTable createPdfTable​(int bCol,
                                                                int eCol,
                                                                SSheet sheet)
                                                         throws com.lowagie.text.DocumentException
        Throws:
        com.lowagie.text.DocumentException
      • printColHeadings

        protected void printColHeadings​(com.lowagie.text.pdf.PdfPTable pdfTable,
                                        int bCol,
                                        int eCol,
                                        float rowHeight)
      • printColHeadingCell

        protected void printColHeadingCell​(com.lowagie.text.pdf.PdfPTable pdfTable,
                                           int colIdx,
                                           float rowHeight)
      • printRowHeadingCell

        protected void printRowHeadingCell​(com.lowagie.text.pdf.PdfPTable pdfTable,
                                           int rowIdx,
                                           float rowHeight)
      • printHeadingCell

        protected void printHeadingCell​(com.lowagie.text.pdf.PdfPTable pdfTable,
                                        com.lowagie.text.Phrase p,
                                        float rowHeight)
      • preparePageXYInfo

        protected double[] preparePageXYInfo​(SSheet sheet,
                                             int bRow,
                                             int eRow,
                                             int bCol,
                                             int eCol)
      • printImage

        protected void printImage​(com.lowagie.text.pdf.PdfContentByte canvas,
                                  byte[] rawData,
                                  ViewAnchor anchor1,
                                  ViewAnchor anchor2,
                                  CellRegion clipRegion,
                                  CellRegion renderRegion,
                                  double pageColumnX,
                                  double pageRowY,
                                  double clipOffsetX,
                                  double clipOffsetY,
                                  boolean outline)
                           throws IOException
        Throws:
        IOException
      • drawShapeBorder

        protected void drawShapeBorder​(com.lowagie.text.pdf.PdfContentByte lineCanvas,
                                       float lineWidth,
                                       float x1,
                                       float y1,
                                       float x2,
                                       float y2)
      • layoverPictureIfAny

        protected void layoverPictureIfAny​(SSheet sheet,
                                           int bRow,
                                           int eRow,
                                           int bCol,
                                           int eCol,
                                           com.lowagie.text.pdf.PdfWriter writer)
                                    throws IOException
        lays images over PdfTable
        Parameters:
        sheet -
        bRow -
        eRow -
        bCol -
        eCol -
        Throws:
        IOException
      • cropImage

        protected com.lowagie.text.Image cropImage​(com.lowagie.text.Image image,
                                                   float origWidth,
                                                   float origHeight,
                                                   com.lowagie.text.pdf.PdfWriter writer,
                                                   float x,
                                                   float y,
                                                   float width,
                                                   float height)
                                            throws com.lowagie.text.DocumentException
        Throws:
        com.lowagie.text.DocumentException
      • layoutCharts

        protected void layoutCharts​(SSheet sheet,
                                    int bRow,
                                    int eRow,
                                    int bCol,
                                    int eCol,
                                    com.lowagie.text.pdf.PdfWriter writer)
                             throws IOException
        Throws:
        IOException
      • getMergedRegionIfAny

        protected CellRegion getMergedRegionIfAny​(SSheet sheet,
                                                  int rowIdx,
                                                  int colIdx)
        returns merged region cell range for a given cell
        Parameters:
        sheet -
        cell -
        Returns:
      • isPartOfMergedRegion

        protected boolean isPartOfMergedRegion​(SSheet sheet,
                                               SCell cell)
        checks if POI Cell is part of any merged regions on the passed SSheet
        Parameters:
        SSheet - sheet
        Cell - cell
        Returns:
        boolean
      • createPdfCell

        protected com.lowagie.text.pdf.PdfPCell createPdfCell​(CellRegion clipRegion,
                                                              CellRegion renderRegion,
                                                              SCell zssCell,
                                                              CellRegion outlineRegion,
                                                              SSheet sheet,
                                                              boolean printGridLines,
                                                              boolean printOutline,
                                                              boolean extended)
        creates a PdfCell from POI Cell
        Parameters:
        zssCell -
        Returns:
        PdfCell
      • prepareClipInfo

        protected io.keikai.model.impl.pdf.RenderInfo prepareClipInfo​(CellRegion clipRegion)
      • prepareRenderInfo

        protected io.keikai.model.impl.pdf.RenderInfo prepareRenderInfo​(CellRegion clipRegion,
                                                                        CellRegion renderRegion,
                                                                        boolean extended,
                                                                        boolean number)
      • getRegionWidth

        protected double getRegionWidth​(CellRegion region)
      • getRegionHeight

        protected double getRegionHeight​(CellRegion region)
      • createPhrase

        protected Object[] createPhrase​(SCell zssCell)
        creates Phrase for corresponding ZSS Cell. If contents are RichString Phrase is constructed out of several Chunk object each representing different sections of rich text.
        Parameters:
        zssCell -
        Returns:
      • createPdfCellFont

        protected com.lowagie.text.Font createPdfCellFont​(SFont zssFont)
        returns pdf font corresponding to ZSS cell font
        Parameters:
        zssFont -
        Returns:
      • createPdfCellFont

        protected com.lowagie.text.Font createPdfCellFont​(SFont zssFont,
                                                          String fontName)
        Returns pdf font corresponding to ZSS cell font with a supplimental font face name.
        Parameters:
        zssFont -
        fontName -
        Returns:
      • prepareFontSelector

        protected com.lowagie.text.pdf.FontSelector prepareFontSelector​(SFont zssFont)
        Prepare a FontSelector which can apply eastern supplemental fonts to text.
      • createPdfChunks

        protected List<com.lowagie.text.Chunk> createPdfChunks​(SFont zssFont,
                                                               String text,
                                                               boolean accountingUnder)
        Create and returns pdf chunks per the provided ZSS font, text, and whether contains a Accounting Underline (because it is handled the other way; see CellRenderEvent.drawAccountingUnderline(com.lowagie.text.Rectangle, com.lowagie.text.Rectangle, float, float, float, float, com.lowagie.text.pdf.PdfContentByte))
      • processPdfChunk

        protected com.lowagie.text.Chunk processPdfChunk​(SFont zssFont,
                                                         com.lowagie.text.Chunk chunk,
                                                         boolean accountingUnder)
      • searchNonBlankEndColumn

        protected int searchNonBlankEndColumn​(SSheet sheet,
                                              int rowIdx,
                                              int lastColIdx)
        Returns the last cell that contains value
        Returns:
        last cell column index of the row
      • initSelectedPrintArea

        protected void initSelectedPrintArea​(SSheet sheet)
      • initPrintArea

        protected void initPrintArea​(SSheet sheet,
                                     CellRegion region)
        sets the column bounds for passed SSheet
        Parameters:
        sheet -
      • getExtendedEndColumn

        protected int getExtendedEndColumn​(SSheet sheet,
                                           SCell zssCell,
                                           int colIdx)
      • getAcrossSelectionColumn0

        protected int getAcrossSelectionColumn0​(SSheet sheet,
                                                int rowIdx,
                                                int colIdx)
      • getExtendedEndColumn0

        protected int getExtendedEndColumn0​(SSheet sheet,
                                            SCell zssCell,
                                            int colIdx)
      • getPrintSetup

        public SPrintSetup getPrintSetup()
        Get this setup to setup the exporting parameters for "print" as a PDF document
        Returns:
      • initSheetPrintSetup

        protected void initSheetPrintSetup​(SSheet sheet)
      • getCurrentPrintSetup

        protected SPrintSetup getCurrentPrintSetup​(SSheet sheet)
      • getCurrentHeader

        protected SHeader getCurrentHeader​(SSheet sheet)
      • getCurrentFooter

        protected SFooter getCurrentFooter​(SSheet sheet)
      • isEvenPage

        protected boolean isEvenPage​(int no)
      • isUseColTitles

        protected boolean isUseColTitles()
      • isUseRowTitles

        protected boolean isUseRowTitles()
      • getCountOfColTitles

        protected int getCountOfColTitles()
      • getTitleWidth

        protected double getTitleWidth()
      • getTitleHeight

        protected double getTitleHeight()
      • getPixelInfo

        protected io.keikai.model.impl.pdf.PixelInfo getPixelInfo​(CellRegion clipRegion)