org.extex.backend.documentWriter.pdf
Class PdfDocumentWriter

java.lang.Object
  extended by org.extex.backend.documentWriter.pdf.PdfDocumentWriter
All Implemented Interfaces:
DocumentWriter, SingleDocumentStream, PdftexSupport

public class PdfDocumentWriter
extends java.lang.Object
implements PdftexSupport, DocumentWriter, SingleDocumentStream

Implementation of a pdf document writer.

Version:
$Revision: 5882 $
Author:
Michael Niedermair, Rolf Niepraschk

Field Summary
static int HEIGHT_A4_BP
          height A4 in bp.
static int WIDTH_A4_BP
          width A4 in bp.
 
Constructor Summary
PdfDocumentWriter(Configuration cfg, DocumentWriterOptions options)
          Creates a new object.
 
Method Summary
 void close()
          This method is invoked upon the end of the processing.
 PdfAnnotation getAnnotation(RuleNode node, java.lang.String annotation)
          Factory method to construct a PdfAnnotation node.
 java.lang.String getExtension()
          Getter for the extension associated with this kind of output.
 PdfObject getObject(java.lang.String attr, boolean isStream, java.lang.String text)
          Factory method to construct a PdfObject node.
 PdfXForm getXForm(java.lang.String attr, java.lang.String resources, NodeList list)
          Factory method to construct a PdfXForm node.
 PdfRefXImage getXImage(java.lang.String resource, RuleNode rule, java.lang.String attr, long page, boolean immediate)
          Factory method to construct a PdfXImage node.
 void pdfcatalog(java.lang.String text, ActionSpec action)
          Add some material to the PDF catalog.
 java.lang.String pdffontname(Font font)
          Retrieve the font name for a given font.
 long pdffontobjnum(Font font)
          Retrieve the font object number for a given font.
 void pdfincludechars(Font font, java.lang.String text)
          Include a set of characters from a font into the output regardless of whether they are used or not.
 void pdfinfo(java.lang.String text)
          This method inserts the text to the info section.
 long pdflastannot()
          Retrieve the object index of the last annotation.
 long pdflastobj()
          Retrieve the object index of the last object.
 long pdflastxform()
          Retrieve the object index of the last XForm.
 long pdflastximage()
          Retrieve the object index of the last XImage.
 void pdfnames(java.lang.String text)
          This method inserts the text to /Names array.
 void pdfoutline(ActionSpec action, long count, java.lang.String text)
          Insert some outline into the PDF output.
 void setOutputStream(java.io.OutputStream outStream)
          Setter for the output stream.
 void setParameter(java.lang.String name, java.lang.String value)
          Setter for a named parameter.
 int shipout(Page p)
          This is the entry point for the document writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIDTH_A4_BP

public static final int WIDTH_A4_BP
width A4 in bp.

See Also:
Constant Field Values

HEIGHT_A4_BP

public static final int HEIGHT_A4_BP
height A4 in bp.

See Also:
Constant Field Values
Constructor Detail

PdfDocumentWriter

public PdfDocumentWriter(Configuration cfg,
                         DocumentWriterOptions options)
Creates a new object.

Parameters:
cfg - the configuration
options - the options
Method Detail

close

public void close()
           throws DocumentWriterException
This method is invoked upon the end of the processing.

Specified by:
close in interface DocumentWriter
Throws:
DocumentWriterException
See Also:
DocumentWriter.close()

getExtension

public java.lang.String getExtension()
Getter for the extension associated with this kind of output. For instance pdf is the expected value for PDF files and dvi is the expected value for DVI files.

Specified by:
getExtension in interface DocumentWriter
Returns:
the appropriate extension for file names
See Also:
DocumentWriter.getExtension()

setOutputStream

public void setOutputStream(java.io.OutputStream outStream)
Setter for the output stream.

Specified by:
setOutputStream in interface SingleDocumentStream
Parameters:
outStream - the output stream
See Also:
SingleDocumentStream.setOutputStream( java.io.OutputStream)

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Setter for a named parameter. Parameters are a general mechanism to influence the behavior of the document writer. Any parameter not known by the document writer has to be ignored.

Specified by:
setParameter in interface DocumentWriter
Parameters:
name - the name of the parameter
value - the value of the parameter
See Also:
DocumentWriter.setParameter( java.lang.String, java.lang.String)

shipout

public int shipout(Page p)
            throws DocumentWriterException
This is the entry point for the document writer. Here it receives a complete node list to be sent to the output writer. It can be assumed that all values for width, height, and depth of the node lists are properly filled. Thus all information should be present to place the ink on the paper.

If the page is null then no page has to be shipped and 0 has to be returned.

Specified by:
shipout in interface DocumentWriter
Parameters:
p - the page to send
Returns:
returns the number of pages shipped
Throws:
DocumentWriterException
See Also:
DocumentWriter.shipout( org.extex.typesetter.type.page.Page)

getAnnotation

public PdfAnnotation getAnnotation(RuleNode node,
                                   java.lang.String annotation)
                            throws HelpingException
Factory method to construct a PdfAnnotation node.

Specified by:
getAnnotation in interface PdftexSupport
Parameters:
node - the rule specification. Only the width height and depth are relevant. Either of them can be null.
annotation - the annotation text
Returns:
a PdfAnnotation node
Throws:
HelpingException - in case of an error
See Also:
PdftexSupport.getAnnotation(org.extex.typesetter.type.node.RuleNode, java.lang.String)

