org.pz.platypus.plugin.pdf
Class PdfOutfile

java.lang.Object
  extended by org.pz.platypus.plugin.pdf.PdfOutfile

public class PdfOutfile
extends java.lang.Object

Manage output to the PDF file


Nested Class Summary
(package private)  class PdfOutfile.OnPageEnd
           
 
Field Summary
(package private)  BulletLists bulletLists
          the collection of active bullet lists
(package private)  com.lowagie.text.pdf.ColumnText iTColumn
          the column that the text is written to in iText.
(package private)  com.lowagie.text.Document iTDocument
          fields with the iT prefix are from iText.
(package private)  com.lowagie.text.Paragraph iTPara
          the largest entity written to an iTDocument is a paragraph
(package private)  int iTStatus
          iText variable that ColumnText uses to see if there's more to write out
(package private)  com.lowagie.text.pdf.PdfWriter iTWriter
          the writer that writes to the iTDocument.
private  boolean openStatus
           
(package private)  PdfData pdfData
          the PDF data structure
(package private)  java.lang.String pdfFilename
          the name of the output file
 
Constructor Summary
PdfOutfile()
           
 
Method Summary
 void addColumnsContentToDocument()
          The method that renders the PDF file
 void addParagraph(com.lowagie.text.Paragraph para, com.lowagie.text.pdf.ColumnText column)
          If paragraph has content, add it to the content of the current column
 void addParagraphToList(com.lowagie.text.Paragraph para)
          Adds a paragraph to the currently active bullet list.
 void addUrl(java.lang.String url, java.lang.String text)
          Emits a URL with the specified cover text.
 void close()
          Outputs any material that has not yet been output.
(package private)  float computeBottomColEdge(float topEdge)
          Compute the bottom edge, which is the lesser of the topEdge - columnHeight or top edge - bottom margin.
(package private)  float computeLeftColEdge()
          Computes the left edge of the current column It starts with the left margin and adds the width and gutters of any columns between it and the left margin.
(package private)  float computeRightColEdge(float leftEdge)
          Compute the right edge of the current column.
(package private)  float computeTopColEdge()
          Compute the top edge of the curren column, which is the page height (PDF coordinates start at lower left corner) - top margin - vertical skip.
(package private)  float doFirstLineIndent(com.lowagie.text.Paragraph para, PdfData pData)
          Handles indenting the first line of a paragraph.
(package private)  void doParagraphAlignment(com.lowagie.text.Paragraph para, PdfData pData)
          Implement the paragraph alignment
(package private)  float doParagraphIndent(com.lowagie.text.Paragraph para, PdfData pData)
          Handles indenting the entire paragraph.
(package private)  float doParagraphIndentRight(com.lowagie.text.Paragraph para, PdfData pData)
          Handles indenting the entire paragraph.
(package private)  void doParagraphSpaceBefore(com.lowagie.text.Paragraph para, PdfData pData)
          Implement the line spacing before the paragraph, if any.
 void emitChar(java.lang.String ch, java.lang.String fontName)
          Emit a single character in the current font, size, etc.
 void emitText(java.lang.String s)
          Writes text to the PDF file.
 void endPlainBulletList()
          End the currently active bullet list.
 int getAddStatus()
           
 float getColumnWidth()
           
 com.lowagie.text.pdf.ColumnText getItColumn()
           
 com.lowagie.text.Paragraph getItPara()
           
 float getYposition()
          Gets the Y-position from iTColumn
 boolean inABulletList()
          Are we in a bullet list?
 boolean isOpen()
           
(package private)  void makeSureOutfileIsOpen()
          Make sure file is open in the event that the first item is not text, such as if it is a URL.
 void newPage()
          High level skip to the top of the next page.
 boolean newPageLowLevel()
          Forces a new page without any of the accompanying processing (although pageEnd() and newPage() events in iText are still performed).
 void open(java.lang.String filename, PdfData pdd)
          Open the output file.
(package private)  void openPdfFile(GDD gdd, PdfData pdf, java.lang.String filename)
          Low level function for opening an iText file (that is, an iText Document)
 void setBulletLists(BulletLists newBulletLists)
           