getObject

public PdfObject getObject(java.lang.String attr,
                           boolean isStream,
                           java.lang.String text)
                    throws HelpingException
Factory method to construct a PdfObject node.

Specified by:
getObject in interface PdftexSupport
Parameters:
attr - the attribute text. This can be null
isStream - boolean indicator to signal that a stream object or file object is requested
text - the object
Returns:
a PdfObject node
Throws:
HelpingException - in case of an error
See Also:
PdftexSupport.getObject(java.lang.String, boolean, java.lang.String)

getXImage

public PdfRefXImage getXImage(java.lang.String resource,
                              RuleNode rule,
                              java.lang.String attr,
                              long page,
                              boolean immediate)
                       throws HelpingException
Factory method to construct a PdfXImage node.

Specified by:
getXImage in interface PdftexSupport
Parameters:
resource - the resource specification
rule - the rule specification. Only the width height and depth are relevant. Either of them can be null.
attr - the attribute text. This can be null
page - the page number
immediate - the indicator that the image should be put into the PDF output without waiting for a reference
Returns:
a PdfXImage node
Throws:
HelpingException - in case of an error
See Also:
PdftexSupport.getXImage(java.lang.String, org.extex.typesetter.type.node.RuleNode, java.lang.String, long, boolean)

pdfcatalog

public void pdfcatalog(java.lang.String text,
                       ActionSpec action)
Add some material to the PDF catalog.

Specified by:
pdfcatalog in interface PdftexSupport
Parameters:
text - the text for the catalog
action - the action specification. This parameter can be null
See Also:
PdftexSupport.pdfcatalog(java.lang.String, org.extex.pdf.api.action.ActionSpec)

pdffontname

public java.lang.String pdffontname(Font font)
Retrieve the font name for a given font. For instance if a font is addressed as /F12 then this method returns 12.

Specified by:
pdffontname in interface PdftexSupport
Parameters:
font - the font to query
Returns:
the name used by PDF for the font
See Also:
PdftexSupport.pdffontname(org.extex.typesetter.tc.font.Font)

pdffontobjnum

public long pdffontobjnum(Font font)
Retrieve the font object number for a given font.

Specified by:
pdffontobjnum in interface PdftexSupport
Parameters:
font - the font to query
Returns:
the object number
See Also:
PdftexSupport.pdffontobjnum(org.extex.typesetter.tc.font.Font)

pdfincludechars

public void pdfincludechars(Font font,
                            java.lang.String text)
Include a set of characters from a font into the output regardless of whether they are used or not.

Specified by:
pdfincludechars in interface PdftexSupport
Parameters:
font - the font
text - the set of characters to include
See Also:
PdftexSupport.pdfincludechars(org.extex.typesetter.tc.font.Font, java.lang.String)

pdfinfo

public void pdfinfo(java.lang.String text)
This method inserts the text to the info section.

Specified by:
pdfinfo in interface PdftexSupport
Parameters:
text - the text to add
See Also:
PdftexSupport.pdfinfo(java.lang.String)

pdflastannot

public long pdflastannot()
Retrieve the object index of the last annotation.

Specified by:
pdflastannot in interface PdftexSupport
Returns:
the last annotation index or -1 if none
See Also:
PdftexSupport.pdflastannot()

pdflastobj

public long pdflastobj()
Retrieve the object index of the last object.

Specified by:
pdflastobj in interface PdftexSupport
Returns:
the last object index or -1 if none
See Also:
PdftexSupport.pdflastobj()

pdflastxform

public long pdflastxform()
Retrieve the object index of the last XForm.

Specified by:
pdflastxform in interface PdftexSupport
Returns:
the last XForm index or -1 if none
See Also:
PdftexSupport.pdflastxform()

pdflastximage

public long pdflastximage()
Retrieve the object index of the last XImage.

Specified by:
pdflastximage in interface PdftexSupport
Returns:
the last XImage index or -1 if none
See Also:
PdftexSupport.pdflastximage()

pdfnames

public void pdfnames(java.lang.String text)
This method inserts the text to /Names array.

Specified by:
pdfnames in interface PdftexSupport
Parameters:
text - the text to add
See Also:
PdftexSupport.pdfnames( java.lang.String)

pdfoutline

public void pdfoutline(ActionSpec action,
                       long count,
                       java.lang.String text)
Insert some outline into the PDF output.

Specified by:
pdfoutline in interface PdftexSupport
Parameters:
action - the action specification
count - the count
text - the text
See Also:
PdftexSupport.pdfoutline( org.extex.pdf.api.action.ActionSpec, long, java.lang.String)

getXForm

public PdfXForm getXForm(java.lang.String attr,
                         java.lang.String resources,
                         NodeList list)
                  throws HelpingException
Factory method to construct a PdfXForm node.

Specified by:
getXForm in interface PdftexSupport
Parameters:
attr - the attribute text. This can be null
resources - the resources specification
list - the content
Returns:
a PdfXForm node
Throws:
HelpingException - in case of an error
See Also:
PdftexSupport.getXForm(java.lang.String, java.lang.String, org.extex.typesetter.type.NodeList)