(package private)  void setColumnSize()
          Set the size of the columns based on their number, page size, and gutter size.
 void setItColumn(com.lowagie.text.pdf.ColumnText ct)
           
 void setItPara(com.lowagie.text.Paragraph newPara)
           
 void setMarginsMirrored()
          Turn on margin mirroring.
 void setPdfData(PdfData newPdfData)
           
 void startNewParagraph()
          Starts a new iText Paragraph.
 void startPlainBulletList(com.lowagie.text.Chunk bulletSymbol)
          Adds a new bullet list to the stack of bulleted lists.
 void startPlainBulletList(java.lang.String bulletSymbol)
          Converts bullet string into an iText Chunk and calls the method that adds a list using the Chunk to define the bullet symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

openStatus

private boolean openStatus

iTDocument

com.lowagie.text.Document iTDocument
fields with the iT prefix are from iText. This is the iText document -- the PDF file


iTWriter

com.lowagie.text.pdf.PdfWriter iTWriter
the writer that writes to the iTDocument. Needed by iText


iTColumn

com.lowagie.text.pdf.ColumnText iTColumn
the column that the text is written to in iText.


iTPara

com.lowagie.text.Paragraph iTPara
the largest entity written to an iTDocument is a paragraph


bulletLists

BulletLists bulletLists
the collection of active bullet lists


iTStatus

int iTStatus
iText variable that ColumnText uses to see if there's more to write out


pdfFilename

java.lang.String pdfFilename
the name of the output file


pdfData

PdfData pdfData
the PDF data structure

Constructor Detail

PdfOutfile

public PdfOutfile()
Method Detail

open

public void open(java.lang.String filename,
                 PdfData pdd)
          throws java.io.IOException
Open the output file. Does basic checks, calls openPdfFile(), and handles any exceptions

Parameters:
filename - name of file to open
pdd - the PDF data class
Throws:
java.io.IOException - in event of a problem opening the file
java.lang.IllegalArgumentException - if pdd is null

openPdfFile

void openPdfFile(GDD gdd,
                 PdfData pdf,
                 java.lang.String filename)
           throws java.io.IOException
Low level function for opening an iText file (that is, an iText Document)

Parameters:
gdd - the GDD
pdf - the PDF data
filename - name of file to be opened
Throws:
java.io.IOException - in the event opening the file runs into an error

close

public void close()
           throws FileCloseException
Outputs any material that has not yet been output. Then closes the iText Document. Note that the first text item to be output forces an open of the document. Consult Start.processText(). So, if the file is closed, no text was output.

Throws:
FileCloseException - if an error occurs closing the file

addParagraph

public void addParagraph(com.lowagie.text.Paragraph para,
                         com.lowagie.text.pdf.ColumnText column)
If paragraph has content, add it to the content of the current column

Parameters:
para - the iText paragraph to add
column - the iText column to add the paragraph to

startPlainBulletList

public void startPlainBulletList(java.lang.String bulletSymbol)
Converts bullet string into an iText Chunk and calls the method that adds a list using the Chunk to define the bullet symbol.

Parameters:
bulletSymbol - string to use as a bullet symbol (most often, a single character)

startPlainBulletList

public void startPlainBulletList(com.lowagie.text.Chunk bulletSymbol)
Adds a new bullet list to the stack of bulleted lists. (These are saved in a stack because lists can nest).

Parameters:
bulletSymbol - symbol to be used as the bullet marker (an iText Chunk)

addParagraphToList

public void addParagraphToList(com.lowagie.text.Paragraph para)
Adds a paragraph to the currently active bullet list.

Parameters:
para - the paragraph to add

endPlainBulletList

public void endPlainBulletList()
End the currently active bullet list. This removes it from the stack of active bullet lists and adds it to the current column.


inABulletList

public boolean inABulletList()
Are we in a bullet list?

Returns:
true if in a bullet list, false otherwise.

doFirstLineIndent

float doFirstLineIndent(com.lowagie.text.Paragraph para,
                        PdfData pData)
Handles indenting the first line of a paragraph. Note: also handles the [noindent] command, which is a one-time command to not indent the present paragraph.

Parameters:
para - the paragraph with the indented first line
pData - the PDF data class containing the indent amount (in points)
Returns:
the amount indented

doParagraphIndent

float doParagraphIndent(com.lowagie.text.Paragraph para,
                        PdfData pData)
Handles indenting the entire paragraph. Indent occurs from the left margin.

Parameters:
para - paragraph
pData - PDF data containing the amount of indent (in points)
Returns:
the amount of indent in points.

doParagraphIndentRight

float doParagraphIndentRight(com.lowagie.text.Paragraph para,
                             PdfData pData)
Handles indenting the entire paragraph. Indent occurs from the right margin.

Parameters:
para - paragraph
pData - PDF data containing the amount of indent (in points)
Returns:
the amount of indent in points.

doParagraphSpaceBefore

void doParagraphSpaceBefore(com.lowagie.text.Paragraph para,
                            PdfData pData)
Implement the line spacing before the paragraph, if any. Note: We do this manually rather than call Paragraph.setSpacingBefore() in iText because setSpacingBefore() in iText affects the current paragraph. So is [paraskip=0] occurs midway in a paragraph, that pargraph will have 0 spacing before it, rather than the previous paraskip value, which was in effect when the paragraph was started. 2009-01-31

Parameters:
para - the paragraph to align
pData - the PdfData container holding the current settings of the PDF output

doParagraphAlignment

void doParagraphAlignment(com.lowagie.text.Paragraph para,
                          PdfData pData)
Implement the paragraph alignment

Parameters:
para - the paragraph to align
pData - the PdfData container holding the current settings of the PDF output

addColumnsContentToDocument

public void addColumnsContentToDocument()
The method that renders the PDF file


setColumnSize

void setColumnSize()
Set the size of the columns based on their number, page size, and gutter size.


computeBottomColEdge

float computeBottomColEdge(float topEdge)
Compute the bottom edge, which is the lesser of the topEdge - columnHeight or top edge - bottom margin. //TODO: find out why this second element is important. (Converted from Platypus v. 0.1.16)

Parameters:
topEdge - top edge of this column
Returns:
bottom edge of the column

computeLeftColEdge

float computeLeftColEdge()
Computes the left edge of the current column It starts with the left margin and adds the width and gutters of any columns between it and the left margin.

Returns:
the left margin of the current column

computeRightColEdge

float computeRightColEdge(float leftEdge)
Compute the right edge of the current column. It's the left edge + column width

Parameters:
leftEdge - location of left edge
Returns:
right edge

computeTopColEdge

float computeTopColEdge()
Compute the top edge of the curren column, which is the page height (PDF coordinates start at lower left corner) - top margin - vertical skip.

Returns:
top edge

newPage

public void newPage()
High level skip to the top of the next page. Writes out all pending text before skipping.


newPageLowLevel

public boolean newPageLowLevel()
Forces a new page without any of the accompanying processing (although pageEnd() and newPage() events in iText are still performed). For example, if we are in mid-paragraph, the paragraph is not added to the current page; etc.

Returns:
wasPageAdded true if it was, false if an error occurred

startNewParagraph

public void startNewParagraph()
Starts a new iText Paragraph. First writes out any content from the previous paragraph if there remains anything unwritten to the output file.


makeSureOutfileIsOpen

void makeSureOutfileIsOpen()
                     throws java.io.IOException
Make sure file is open in the event that the first item is not text, such as if it is a URL.

Throws:
java.io.IOException - in the event that the call to open() throws this exception

emitText

public void emitText(java.lang.String s)
Writes text to the PDF file. Because text can be written either as a Chunk or a Phrase in iText, this method has to manage both entities within the larger context of a Paragraph.

Parameters:
s - the text to be written

emitChar

public void emitChar(java.lang.String ch,
                     java.lang.String fontName)
Emit a single character in the current font, size, etc. This is used to output a character by its Unicode value and is called by PdfSymbol, which handles the processing of symbols and special characters.

Parameters:
ch - char to be emitted
fontName - fontName to use. If null, use current font.

addUrl

public void addUrl(java.lang.String url,
                   java.lang.String text)
Emits a URL with the specified cover text. Creates a clickable link in the PDF doc. If no cover text is null (so, not specified), then the text defaults to the URL itself. (In other words, http://pz.org would print as is.)

Parameters:
url - the URL of the link
text - words to be printed and made linkable (in lieu of printing the URL)

setMarginsMirrored

public void setMarginsMirrored()
Turn on margin mirroring.


getYposition

public float getYposition()
Gets the Y-position from iTColumn

Returns:
the vertical position of the current writing position

getAddStatus

public int getAddStatus()

isOpen

public boolean isOpen()

setPdfData

public void setPdfData(PdfData newPdfData)

getColumnWidth

public float getColumnWidth()

getItPara

public com.lowagie.text.Paragraph getItPara()

setBulletLists

public void setBulletLists(BulletLists newBulletLists)

setItPara

public void setItPara(com.lowagie.text.Paragraph newPara)

setItColumn

public void setItColumn(com.lowagie.text.pdf.ColumnText ct)

getItColumn

public com.lowagie.text.pdf.ColumnText getItColumn()


Copyright © 2008-10 Pacific Data Works LLC