idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
4,900
protected PdfStream copyStream ( PRStream in ) throws IOException , BadPdfFormatException { PRStream out = new PRStream ( in , null ) ; for ( Iterator it = in . getKeys ( ) . iterator ( ) ; it . hasNext ( ) ; ) { PdfName key = ( PdfName ) it . next ( ) ; PdfObject value = in . get ( key ) ; out . put ( key , copyObject ( value ) ) ; } return out ; }
Translate a PRStream to a PdfStream . The data part copies itself .
4,901
protected PdfArray copyArray ( PdfArray in ) throws IOException , BadPdfFormatException { PdfArray out = new PdfArray ( ) ; for ( Iterator i = in . listIterator ( ) ; i . hasNext ( ) ; ) { PdfObject value = ( PdfObject ) i . next ( ) ; out . add ( copyObject ( value ) ) ; } return out ; }
Translate a PRArray to a PdfArray . Also translate all of the objects contained in it
4,902
protected PdfObject copyObject ( PdfObject in ) throws IOException , BadPdfFormatException { if ( in == null ) return PdfNull . PDFNULL ; switch ( in . type ) { case PdfObject . DICTIONARY : return copyDictionary ( ( PdfDictionary ) in ) ; case PdfObject . INDIRECT : return copyIndirect ( ( PRIndirectReference ) in ) ; case PdfObject . ARRAY : return copyArray ( ( PdfArray ) in ) ; case PdfObject . NUMBER : case PdfObject . NAME : case PdfObject . STRING : case PdfObject . NULL : case PdfObject . BOOLEAN : case 0 : return in ; case PdfObject . STREAM : return copyStream ( ( PRStream ) in ) ; default : if ( in . type < 0 ) { String lit = ( ( PdfLiteral ) in ) . toString ( ) ; if ( lit . equals ( "true" ) || lit . equals ( "false" ) ) { return new PdfBoolean ( lit ) ; } return new PdfLiteral ( lit ) ; } System . out . println ( "CANNOT COPY type " + in . type ) ; return null ; } }
Translate a PR - object to a Pdf - object
4,903
protected int setFromIPage ( PdfImportedPage iPage ) { int pageNum = iPage . getPageNumber ( ) ; PdfReaderInstance inst = currentPdfReaderInstance = iPage . getPdfReaderInstance ( ) ; reader = inst . getReader ( ) ; setFromReader ( reader ) ; return pageNum ; }
convenience method . Given an imported page set our globals
4,904
protected void setFromReader ( PdfReader reader ) { this . reader = reader ; indirects = ( HashMap ) indirectMap . get ( reader ) ; if ( indirects == null ) { indirects = new HashMap ( ) ; indirectMap . put ( reader , indirects ) ; PdfDictionary catalog = reader . getCatalog ( ) ; PRIndirectReference ref = null ; PdfObject o = catalog . get ( PdfName . ACROFORM ) ; if ( o == null || o . type ( ) != PdfObject . INDIRECT ) return ; ref = ( PRIndirectReference ) o ; if ( acroForm == null ) acroForm = body . getPdfIndirectReference ( ) ; indirects . put ( new RefKey ( ref ) , new IndirectReferences ( acroForm ) ) ; } }
convenience method . Given a reader set our globals
4,905
public void addPage ( PdfImportedPage iPage ) throws IOException , BadPdfFormatException { int pageNum = setFromIPage ( iPage ) ; PdfDictionary thePage = reader . getPageN ( pageNum ) ; PRIndirectReference origRef = reader . getPageOrigRef ( pageNum ) ; reader . releasePage ( pageNum ) ; RefKey key = new RefKey ( origRef ) ; PdfIndirectReference pageRef ; IndirectReferences iRef = ( IndirectReferences ) indirects . get ( key ) ; if ( iRef != null && ! iRef . getCopied ( ) ) { pageReferences . add ( iRef . getRef ( ) ) ; iRef . setCopied ( ) ; } pageRef = getCurrentPage ( ) ; if ( iRef == null ) { iRef = new IndirectReferences ( pageRef ) ; indirects . put ( key , iRef ) ; } iRef . setCopied ( ) ; PdfDictionary newPage = copyDictionary ( thePage ) ; root . addPage ( newPage ) ; ++ currentPageNumber ; }
Add an imported page to our output
4,906
public void addPage ( Rectangle rect , int rotation ) { PdfRectangle mediabox = new PdfRectangle ( rect , rotation ) ; PageResources resources = new PageResources ( ) ; PdfPage page = new PdfPage ( mediabox , new HashMap ( ) , resources . getResources ( ) , 0 ) ; page . put ( PdfName . TABS , getTabs ( ) ) ; root . addPage ( page ) ; ++ currentPageNumber ; }
Adds a blank page .
4,907
public void copyAcroForm ( PdfReader reader ) throws IOException , BadPdfFormatException { setFromReader ( reader ) ; PdfDictionary catalog = reader . getCatalog ( ) ; PRIndirectReference hisRef = null ; PdfObject o = catalog . get ( PdfName . ACROFORM ) ; if ( o != null && o . type ( ) == PdfObject . INDIRECT ) hisRef = ( PRIndirectReference ) o ; if ( hisRef == null ) return ; RefKey key = new RefKey ( hisRef ) ; PdfIndirectReference myRef ; IndirectReferences iRef = ( IndirectReferences ) indirects . get ( key ) ; if ( iRef != null ) { acroForm = myRef = iRef . getRef ( ) ; } else { acroForm = myRef = body . getPdfIndirectReference ( ) ; iRef = new IndirectReferences ( myRef ) ; indirects . put ( key , iRef ) ; } if ( ! iRef . getCopied ( ) ) { iRef . setCopied ( ) ; PdfDictionary theForm = copyDictionary ( ( PdfDictionary ) PdfReader . getPdfObject ( hisRef ) ) ; addToBody ( theForm , myRef ) ; } }
Copy the acroform for an input document . Note that you can only have one we make no effort to merge them .
4,908
void initOutline ( PdfOutline parent , String title , boolean open ) { this . open = open ; this . parent = parent ; writer = parent . writer ; put ( PdfName . TITLE , new PdfString ( title , PdfObject . TEXT_UNICODE ) ) ; parent . addKid ( this ) ; if ( destination != null && ! destination . hasPage ( ) ) setDestinationPage ( writer . getCurrentPage ( ) ) ; }
Helper for the constructors .
4,909
public String getTitle ( ) { PdfString title = ( PdfString ) get ( PdfName . TITLE ) ; return title . toString ( ) ; }
Gets the title of this outline
4,910
public void setTitle ( String title ) { put ( PdfName . TITLE , new PdfString ( title , PdfObject . TEXT_UNICODE ) ) ; }
Sets the title of this outline
4,911
public void drawLine ( PdfContentByte canvas , float leftX , float rightX , float y ) { float w ; if ( getPercentage ( ) < 0 ) w = - getPercentage ( ) ; else w = ( rightX - leftX ) * getPercentage ( ) / 100.0f ; float s ; switch ( getAlignment ( ) ) { case Element . ALIGN_LEFT : s = 0 ; break ; case Element . ALIGN_RIGHT : s = rightX - leftX - w ; break ; default : s = ( rightX - leftX - w ) / 2 ; break ; } canvas . setLineWidth ( getLineWidth ( ) ) ; if ( getLineColor ( ) != null ) canvas . setColorStroke ( getLineColor ( ) ) ; canvas . moveTo ( s + leftX , y + offset ) ; canvas . lineTo ( s + w + leftX , y + offset ) ; canvas . stroke ( ) ; }
Draws a horizontal line .
4,912
public void setBox ( Rectangle box ) { if ( box == null ) { this . box = null ; } else { this . box = new Rectangle ( box ) ; this . box . normalize ( ) ; } }
Sets the field dimension and position .
4,913
public void writeDefinition ( final OutputStream result ) throws IOException { result . write ( FONT_FAMILY ) ; result . write ( FONT_CHARSET ) ; result . write ( intToByteArray ( charset ) ) ; result . write ( DELIMITER ) ; document . filterSpecialChar ( result , fontName , true , false ) ; }
Writes the font definition
4,914
public void writeBegin ( final OutputStream result ) throws IOException { if ( this . fontNumber != Font . UNDEFINED ) { result . write ( RtfFontList . FONT_NUMBER ) ; result . write ( intToByteArray ( fontNumber ) ) ; } if ( this . fontSize != Font . UNDEFINED ) { result . write ( FONT_SIZE ) ; result . write ( intToByteArray ( fontSize * 2 ) ) ; } if ( this . fontStyle != UNDEFINED ) { if ( ( fontStyle & STYLE_BOLD ) == STYLE_BOLD ) { result . write ( FONT_BOLD ) ; } if ( ( fontStyle & STYLE_ITALIC ) == STYLE_ITALIC ) { result . write ( FONT_ITALIC ) ; } if ( ( fontStyle & STYLE_UNDERLINE ) == STYLE_UNDERLINE ) { result . write ( FONT_UNDERLINE ) ; } if ( ( fontStyle & STYLE_STRIKETHROUGH ) == STYLE_STRIKETHROUGH ) { result . write ( FONT_STRIKETHROUGH ) ; } if ( ( fontStyle & STYLE_HIDDEN ) == STYLE_HIDDEN ) { result . write ( FONT_HIDDEN ) ; } if ( ( fontStyle & STYLE_DOUBLE_STRIKETHROUGH ) == STYLE_DOUBLE_STRIKETHROUGH ) { result . write ( FONT_DOUBLE_STRIKETHROUGH ) ; result . write ( intToByteArray ( 1 ) ) ; } if ( ( fontStyle & STYLE_SHADOW ) == STYLE_SHADOW ) { result . write ( FONT_SHADOW ) ; } if ( ( fontStyle & STYLE_OUTLINE ) == STYLE_OUTLINE ) { result . write ( FONT_OUTLINE ) ; } if ( ( fontStyle & STYLE_EMBOSSED ) == STYLE_EMBOSSED ) { result . write ( FONT_EMBOSSED ) ; } if ( ( fontStyle & STYLE_ENGRAVED ) == STYLE_ENGRAVED ) { result . write ( FONT_ENGRAVED ) ; } } if ( color != null ) { color . writeBegin ( result ) ; } }
Writes the font beginning
4,915
public void writeEnd ( final OutputStream result ) throws IOException { if ( this . fontStyle != UNDEFINED ) { if ( ( fontStyle & STYLE_BOLD ) == STYLE_BOLD ) { result . write ( FONT_BOLD ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_ITALIC ) == STYLE_ITALIC ) { result . write ( FONT_ITALIC ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_UNDERLINE ) == STYLE_UNDERLINE ) { result . write ( FONT_UNDERLINE ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_STRIKETHROUGH ) == STYLE_STRIKETHROUGH ) { result . write ( FONT_STRIKETHROUGH ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_HIDDEN ) == STYLE_HIDDEN ) { result . write ( FONT_HIDDEN ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_DOUBLE_STRIKETHROUGH ) == STYLE_DOUBLE_STRIKETHROUGH ) { result . write ( FONT_DOUBLE_STRIKETHROUGH ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_SHADOW ) == STYLE_SHADOW ) { result . write ( FONT_SHADOW ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_OUTLINE ) == STYLE_OUTLINE ) { result . write ( FONT_OUTLINE ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_EMBOSSED ) == STYLE_EMBOSSED ) { result . write ( FONT_EMBOSSED ) ; result . write ( intToByteArray ( 0 ) ) ; } if ( ( fontStyle & STYLE_ENGRAVED ) == STYLE_ENGRAVED ) { result . write ( FONT_ENGRAVED ) ; result . write ( intToByteArray ( 0 ) ) ; } } }
Write the font end
4,916
protected void setFontName ( String fontName ) { this . fontName = fontName ; if ( document != null ) { this . fontNumber = document . getDocumentHeader ( ) . getFontNumber ( this ) ; } }
Sets the font name of this RtfFont .
4,917
private void setToDefaultFamily ( String familyname ) { switch ( Font . getFamilyIndex ( familyname ) ) { case Font . COURIER : this . fontName = "Courier" ; break ; case Font . HELVETICA : this . fontName = "Arial" ; break ; case Font . SYMBOL : this . fontName = "Symbol" ; this . charset = 2 ; break ; case Font . TIMES_ROMAN : this . fontName = "Times New Roman" ; break ; case Font . ZAPFDINGBATS : this . fontName = "Windings" ; break ; default : this . fontName = familyname ; } }
Sets the correct font name from the family name .
4,918
public void setRtfDocument ( RtfDocument doc ) { this . document = doc ; if ( document != null ) { this . fontNumber = document . getDocumentHeader ( ) . getFontNumber ( this ) ; } if ( this . color != null ) { this . color . setRtfDocument ( this . document ) ; } }
Sets the RtfDocument this RtfFont belongs to
4,919
public boolean importFont ( String fontNr , String fontName , String fontFamily , int charset ) { RtfFont rtfFont = new RtfFont ( fontName ) ; if ( charset >= 0 ) rtfFont . setCharset ( charset ) ; if ( fontFamily != null && fontFamily . length ( ) > 0 ) rtfFont . setFamily ( fontFamily ) ; rtfFont . setRtfDocument ( this . rtfDoc ) ; this . importFontMapping . put ( fontNr , Integer . toString ( this . rtfDoc . getDocumentHeader ( ) . getFontNumber ( rtfFont ) ) ) ; return true ; }
Imports a font . The font name is looked up in the RtfDocumentHeader and then the mapping from original font number to actual font number is added .
4,920
public void importColor ( String colorNr , Color color ) { RtfColor rtfColor = new RtfColor ( this . rtfDoc , color ) ; this . importColorMapping . put ( colorNr , Integer . toString ( rtfColor . getColorNumber ( ) ) ) ; }
Imports a color value . The color number for the color defined by its red green and blue values is determined and then the resulting mapping is added .
4,921
public boolean importStylesheetList ( String listNr , List listIn ) { RtfList rtfList = new RtfList ( this . rtfDoc , listIn ) ; rtfList . setRtfDocument ( this . rtfDoc ) ; return true ; }
Imports a stylesheet list value . The stylesheet number for the stylesheet defined is determined and then the resulting mapping is added .
4,922
public static void main ( String [ ] args ) { if ( GraphicsEnvironment . isHeadless ( ) ) { System . out . println ( Document . getVersion ( ) + " Toolbox error: headless display" ) ; } else try { Class c = Class . forName ( "com.lowagie.toolbox.Toolbox" ) ; Method toolboxMain = c . getMethod ( "main" , new Class [ ] { args . getClass ( ) } ) ; toolboxMain . invoke ( null , new Object [ ] { args } ) ; } catch ( Exception e ) { JOptionPane . showMessageDialog ( null , "You need the iText-toolbox.jar with class com.lowagie.toolbox.Toolbox to use the iText Toolbox." , Document . getVersion ( ) + " Toolbox error" , JOptionPane . ERROR_MESSAGE ) ; } }
Checks if the toolbox if available . If it is the toolbox is started . If it isn t an error message is shown .
4,923
public static List expand ( String ranges , int maxNumber ) { SequenceList parse = new SequenceList ( ranges ) ; LinkedList list = new LinkedList ( ) ; boolean sair = false ; while ( ! sair ) { sair = parse . getAttributes ( ) ; if ( parse . low == - 1 && parse . high == - 1 && ! parse . even && ! parse . odd ) continue ; if ( parse . low < 1 ) parse . low = 1 ; if ( parse . high < 1 || parse . high > maxNumber ) parse . high = maxNumber ; if ( parse . low > maxNumber ) parse . low = maxNumber ; int inc = 1 ; if ( parse . inverse ) { if ( parse . low > parse . high ) { int t = parse . low ; parse . low = parse . high ; parse . high = t ; } for ( ListIterator it = list . listIterator ( ) ; it . hasNext ( ) ; ) { int n = ( ( Integer ) it . next ( ) ) . intValue ( ) ; if ( parse . even && ( n & 1 ) == 1 ) continue ; if ( parse . odd && ( n & 1 ) == 0 ) continue ; if ( n >= parse . low && n <= parse . high ) it . remove ( ) ; } } else { if ( parse . low > parse . high ) { inc = - 1 ; if ( parse . odd || parse . even ) { -- inc ; if ( parse . even ) parse . low &= ~ 1 ; else parse . low -= ( ( parse . low & 1 ) == 1 ? 0 : 1 ) ; } for ( int k = parse . low ; k >= parse . high ; k += inc ) list . add ( Integer . valueOf ( k ) ) ; } else { if ( parse . odd || parse . even ) { ++ inc ; if ( parse . odd ) parse . low |= 1 ; else parse . low += ( ( parse . low & 1 ) == 1 ? 1 : 0 ) ; } for ( int k = parse . low ; k <= parse . high ; k += inc ) { list . add ( Integer . valueOf ( k ) ) ; } } } } return list ; }
Generates a list of numbers from a string .
4,924
public void writeDefinition ( final OutputStream result ) throws IOException { result . write ( OPEN_GROUP ) ; result . write ( LIST ) ; result . write ( LIST_TEMPLATE_ID ) ; result . write ( intToByteArray ( document . getRandomInt ( ) ) ) ; int levelsToWrite = - 1 ; switch ( this . listType ) { case LIST_TYPE_NORMAL : levelsToWrite = listLevels . size ( ) ; break ; case LIST_TYPE_SIMPLE : result . write ( LIST_SIMPLE ) ; result . write ( intToByteArray ( 1 ) ) ; levelsToWrite = 1 ; break ; case LIST_TYPE_HYBRID : result . write ( LIST_HYBRID ) ; levelsToWrite = listLevels . size ( ) ; break ; default : break ; } this . document . outputDebugLinebreak ( result ) ; for ( int i = 0 ; i < levelsToWrite ; i ++ ) { ( ( RtfListLevel ) listLevels . get ( i ) ) . writeDefinition ( result ) ; this . document . outputDebugLinebreak ( result ) ; } result . write ( LIST_ID ) ; result . write ( intToByteArray ( this . listID ) ) ; result . write ( CLOSE_GROUP ) ; this . document . outputDebugLinebreak ( result ) ; if ( items != null ) { for ( int i = 0 ; i < items . size ( ) ; i ++ ) { RtfElement rtfElement = ( RtfElement ) items . get ( i ) ; if ( rtfElement instanceof RtfList ) { RtfList rl = ( RtfList ) rtfElement ; rl . writeDefinition ( result ) ; break ; } else if ( rtfElement instanceof RtfListItem ) { RtfListItem rli = ( RtfListItem ) rtfElement ; if ( rli . writeDefinition ( result ) ) break ; } } } }
Writes the definition part of this list level
4,925
public void writeContent ( final OutputStream result ) throws IOException { if ( ! this . inTable ) { result . write ( OPEN_GROUP ) ; } int itemNr = 0 ; if ( items != null ) { for ( int i = 0 ; i < items . size ( ) ; i ++ ) { RtfElement thisRtfElement = ( RtfElement ) items . get ( i ) ; if ( thisRtfElement instanceof RtfListItem ) { itemNr ++ ; RtfListItem rtfElement = ( RtfListItem ) thisRtfElement ; RtfListLevel listLevel = rtfElement . getParent ( ) ; if ( listLevel . getListLevel ( ) == 0 ) { correctIndentation ( ) ; } if ( i == 0 ) { listLevel . writeListBeginning ( result ) ; writeListNumbers ( result ) ; } writeListTextBlock ( result , itemNr , listLevel ) ; rtfElement . writeContent ( result ) ; if ( i < ( items . size ( ) - 1 ) || ! this . inTable || listLevel . getListType ( ) > 0 ) { result . write ( RtfParagraph . PARAGRAPH ) ; } this . document . outputDebugLinebreak ( result ) ; } else if ( thisRtfElement instanceof RtfList ) { ( ( RtfList ) thisRtfElement ) . writeContent ( result ) ; writeListNumbers ( result ) ; this . document . outputDebugLinebreak ( result ) ; } } } if ( ! this . inTable ) { result . write ( CLOSE_GROUP ) ; } result . write ( RtfParagraph . PARAGRAPH_DEFAULTS ) ; }
Writes the content of the RtfList
4,926
protected void createDefaultLevels ( ) { this . listLevels = new ArrayList ( ) ; for ( int i = 0 ; i <= 8 ; i ++ ) { RtfListLevel ll = new RtfListLevel ( this . document ) ; ll . setListType ( RtfListLevel . LIST_TYPE_NUMBERED ) ; ll . setFirstIndent ( 0 ) ; ll . setLeftIndent ( 0 ) ; ll . setLevelTextNumber ( i ) ; ll . setTentative ( true ) ; ll . correctIndentation ( ) ; this . listLevels . add ( ll ) ; } }
Create a default set of listlevels
4,927
public void setInTable ( boolean inTable ) { super . setInTable ( inTable ) ; for ( int i = 0 ; i < this . items . size ( ) ; i ++ ) { ( ( RtfBasicElement ) this . items . get ( i ) ) . setInTable ( inTable ) ; } for ( int i = 0 ; i < this . listLevels . size ( ) ; i ++ ) { ( ( RtfListLevel ) this . listLevels . get ( i ) ) . setInTable ( inTable ) ; } }
Sets whether this RtfList is in a table . Sets the correct inTable setting for all child elements .
4,928
public static char getCorrespondingSymbol ( String name ) { Character symbol = ( Character ) map . get ( name ) ; if ( symbol == null ) { return ( char ) 0 ; } return symbol . charValue ( ) ; }
Looks for the corresponding symbol in the font Symbol .
4,929
public void writeSectionDefinition ( final OutputStream result ) throws IOException { if ( landscape ) { result . write ( LANDSCAPE ) ; result . write ( SECTION_PAGE_WIDTH ) ; result . write ( intToByteArray ( pageWidth ) ) ; result . write ( SECTION_PAGE_HEIGHT ) ; result . write ( intToByteArray ( pageHeight ) ) ; this . document . outputDebugLinebreak ( result ) ; } else { result . write ( SECTION_PAGE_WIDTH ) ; result . write ( intToByteArray ( pageWidth ) ) ; result . write ( SECTION_PAGE_HEIGHT ) ; result . write ( intToByteArray ( pageHeight ) ) ; this . document . outputDebugLinebreak ( result ) ; } result . write ( SECTION_MARGIN_LEFT ) ; result . write ( intToByteArray ( marginLeft ) ) ; result . write ( SECTION_MARGIN_RIGHT ) ; result . write ( intToByteArray ( marginRight ) ) ; result . write ( SECTION_MARGIN_TOP ) ; result . write ( intToByteArray ( marginTop ) ) ; result . write ( SECTION_MARGIN_BOTTOM ) ; result . write ( intToByteArray ( marginBottom ) ) ; }
Writes the definition part for a new section
4,930
public void setPageSize ( Rectangle pageSize ) { if ( ! guessFormat ( pageSize , false ) ) { this . pageWidth = ( int ) ( pageSize . getWidth ( ) * RtfElement . TWIPS_FACTOR ) ; this . pageHeight = ( int ) ( pageSize . getHeight ( ) * RtfElement . TWIPS_FACTOR ) ; this . landscape = pageWidth > pageHeight ; } }
Set the page size to use . This method will use guessFormat to try to guess the correct page format . If no format could be guessed the sizes from the pageSize are used and the landscape setting is determined by comparing width and height ;
4,931
private boolean rectEquals ( Rectangle rect1 , Rectangle rect2 ) { return ( rect1 . getWidth ( ) == rect2 . getWidth ( ) ) && ( rect1 . getHeight ( ) == rect2 . getHeight ( ) ) ; }
This method compares to Rectangles . They are considered equal if width and height are the same
4,932
public void handleInheritance ( ) { if ( this . basedOnName != null && this . document . getDocumentHeader ( ) . getRtfParagraphStyle ( this . basedOnName ) != null ) { this . baseStyle = this . document . getDocumentHeader ( ) . getRtfParagraphStyle ( this . basedOnName ) ; this . baseStyle . handleInheritance ( ) ; if ( ! ( ( this . modified & MODIFIED_ALIGNMENT ) == MODIFIED_ALIGNMENT ) ) { this . alignment = this . baseStyle . getAlignment ( ) ; } if ( ! ( ( this . modified & MODIFIED_INDENT_LEFT ) == MODIFIED_INDENT_LEFT ) ) { this . indentLeft = this . baseStyle . getIndentLeft ( ) ; } if ( ! ( ( this . modified & MODIFIED_INDENT_RIGHT ) == MODIFIED_INDENT_RIGHT ) ) { this . indentRight = this . baseStyle . getIndentRight ( ) ; } if ( ! ( ( this . modified & MODIFIED_SPACING_BEFORE ) == MODIFIED_SPACING_BEFORE ) ) { this . spacingBefore = this . baseStyle . getSpacingBefore ( ) ; } if ( ! ( ( this . modified & MODIFIED_SPACING_AFTER ) == MODIFIED_SPACING_AFTER ) ) { this . spacingAfter = this . baseStyle . getSpacingAfter ( ) ; } if ( ! ( ( this . modified & MODIFIED_FONT_NAME ) == MODIFIED_FONT_NAME ) ) { setFontName ( this . baseStyle . getFontName ( ) ) ; } if ( ! ( ( this . modified & MODIFIED_FONT_SIZE ) == MODIFIED_FONT_SIZE ) ) { setSize ( this . baseStyle . getFontSize ( ) ) ; } if ( ! ( ( this . modified & MODIFIED_FONT_STYLE ) == MODIFIED_FONT_STYLE ) ) { setStyle ( this . baseStyle . getFontStyle ( ) ) ; } if ( ! ( ( this . modified & MODIFIED_FONT_COLOR ) == MODIFIED_FONT_COLOR ) ) { setColor ( this . baseStyle . getColor ( ) ) ; } if ( ! ( ( this . modified & MODIFIED_LINE_LEADING ) == MODIFIED_LINE_LEADING ) ) { setLineLeading ( this . baseStyle . getLineLeading ( ) ) ; } if ( ! ( ( this . modified & MODIFIED_KEEP_TOGETHER ) == MODIFIED_KEEP_TOGETHER ) ) { setKeepTogether ( this . baseStyle . getKeepTogether ( ) ) ; } if ( ! ( ( this . modified & MODIFIED_KEEP_TOGETHER_WITH_NEXT ) == MODIFIED_KEEP_TOGETHER_WITH_NEXT ) ) { setKeepTogetherWithNext ( this . baseStyle . getKeepTogetherWithNext ( ) ) ; } } }
Handles the inheritance of paragraph style settings . All settings that have not been modified will be inherited from the base RtfParagraphStyle . If this RtfParagraphStyle is not based on another one then nothing happens .
4,933
private void writeParagraphSettings ( final OutputStream result ) throws IOException { if ( this . keepTogether ) { result . write ( RtfParagraphStyle . KEEP_TOGETHER ) ; } if ( this . keepTogetherWithNext ) { result . write ( RtfParagraphStyle . KEEP_TOGETHER_WITH_NEXT ) ; } switch ( alignment ) { case Element . ALIGN_LEFT : result . write ( RtfParagraphStyle . ALIGN_LEFT ) ; break ; case Element . ALIGN_RIGHT : result . write ( RtfParagraphStyle . ALIGN_RIGHT ) ; break ; case Element . ALIGN_CENTER : result . write ( RtfParagraphStyle . ALIGN_CENTER ) ; break ; case Element . ALIGN_JUSTIFIED : case Element . ALIGN_JUSTIFIED_ALL : result . write ( RtfParagraphStyle . ALIGN_JUSTIFY ) ; break ; } result . write ( FIRST_LINE_INDENT ) ; result . write ( intToByteArray ( this . firstLineIndent ) ) ; result . write ( RtfParagraphStyle . INDENT_LEFT ) ; result . write ( intToByteArray ( indentLeft ) ) ; result . write ( RtfParagraphStyle . INDENT_RIGHT ) ; result . write ( intToByteArray ( indentRight ) ) ; if ( this . spacingBefore > 0 ) { result . write ( RtfParagraphStyle . SPACING_BEFORE ) ; result . write ( intToByteArray ( this . spacingBefore ) ) ; } if ( this . spacingAfter > 0 ) { result . write ( RtfParagraphStyle . SPACING_AFTER ) ; result . write ( intToByteArray ( this . spacingAfter ) ) ; } if ( this . lineLeading > 0 ) { result . write ( RtfParagraph . LINE_SPACING ) ; result . write ( intToByteArray ( this . lineLeading ) ) ; } }
Writes the settings of this RtfParagraphStyle .
4,934
public void writeDefinition ( final OutputStream result ) throws IOException { result . write ( DocWriter . getISOBytes ( "{" ) ) ; result . write ( DocWriter . getISOBytes ( "\\style" ) ) ; result . write ( DocWriter . getISOBytes ( "\\s" ) ) ; result . write ( intToByteArray ( this . styleNumber ) ) ; result . write ( RtfBasicElement . DELIMITER ) ; writeParagraphSettings ( result ) ; super . writeBegin ( result ) ; result . write ( RtfBasicElement . DELIMITER ) ; result . write ( DocWriter . getISOBytes ( this . styleName ) ) ; result . write ( DocWriter . getISOBytes ( ";" ) ) ; result . write ( DocWriter . getISOBytes ( "}" ) ) ; this . document . outputDebugLinebreak ( result ) ; }
Writes the definition of this RtfParagraphStyle for the stylesheet list .
4,935
public void writeBegin ( final OutputStream result ) throws IOException { result . write ( DocWriter . getISOBytes ( "\\s" ) ) ; result . write ( intToByteArray ( this . styleNumber ) ) ; writeParagraphSettings ( result ) ; }
Writes the start information of this RtfParagraphStyle .
4,936
public static Image getJbig2Image ( RandomAccessFileOrArray ra , int page ) { if ( page < 1 ) throw new IllegalArgumentException ( "The page number must be >= 1." ) ; try { JBIG2SegmentReader sr = new JBIG2SegmentReader ( ra ) ; sr . read ( ) ; JBIG2SegmentReader . JBIG2Page p = sr . getPage ( page ) ; Image img = new ImgJBIG2 ( p . pageBitmapWidth , p . pageBitmapHeight , p . getData ( true ) , sr . getGlobal ( true ) ) ; return img ; } catch ( Exception e ) { throw new ExceptionConverter ( e ) ; } }
returns an Image representing the given page .
4,937
public void writeDefinition ( final OutputStream result ) throws IOException { result . write ( ANSI ) ; result . write ( ANSI_CODEPAGE ) ; result . write ( intToByteArray ( 1252 ) ) ; this . document . outputDebugLinebreak ( result ) ; }
Writes the selected codepage
4,938
public RtfCtrlWordHandler getCtrlWordHandler ( String ctrlWord ) { try { if ( ctrlWords . containsKey ( ctrlWord ) ) { return ( RtfCtrlWordHandler ) ctrlWords . get ( ctrlWord ) ; } else { return ( RtfCtrlWordHandler ) ctrlWords . get ( "unknown" ) ; } } catch ( SecurityException e ) { e . printStackTrace ( ) ; } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; } return null ; }
Get the HashMap object containing the control words . Initializes the instance if this is the first instantiation of RtfCtrlWords class .
4,939
public void writeContent ( final OutputStream result ) throws IOException { if ( this . borderStyle == BORDER_NONE || this . borderPosition == NO_BORDER || this . borderWidth == 0 ) { return ; } if ( this . borderType == ROW_BORDER ) { switch ( this . borderPosition ) { case LEFT_BORDER : result . write ( ROW_BORDER_LEFT ) ; break ; case TOP_BORDER : result . write ( ROW_BORDER_TOP ) ; break ; case RIGHT_BORDER : result . write ( ROW_BORDER_RIGHT ) ; break ; case BOTTOM_BORDER : result . write ( ROW_BORDER_BOTTOM ) ; break ; case HORIZONTAL_BORDER : result . write ( ROW_BORDER_HORIZONTAL ) ; break ; case VERTICAL_BORDER : result . write ( ROW_BORDER_VERTICAL ) ; break ; default : return ; } result . write ( writeBorderStyle ( ) ) ; result . write ( BORDER_WIDTH ) ; result . write ( intToByteArray ( this . borderWidth ) ) ; result . write ( BORDER_COLOR_NUMBER ) ; result . write ( intToByteArray ( this . borderColor . getColorNumber ( ) ) ) ; this . document . outputDebugLinebreak ( result ) ; } else if ( this . borderType == CELL_BORDER ) { switch ( this . borderPosition ) { case LEFT_BORDER : result . write ( CELL_BORDER_LEFT ) ; break ; case TOP_BORDER : result . write ( CELL_BORDER_TOP ) ; break ; case RIGHT_BORDER : result . write ( CELL_BORDER_RIGHT ) ; break ; case BOTTOM_BORDER : result . write ( CELL_BORDER_BOTTOM ) ; break ; default : return ; } result . write ( writeBorderStyle ( ) ) ; result . write ( BORDER_WIDTH ) ; result . write ( intToByteArray ( this . borderWidth ) ) ; result . write ( BORDER_COLOR_NUMBER ) ; result . write ( intToByteArray ( this . borderColor . getColorNumber ( ) ) ) ; this . document . outputDebugLinebreak ( result ) ; } }
Writes the RtfBorder settings
4,940
private byte [ ] writeBorderStyle ( ) { switch ( this . borderStyle ) { case BORDER_NONE : return new byte [ 0 ] ; case BORDER_SINGLE : return BORDER_STYLE_SINGLE ; case BORDER_DOUBLE_THICK : return BORDER_STYLE_DOUBLE_THICK ; case BORDER_SHADOWED : return BORDER_STYLE_SHADOWED ; case BORDER_DOTTED : return BORDER_STYLE_DOTTED ; case BORDER_DASHED : return BORDER_STYLE_DASHED ; case BORDER_HAIRLINE : return BORDER_STYLE_HAIRLINE ; case BORDER_DOUBLE : return BORDER_STYLE_DOUBLE ; case BORDER_DOT_DASH : return BORDER_STYLE_DOT_DASH ; case BORDER_DOT_DOT_DASH : return BORDER_STYLE_DOT_DOT_DASH ; case BORDER_TRIPLE : return BORDER_STYLE_TRIPLE ; case BORDER_THICK_THIN : return BORDER_STYLE_THICK_THIN ; case BORDER_THIN_THICK : return BORDER_STYLE_THIN_THICK ; case BORDER_THIN_THICK_THIN : return BORDER_STYLE_THIN_THICK_THIN ; case BORDER_THICK_THIN_MED : return BORDER_STYLE_THICK_THIN_MED ; case BORDER_THIN_THICK_MED : return BORDER_STYLE_THIN_THICK_MED ; case BORDER_THIN_THICK_THIN_MED : return BORDER_STYLE_THIN_THICK_THIN_MED ; case BORDER_THICK_THIN_LARGE : return BORDER_STYLE_THICK_THIN_LARGE ; case BORDER_THIN_THICK_LARGE : return BORDER_STYLE_THIN_THICK_LARGE ; case BORDER_THIN_THICK_THIN_LARGE : return BORDER_STYLE_THIN_THICK_THIN_LARGE ; case BORDER_WAVY : return BORDER_STYLE_WAVY ; case BORDER_DOUBLE_WAVY : return BORDER_STYLE_DOUBLE_WAVY ; case BORDER_STRIPED : return BORDER_STYLE_STRIPED ; case BORDER_EMBOSS : return BORDER_STYLE_EMBOSS ; case BORDER_ENGRAVE : return BORDER_STYLE_ENGRAVE ; default : return BORDER_STYLE_SINGLE ; } }
Writes the style of this RtfBorder
4,941
public static String getW3CDate ( String d ) { if ( d . startsWith ( "D:" ) ) d = d . substring ( 2 ) ; StringBuffer sb = new StringBuffer ( ) ; if ( d . length ( ) < 4 ) return "0000" ; sb . append ( d . substring ( 0 , 4 ) ) ; d = d . substring ( 4 ) ; if ( d . length ( ) < 2 ) return sb . toString ( ) ; sb . append ( '-' ) . append ( d . substring ( 0 , 2 ) ) ; d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) return sb . toString ( ) ; sb . append ( '-' ) . append ( d . substring ( 0 , 2 ) ) ; d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) return sb . toString ( ) ; sb . append ( 'T' ) . append ( d . substring ( 0 , 2 ) ) ; d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) { sb . append ( ":00Z" ) ; return sb . toString ( ) ; } sb . append ( ':' ) . append ( d . substring ( 0 , 2 ) ) ; d = d . substring ( 2 ) ; if ( d . length ( ) < 2 ) { sb . append ( 'Z' ) ; return sb . toString ( ) ; } sb . append ( ':' ) . append ( d . substring ( 0 , 2 ) ) ; d = d . substring ( 2 ) ; if ( d . startsWith ( "-" ) || d . startsWith ( "+" ) ) { String sign = d . substring ( 0 , 1 ) ; d = d . substring ( 1 ) ; String h = "00" ; String m = "00" ; if ( d . length ( ) >= 2 ) { h = d . substring ( 0 , 2 ) ; if ( d . length ( ) > 2 ) { d = d . substring ( 3 ) ; if ( d . length ( ) >= 2 ) m = d . substring ( 0 , 2 ) ; } sb . append ( sign ) . append ( h ) . append ( ':' ) . append ( m ) ; return sb . toString ( ) ; } } sb . append ( 'Z' ) ; return sb . toString ( ) ; }
Gives the W3C format of the PdfDate .
4,942
public static Calendar decode ( String s ) { try { if ( s . startsWith ( "D:" ) ) s = s . substring ( 2 ) ; GregorianCalendar calendar ; int slen = s . length ( ) ; int idx = s . indexOf ( 'Z' ) ; if ( idx >= 0 ) { slen = idx ; calendar = new GregorianCalendar ( new SimpleTimeZone ( 0 , "ZPDF" ) ) ; } else { int sign = 1 ; idx = s . indexOf ( '+' ) ; if ( idx < 0 ) { idx = s . indexOf ( '-' ) ; if ( idx >= 0 ) sign = - 1 ; } if ( idx < 0 ) calendar = new GregorianCalendar ( ) ; else { int offset = Integer . parseInt ( s . substring ( idx + 1 , idx + 3 ) ) * 60 ; if ( idx + 5 < s . length ( ) ) offset += Integer . parseInt ( s . substring ( idx + 4 , idx + 6 ) ) ; calendar = new GregorianCalendar ( new SimpleTimeZone ( offset * sign * 60000 , "ZPDF" ) ) ; slen = idx ; } } calendar . clear ( ) ; idx = 0 ; for ( int k = 0 ; k < DATE_SPACE . length ; k += 3 ) { if ( idx >= slen ) break ; calendar . set ( DATE_SPACE [ k ] , Integer . parseInt ( s . substring ( idx , idx + DATE_SPACE [ k + 1 ] ) ) + DATE_SPACE [ k + 2 ] ) ; idx += DATE_SPACE [ k + 1 ] ; } return calendar ; } catch ( Exception e ) { return null ; } }
Converts a PDF string representing a date into a Calendar .
4,943
private void HelperRGB ( float red , float green , float blue ) { PdfXConformanceImp . checkPDFXConformance ( writer , PdfXConformanceImp . PDFXKEY_RGB , null ) ; if ( red < 0 ) red = 0.0f ; else if ( red > 1.0f ) red = 1.0f ; if ( green < 0 ) green = 0.0f ; else if ( green > 1.0f ) green = 1.0f ; if ( blue < 0 ) blue = 0.0f ; else if ( blue > 1.0f ) blue = 1.0f ; content . append ( red ) . append ( ' ' ) . append ( green ) . append ( ' ' ) . append ( blue ) ; }
Helper to validate and write the RGB color components
4,944
private void HelperCMYK ( float cyan , float magenta , float yellow , float black ) { if ( cyan < 0 ) cyan = 0.0f ; else if ( cyan > 1.0f ) cyan = 1.0f ; if ( magenta < 0 ) magenta = 0.0f ; else if ( magenta > 1.0f ) magenta = 1.0f ; if ( yellow < 0 ) yellow = 0.0f ; else if ( yellow > 1.0f ) yellow = 1.0f ; if ( black < 0 ) black = 0.0f ; else if ( black > 1.0f ) black = 1.0f ; content . append ( cyan ) . append ( ' ' ) . append ( magenta ) . append ( ' ' ) . append ( yellow ) . append ( ' ' ) . append ( black ) ; }
Helper to validate and write the CMYK color components .
4,945
public void rectangle ( float x , float y , float w , float h ) { content . append ( x ) . append ( ' ' ) . append ( y ) . append ( ' ' ) . append ( w ) . append ( ' ' ) . append ( h ) . append ( " re" ) . append_i ( separator ) ; }
Adds a rectangle to the current path .
4,946
public void beginText ( ) { if ( inText ) { throw new IllegalPdfSyntaxException ( "Unbalanced begin/end text operators." ) ; } inText = true ; state . xTLM = 0 ; state . yTLM = 0 ; content . append ( "BT" ) . append_i ( separator ) ; }
Starts the writing of text .
4,947
public void setCharacterSpacing ( float charSpace ) { state . charSpace = charSpace ; content . append ( charSpace ) . append ( " Tc" ) . append_i ( separator ) ; }
Sets the character spacing parameter .
4,948
public void setWordSpacing ( float wordSpace ) { state . wordSpace = wordSpace ; content . append ( wordSpace ) . append ( " Tw" ) . append_i ( separator ) ; }
Sets the word spacing parameter .
4,949
public void setHorizontalScaling ( float scale ) { state . scale = scale ; content . append ( scale ) . append ( " Tz" ) . append_i ( separator ) ; }
Sets the horizontal scaling parameter .
4,950
public static PdfTextArray getKernArray ( String text , BaseFont font ) { PdfTextArray pa = new PdfTextArray ( ) ; StringBuffer acc = new StringBuffer ( ) ; int len = text . length ( ) - 1 ; char c [ ] = text . toCharArray ( ) ; if ( len >= 0 ) acc . append ( c , 0 , 1 ) ; for ( int k = 0 ; k < len ; ++ k ) { char c2 = c [ k + 1 ] ; int kern = font . getKerning ( c [ k ] , c2 ) ; if ( kern == 0 ) { acc . append ( c2 ) ; } else { pa . add ( acc . toString ( ) ) ; acc . setLength ( 0 ) ; acc . append ( c , k + 1 , 1 ) ; pa . add ( - kern ) ; } } pa . add ( acc . toString ( ) ) ; return pa ; }
Constructs a kern array for a text in a certain font
4,951
public void newlineShowText ( float wordSpacing , float charSpacing , String text ) { state . yTLM -= state . leading ; content . append ( wordSpacing ) . append ( ' ' ) . append ( charSpacing ) ; showText2 ( text ) ; content . append ( "\"" ) . append_i ( separator ) ; state . charSpace = charSpacing ; state . wordSpace = wordSpacing ; }
Moves to the next line and shows text string using the given values of the character and word spacing parameters .
4,952
public void moveText ( float x , float y ) { state . xTLM += x ; state . yTLM += y ; content . append ( x ) . append ( ' ' ) . append ( y ) . append ( " Td" ) . append_i ( separator ) ; }
Moves to the start of the next line offset from the start of the current line .
4,953
public void addOutline ( PdfOutline outline , String name ) { checkWriter ( ) ; pdf . addOutline ( outline , name ) ; }
Adds a named outline to the document .
4,954
public float getEffectiveStringWidth ( String text , boolean kerned ) { BaseFont bf = state . fontDetails . getBaseFont ( ) ; float w ; if ( kerned ) w = bf . getWidthPointKerned ( text , state . size ) ; else w = bf . getWidthPoint ( text , state . size ) ; if ( state . charSpace != 0.0f && text . length ( ) > 1 ) { w += state . charSpace * ( text . length ( ) - 1 ) ; } int ft = bf . getFontType ( ) ; if ( state . wordSpace != 0.0f && ( ft == BaseFont . FONT_TYPE_T1 || ft == BaseFont . FONT_TYPE_TT || ft == BaseFont . FONT_TYPE_T3 ) ) { for ( int i = 0 ; i < ( text . length ( ) - 1 ) ; i ++ ) { if ( text . charAt ( i ) == ' ' ) w += state . wordSpace ; } } if ( state . scale != 100.0 ) w = ( w * state . scale ) / 100.0f ; return w ; }
Computes the width of the given string taking in account the current values of Character spacing Word Spacing and Horizontal Scaling . The additional spacing is not computed for the last character of the string .
4,955
public void showTextAligned ( int alignment , String text , float x , float y , float rotation ) { showTextAligned ( alignment , text , x , y , rotation , false ) ; }
Shows text right left or center aligned with rotation .
4,956
public void showTextAlignedKerned ( int alignment , String text , float x , float y , float rotation ) { showTextAligned ( alignment , text , x , y , rotation , true ) ; }
Shows text kerned right left or center aligned with rotation .
4,957
public void concatCTM ( float a , float b , float c , float d , float e , float f ) { content . append ( a ) . append ( ' ' ) . append ( b ) . append ( ' ' ) . append ( c ) . append ( ' ' ) ; content . append ( d ) . append ( ' ' ) . append ( e ) . append ( ' ' ) . append ( f ) . append ( " cm" ) . append_i ( separator ) ; }
Concatenate a matrix to the current transformation matrix .
4,958
public void ellipse ( float x1 , float y1 , float x2 , float y2 ) { arc ( x1 , y1 , x2 , y2 , 0f , 360f ) ; }
Draws an ellipse inscribed within the rectangle x1 y1 x2 y2 .
4,959
public PdfPatternPainter createPattern ( float width , float height , float xstep , float ystep , Color color ) { checkWriter ( ) ; if ( xstep == 0.0f || ystep == 0.0f ) throw new RuntimeException ( "XStep or YStep can not be ZERO." ) ; PdfPatternPainter painter = new PdfPatternPainter ( writer , color ) ; painter . setWidth ( width ) ; painter . setHeight ( height ) ; painter . setXStep ( xstep ) ; painter . setYStep ( ystep ) ; writer . addSimplePattern ( painter ) ; return painter ; }
Create a new uncolored tiling pattern .
4,960
public PdfPatternPainter createPattern ( float width , float height , Color color ) { return createPattern ( width , height , width , height , color ) ; }
Create a new uncolored tiling pattern . Variables xstep and ystep are set to the same values of width and height .
4,961
public void addPSXObject ( PdfPSXObject psobject ) { checkWriter ( ) ; PdfName name = writer . addDirectTemplateSimple ( psobject , null ) ; PageResources prs = getPageResources ( ) ; name = prs . addXObject ( name , psobject . getIndirectReference ( ) ) ; content . append ( name . getBytes ( ) ) . append ( " Do" ) . append_i ( separator ) ; }
Adds a PostScript XObject to this content .
4,962
public void addTemplate ( PdfTemplate template , float a , float b , float c , float d , float e , float f ) { checkWriter ( ) ; checkNoPattern ( template ) ; PdfName name = writer . addDirectTemplateSimple ( template , null ) ; PageResources prs = getPageResources ( ) ; name = prs . addXObject ( name , template . getIndirectReference ( ) ) ; content . append ( "q " ) ; content . append ( a ) . append ( ' ' ) ; content . append ( b ) . append ( ' ' ) ; content . append ( c ) . append ( ' ' ) ; content . append ( d ) . append ( ' ' ) ; content . append ( e ) . append ( ' ' ) ; content . append ( f ) . append ( " cm " ) ; content . append ( name . getBytes ( ) ) . append ( " Do Q" ) . append_i ( separator ) ; }
Adds a template to this content .
4,963
public void setColorFill ( PdfSpotColor sp , float tint ) { checkWriter ( ) ; state . colorDetails = writer . addSimple ( sp ) ; PageResources prs = getPageResources ( ) ; PdfName name = state . colorDetails . getColorName ( ) ; name = prs . addColor ( name , state . colorDetails . getIndirectReference ( ) ) ; content . append ( name . getBytes ( ) ) . append ( " cs " ) . append ( tint ) . append ( " scn" ) . append_i ( separator ) ; }
Sets the fill color to a spot color .
4,964
void outputColorNumbers ( Color color , float tint ) { PdfXConformanceImp . checkPDFXConformance ( writer , PdfXConformanceImp . PDFXKEY_COLOR , color ) ; int type = ExtendedColor . getType ( color ) ; switch ( type ) { case ExtendedColor . TYPE_RGB : content . append ( ( float ) ( color . getRed ( ) ) / 0xFF ) ; content . append ( ' ' ) ; content . append ( ( float ) ( color . getGreen ( ) ) / 0xFF ) ; content . append ( ' ' ) ; content . append ( ( float ) ( color . getBlue ( ) ) / 0xFF ) ; break ; case ExtendedColor . TYPE_GRAY : content . append ( ( ( GrayColor ) color ) . getGray ( ) ) ; break ; case ExtendedColor . TYPE_CMYK : { CMYKColor cmyk = ( CMYKColor ) color ; content . append ( cmyk . getCyan ( ) ) . append ( ' ' ) . append ( cmyk . getMagenta ( ) ) ; content . append ( ' ' ) . append ( cmyk . getYellow ( ) ) . append ( ' ' ) . append ( cmyk . getBlack ( ) ) ; break ; } case ExtendedColor . TYPE_SEPARATION : content . append ( tint ) ; break ; default : throw new RuntimeException ( "Invalid color type." ) ; } }
Outputs the color values to the content .
4,965
public void setPatternFill ( PdfPatternPainter p , Color color ) { if ( ExtendedColor . getType ( color ) == ExtendedColor . TYPE_SEPARATION ) setPatternFill ( p , color , ( ( SpotColor ) color ) . getTint ( ) ) ; else setPatternFill ( p , color , 0 ) ; }
Sets the fill color to an uncolored pattern .
4,966
public void setPatternStroke ( PdfPatternPainter p , Color color , float tint ) { checkWriter ( ) ; if ( ! p . isStencil ( ) ) throw new RuntimeException ( "An uncolored pattern was expected." ) ; PageResources prs = getPageResources ( ) ; PdfName name = writer . addSimplePattern ( p ) ; name = prs . addPattern ( name , p . getIndirectReference ( ) ) ; ColorDetails csDetail = writer . addSimplePatternColorspace ( color ) ; PdfName cName = prs . addColor ( csDetail . getColorName ( ) , csDetail . getIndirectReference ( ) ) ; content . append ( cName . getBytes ( ) ) . append ( " CS" ) . append_i ( separator ) ; outputColorNumbers ( color , tint ) ; content . append ( ' ' ) . append ( name . getBytes ( ) ) . append ( " SCN" ) . append_i ( separator ) ; }
Sets the stroke color to an uncolored pattern .
4,967
public void setPatternStroke ( PdfPatternPainter p ) { if ( p . isStencil ( ) ) { setPatternStroke ( p , p . getDefaultColor ( ) ) ; return ; } checkWriter ( ) ; PageResources prs = getPageResources ( ) ; PdfName name = writer . addSimplePattern ( p ) ; name = prs . addPattern ( name , p . getIndirectReference ( ) ) ; content . append ( PdfName . PATTERN . getBytes ( ) ) . append ( " CS " ) . append ( name . getBytes ( ) ) . append ( " SCN" ) . append_i ( separator ) ; }
Sets the stroke color to a pattern . The pattern can be colored or uncolored .
4,968
public void paintShading ( PdfShading shading ) { writer . addSimpleShading ( shading ) ; PageResources prs = getPageResources ( ) ; PdfName name = prs . addShading ( shading . getShadingName ( ) , shading . getShadingReference ( ) ) ; content . append ( name . getBytes ( ) ) . append ( " sh" ) . append_i ( separator ) ; ColorDetails details = shading . getColorDetails ( ) ; if ( details != null ) prs . addColor ( details . getColorName ( ) , details . getIndirectReference ( ) ) ; }
Paints using a shading object .
4,969
public void setShadingFill ( PdfShadingPattern shading ) { writer . addSimpleShadingPattern ( shading ) ; PageResources prs = getPageResources ( ) ; PdfName name = prs . addPattern ( shading . getPatternName ( ) , shading . getPatternReference ( ) ) ; content . append ( PdfName . PATTERN . getBytes ( ) ) . append ( " cs " ) . append ( name . getBytes ( ) ) . append ( " scn" ) . append_i ( separator ) ; ColorDetails details = shading . getColorDetails ( ) ; if ( details != null ) prs . addColor ( details . getColorName ( ) , details . getIndirectReference ( ) ) ; }
Sets the shading fill pattern .
4,970
public void showText ( PdfTextArray text ) { if ( state . fontDetails == null ) throw new NullPointerException ( "Font and size must be set before writing any text" ) ; content . append ( "[" ) ; ArrayList arrayList = text . getArrayList ( ) ; boolean lastWasNumber = false ; for ( int k = 0 ; k < arrayList . size ( ) ; ++ k ) { Object obj = arrayList . get ( k ) ; if ( obj instanceof String ) { showText2 ( ( String ) obj ) ; lastWasNumber = false ; } else { if ( lastWasNumber ) content . append ( ' ' ) ; else lastWasNumber = true ; content . append ( ( ( Float ) obj ) . floatValue ( ) ) ; } } content . append ( "]TJ" ) . append_i ( separator ) ; }
Show an array of text .
4,971
public void roundRectangle ( float x , float y , float w , float h , float r ) { if ( w < 0 ) { x += w ; w = - w ; } if ( h < 0 ) { y += h ; h = - h ; } if ( r < 0 ) r = - r ; float b = 0.4477f ; moveTo ( x + r , y ) ; lineTo ( x + w - r , y ) ; curveTo ( x + w - r * b , y , x + w , y + r * b , x + w , y + r ) ; lineTo ( x + w , y + h - r ) ; curveTo ( x + w , y + h - r * b , x + w - r * b , y + h , x + w - r , y + h ) ; lineTo ( x + r , y + h ) ; curveTo ( x + r * b , y + h , x , y + h - r * b , x , y + h - r ) ; lineTo ( x , y + r ) ; curveTo ( x , y + r * b , x + r * b , y , x + r , y ) ; }
Adds a round rectangle to the current path .
4,972
public void drawButton ( float llx , float lly , float urx , float ury , String text , BaseFont bf , float size ) { if ( llx > urx ) { float x = llx ; llx = urx ; urx = x ; } if ( lly > ury ) { float y = lly ; lly = ury ; ury = y ; } setColorStroke ( new Color ( 0x00 , 0x00 , 0x00 ) ) ; setLineWidth ( 1 ) ; setLineCap ( 0 ) ; rectangle ( llx , lly , urx - llx , ury - lly ) ; stroke ( ) ; setLineWidth ( 1 ) ; setLineCap ( 0 ) ; setColorFill ( new Color ( 0xC0 , 0xC0 , 0xC0 ) ) ; rectangle ( llx + 0.5f , lly + 0.5f , urx - llx - 1f , ury - lly - 1f ) ; fill ( ) ; setColorStroke ( new Color ( 0xFF , 0xFF , 0xFF ) ) ; setLineWidth ( 1 ) ; setLineCap ( 0 ) ; moveTo ( llx + 1f , lly + 1f ) ; lineTo ( llx + 1f , ury - 1f ) ; lineTo ( urx - 1f , ury - 1f ) ; stroke ( ) ; setColorStroke ( new Color ( 0xA0 , 0xA0 , 0xA0 ) ) ; setLineWidth ( 1 ) ; setLineCap ( 0 ) ; moveTo ( llx + 1f , lly + 1f ) ; lineTo ( urx - 1f , lly + 1f ) ; lineTo ( urx - 1f , ury - 1f ) ; stroke ( ) ; resetRGBColorFill ( ) ; beginText ( ) ; setFontAndSize ( bf , size ) ; showTextAligned ( PdfContentByte . ALIGN_CENTER , text , llx + ( urx - llx ) / 2 , lly + ( ury - lly - size ) / 2 , 0 ) ; endText ( ) ; }
Draws a button .
4,973
public void setGState ( PdfGState gstate ) { PdfObject obj [ ] = writer . addSimpleExtGState ( gstate ) ; PageResources prs = getPageResources ( ) ; PdfName name = prs . addExtGState ( ( PdfName ) obj [ 0 ] , ( PdfIndirectReference ) obj [ 1 ] ) ; content . append ( name . getBytes ( ) ) . append ( " gs" ) . append_i ( separator ) ; }
Sets the graphic state
4,974
public void endLayer ( ) { int n = 1 ; if ( layerDepth != null && ! layerDepth . isEmpty ( ) ) { n = ( ( Integer ) layerDepth . get ( layerDepth . size ( ) - 1 ) ) . intValue ( ) ; layerDepth . remove ( layerDepth . size ( ) - 1 ) ; } else { throw new IllegalPdfSyntaxException ( "Unbalanced layer operators." ) ; } while ( n -- > 0 ) content . append ( "EMC" ) . append_i ( separator ) ; }
Ends a layer controlled graphic block . It will end the most recent open block .
4,975
public void transform ( AffineTransform af ) { double arr [ ] = new double [ 6 ] ; af . getMatrix ( arr ) ; content . append ( arr [ 0 ] ) . append ( ' ' ) . append ( arr [ 1 ] ) . append ( ' ' ) . append ( arr [ 2 ] ) . append ( ' ' ) ; content . append ( arr [ 3 ] ) . append ( ' ' ) . append ( arr [ 4 ] ) . append ( ' ' ) . append ( arr [ 5 ] ) . append ( " cm" ) . append_i ( separator ) ; }
Concatenates a transformation to the current transformation matrix .
4,976
public void setDefaultColorspace ( PdfName name , PdfObject obj ) { PageResources prs = getPageResources ( ) ; prs . addDefaultColor ( name , obj ) ; }
Sets the default colorspace .
4,977
public boolean add ( Element element ) throws DocumentException { if ( pause ) { return false ; } RtfBasicElement [ ] rtfElements = rtfDoc . getMapper ( ) . mapElement ( element ) ; if ( rtfElements . length != 0 ) { for ( int i = 0 ; i < rtfElements . length ; i ++ ) { if ( rtfElements [ i ] != null ) { rtfDoc . add ( rtfElements [ i ] ) ; } } return true ; } else { return false ; } }
Adds an Element to the Document
4,978
public boolean setMargins ( float left , float right , float top , float bottom ) { rtfDoc . getDocumentHeader ( ) . getPageSetting ( ) . setMarginLeft ( ( int ) ( left * RtfElement . TWIPS_FACTOR ) ) ; rtfDoc . getDocumentHeader ( ) . getPageSetting ( ) . setMarginRight ( ( int ) ( right * RtfElement . TWIPS_FACTOR ) ) ; rtfDoc . getDocumentHeader ( ) . getPageSetting ( ) . setMarginTop ( ( int ) ( top * RtfElement . TWIPS_FACTOR ) ) ; rtfDoc . getDocumentHeader ( ) . getPageSetting ( ) . setMarginBottom ( ( int ) ( bottom * RtfElement . TWIPS_FACTOR ) ) ; return true ; }
Sets the page margins
4,979
public void importRtfDocument ( InputStream documentSource , EventListener [ ] events ) throws IOException , DocumentException { if ( ! this . open ) { throw new DocumentException ( "The document must be open to import RTF documents." ) ; } RtfParser rtfImport = new RtfParser ( this . document ) ; if ( events != null ) { for ( int idx = 0 ; idx < events . length ; idx ++ ) { rtfImport . addListener ( events [ idx ] ) ; } } rtfImport . importRtfDocument ( documentSource , this . rtfDoc ) ; }
Adds the complete RTF document to the current RTF document being generated . It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings . Uses new RtfParser object .
4,980
public void importRtfFragment ( InputStream documentSource , RtfImportMappings mappings ) throws IOException , DocumentException { importRtfFragment ( documentSource , mappings , null ) ; }
Adds a fragment of an RTF document to the current RTF document being generated . Since this fragment doesn t contain font or color tables all fonts and colors are mapped to the default font and color . If the font and color mappings are known they can be specified via the mappings parameter .
4,981
public void importRtfFragment ( InputStream documentSource , RtfImportMappings mappings , EventListener [ ] events ) throws IOException , DocumentException { if ( ! this . open ) { throw new DocumentException ( "The document must be open to import RTF fragments." ) ; } RtfParser rtfImport = new RtfParser ( this . document ) ; if ( events != null ) { for ( int idx = 0 ; idx < events . length ; idx ++ ) { rtfImport . addListener ( events [ idx ] ) ; } } rtfImport . importRtfFragment ( documentSource , this . rtfDoc , mappings ) ; }
Adds a fragment of an RTF document to the current RTF document being generated . Since this fragment doesn t contain font or color tables all fonts and colors are mapped to the default font and color . If the font and color mappings are known they can be specified via the mappings parameter . Uses new RtfParser object .
4,982
public boolean isValid ( ) { if ( documentFields . size ( ) == 0 ) return false ; put ( PdfName . FIELDS , documentFields ) ; if ( sigFlags != 0 ) put ( PdfName . SIGFLAGS , new PdfNumber ( sigFlags ) ) ; if ( calculationOrder . size ( ) > 0 ) put ( PdfName . CO , calculationOrder ) ; if ( fieldTemplates . isEmpty ( ) ) return true ; PdfDictionary dic = new PdfDictionary ( ) ; for ( Iterator it = fieldTemplates . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { PdfTemplate template = ( PdfTemplate ) it . next ( ) ; PdfFormField . mergeResources ( dic , ( PdfDictionary ) template . getResources ( ) ) ; } put ( PdfName . DR , dic ) ; put ( PdfName . DA , new PdfString ( "/Helv 0 Tf 0 g " ) ) ; PdfDictionary fonts = ( PdfDictionary ) dic . get ( PdfName . FONT ) ; if ( fonts != null ) { writer . eliminateFontSubset ( fonts ) ; } return true ; }
Checks if the Acroform is valid
4,983
public void addDocument ( PdfReader reader , String ranges ) throws DocumentException , IOException { fc . addDocument ( reader , SequenceList . expand ( ranges , reader . getNumberOfPages ( ) ) ) ; }
Concatenates a PDF document selecting the pages to keep . The pages are described as ranges . The page ordering can be changed but no page repetitions are allowed .
4,984
public boolean setWidths ( float widths [ ] ) { if ( widths . length != cells . length ) return false ; System . arraycopy ( widths , 0 , this . widths , 0 , cells . length ) ; float total = 0 ; calculated = false ; for ( int k = 0 ; k < widths . length ; ++ k ) { PdfPCell cell = cells [ k ] ; if ( cell == null ) { total += widths [ k ] ; continue ; } cell . setLeft ( total ) ; int last = k + cell . getColspan ( ) ; for ( ; k < last ; ++ k ) total += widths [ k ] ; -- k ; cell . setRight ( total ) ; cell . setTop ( 0 ) ; } return true ; }
Sets the widths of the columns in the row .
4,985
public void initExtraHeights ( ) { extraHeights = new float [ cells . length ] ; for ( int i = 0 ; i < extraHeights . length ; i ++ ) { extraHeights [ i ] = 0 ; } }
Initializes the extra heights array .
4,986
public void setExtraHeight ( int cell , float height ) { if ( cell < 0 || cell >= cells . length ) return ; extraHeights [ cell ] = height ; }
Sets an extra height for a cell .
4,987
public float calculateHeights ( ) { maxHeight = 0 ; for ( int k = 0 ; k < cells . length ; ++ k ) { PdfPCell cell = cells [ k ] ; float height = 0 ; if ( cell == null ) { continue ; } else { height = cell . getMaxHeight ( ) ; if ( ( height > maxHeight ) && ( cell . getRowspan ( ) == 1 ) ) maxHeight = height ; } } calculated = true ; return maxHeight ; }
Calculates the heights of each cell in the row .
4,988
public void writeBorderAndBackground ( float xPos , float yPos , float currentMaxHeight , PdfPCell cell , PdfContentByte [ ] canvases ) { Color background = cell . getBackgroundColor ( ) ; if ( background != null || cell . hasBorders ( ) ) { float right = cell . getRight ( ) + xPos ; float top = cell . getTop ( ) + yPos ; float left = cell . getLeft ( ) + xPos ; float bottom = top - currentMaxHeight ; if ( background != null ) { PdfContentByte backgr = canvases [ PdfPTable . BACKGROUNDCANVAS ] ; backgr . setColorFill ( background ) ; backgr . rectangle ( left , bottom , right - left , top - bottom ) ; backgr . fill ( ) ; } if ( cell . hasBorders ( ) ) { Rectangle newRect = new Rectangle ( left , bottom , right , top ) ; newRect . cloneNonPositionParameters ( cell ) ; newRect . setBackgroundColor ( null ) ; PdfContentByte lineCanvas = canvases [ PdfPTable . LINECANVAS ] ; lineCanvas . rectangle ( newRect ) ; } } }
Writes the border and background of one cell in the row .
4,989
public void writeContent ( final OutputStream result ) throws IOException { switch ( this . type ) { case TAB_CENTER_ALIGN : result . write ( DocWriter . getISOBytes ( "\\tqc" ) ) ; break ; case TAB_RIGHT_ALIGN : result . write ( DocWriter . getISOBytes ( "\\tqr" ) ) ; break ; case TAB_DECIMAL_ALIGN : result . write ( DocWriter . getISOBytes ( "\\tqdec" ) ) ; break ; } result . write ( DocWriter . getISOBytes ( "\\tx" ) ) ; result . write ( intToByteArray ( this . position ) ) ; }
Writes the tab settings .
4,990
protected PdfIndirectReference copyIndirect ( PRIndirectReference in ) throws IOException , BadPdfFormatException { PdfObject srcObj = PdfReader . getPdfObjectRelease ( in ) ; ByteStore streamKey = null ; boolean validStream = false ; if ( srcObj . isStream ( ) ) { streamKey = new ByteStore ( ( PRStream ) srcObj ) ; validStream = true ; PdfIndirectReference streamRef = ( PdfIndirectReference ) streamMap . get ( streamKey ) ; if ( streamRef != null ) { return streamRef ; } } PdfIndirectReference theRef ; RefKey key = new RefKey ( in ) ; IndirectReferences iRef = ( IndirectReferences ) indirects . get ( key ) ; if ( iRef != null ) { theRef = iRef . getRef ( ) ; if ( iRef . getCopied ( ) ) { return theRef ; } } else { theRef = body . getPdfIndirectReference ( ) ; iRef = new IndirectReferences ( theRef ) ; indirects . put ( key , iRef ) ; } if ( srcObj . isDictionary ( ) ) { PdfObject type = PdfReader . getPdfObjectRelease ( ( ( PdfDictionary ) srcObj ) . get ( PdfName . TYPE ) ) ; if ( type != null && PdfName . PAGE . equals ( type ) ) { return theRef ; } } iRef . setCopied ( ) ; if ( validStream ) { streamMap . put ( streamKey , theRef ) ; } PdfObject obj = copyObject ( srcObj ) ; addToBody ( obj , theRef ) ; return theRef ; }
Translate a PRIndirectReference to a PdfIndirectReference In addition translates the object numbers and copies the referenced object to the output file if it wasn t available in the cache yet . If it s in the cache the reference to the already used stream is returned .
4,991
public String getContent ( ) { StringBuffer buf = new StringBuffer ( ) ; for ( Iterator i = getChunks ( ) . iterator ( ) ; i . hasNext ( ) ; ) { buf . append ( i . next ( ) . toString ( ) ) ; } return buf . toString ( ) ; }
Returns the content as a String object . This method differs from toString because toString will return an ArrayList with the toString value of the Chunks in this Phrase .
4,992
public static final Phrase getInstance ( int leading , String string , Font font ) { Phrase p = new Phrase ( true ) ; p . setLeading ( leading ) ; p . font = font ; if ( font . getFamily ( ) != Font . SYMBOL && font . getFamily ( ) != Font . ZAPFDINGBATS && font . getBaseFont ( ) == null ) { int index ; while ( ( index = SpecialSymbol . index ( string ) ) > - 1 ) { if ( index > 0 ) { String firstPart = string . substring ( 0 , index ) ; ( ( ArrayList ) p ) . add ( new Chunk ( firstPart , font ) ) ; string = string . substring ( index ) ; } Font symbol = new Font ( Font . SYMBOL , font . getSize ( ) , font . getStyle ( ) , font . getColor ( ) ) ; StringBuffer buf = new StringBuffer ( ) ; buf . append ( SpecialSymbol . getCorrespondingSymbol ( string . charAt ( 0 ) ) ) ; string = string . substring ( 1 ) ; while ( SpecialSymbol . index ( string ) == 0 ) { buf . append ( SpecialSymbol . getCorrespondingSymbol ( string . charAt ( 0 ) ) ) ; string = string . substring ( 1 ) ; } ( ( ArrayList ) p ) . add ( new Chunk ( buf . toString ( ) , symbol ) ) ; } } if ( string != null && string . length ( ) != 0 ) { ( ( ArrayList ) p ) . add ( new Chunk ( string , font ) ) ; } return p ; }
Gets a special kind of Phrase that changes some characters into corresponding symbols .
4,993
public void writeContent ( final OutputStream result ) throws IOException { result . write ( OPEN_GROUP ) ; switch ( infoType ) { case Meta . AUTHOR : result . write ( INFO_AUTHOR ) ; break ; case Meta . SUBJECT : result . write ( INFO_SUBJECT ) ; break ; case Meta . KEYWORDS : result . write ( INFO_KEYWORDS ) ; break ; case Meta . TITLE : result . write ( INFO_TITLE ) ; break ; case Meta . PRODUCER : result . write ( INFO_PRODUCER ) ; break ; case Meta . CREATIONDATE : result . write ( INFO_CREATION_DATE ) ; break ; default : result . write ( INFO_AUTHOR ) ; break ; } result . write ( DELIMITER ) ; if ( infoType == Meta . CREATIONDATE ) { result . write ( DocWriter . getISOBytes ( convertDate ( content ) ) ) ; } else { document . filterSpecialChar ( result , content , false , false ) ; } result . write ( CLOSE_GROUP ) ; }
Writes the content of one RTF information element .
4,994
public static void main ( String args [ ] ) { System . out . println ( "PDF document encryptor" ) ; if ( args . length <= STRENGTH || args [ PERMISSIONS ] . length ( ) != 8 ) { usage ( ) ; return ; } try { int permissions = 0 ; String p = args [ PERMISSIONS ] ; for ( int k = 0 ; k < p . length ( ) ; ++ k ) { permissions |= ( p . charAt ( k ) == '0' ? 0 : permit [ k ] ) ; } System . out . println ( "Reading " + args [ INPUT_FILE ] ) ; PdfReader reader = new PdfReader ( args [ INPUT_FILE ] ) ; System . out . println ( "Writing " + args [ OUTPUT_FILE ] ) ; HashMap moreInfo = new HashMap ( ) ; for ( int k = MOREINFO ; k < args . length - 1 ; k += 2 ) moreInfo . put ( args [ k ] , args [ k + 1 ] ) ; PdfEncryptor . encrypt ( reader , new FileOutputStream ( args [ OUTPUT_FILE ] ) , args [ USER_PASSWORD ] . getBytes ( ) , args [ OWNER_PASSWORD ] . getBytes ( ) , permissions , args [ STRENGTH ] . equals ( "128" ) , moreInfo ) ; System . out . println ( "Done." ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } }
Encrypts a PDF document .
4,995
public Integer toInteger ( ) { Integer value ; value = Integer . valueOf ( this . isNeg ? Integer . parseInt ( this . param ) * - 1 : Integer . parseInt ( this . param ) ) ; return value ; }
Return the parameter value as an Integer object .
4,996
public long longValue ( ) { long value ; value = Long . parseLong ( this . param ) ; if ( this . isNeg ) value = ( - value ) ; return value ; }
Return the parameter value as a long value
4,997
public Long toLong ( ) { Long value ; value = Long . valueOf ( this . isNeg ? Long . parseLong ( this . param ) * - 1 : Long . parseLong ( this . param ) ) ; return value ; }
Return the parameter value as a Long object
4,998
private float firstLineRealHeight ( ) { float firstLineRealHeight = 0f ; if ( firstLine != null ) { PdfChunk chunk = firstLine . getChunk ( 0 ) ; if ( chunk != null ) { Image image = chunk . getImage ( ) ; if ( image != null ) { firstLineRealHeight = firstLine . getChunk ( 0 ) . getImage ( ) . getScaledHeight ( ) ; } else { firstLineRealHeight = useAscender ? firstLine . getAscender ( ) : leading ; } } } return firstLineRealHeight ; }
Calculates what the height of the first line should be so that the content will be flush with the top . For text this is the height of the ascender . For an image it is the actual height of the image .
4,999
private float addImage ( Image i , float left , float right , float extraHeight , int alignment ) { Image image = Image . getInstance ( i ) ; if ( image . getScaledWidth ( ) > right - left ) { image . scaleToFit ( right - left , Float . MAX_VALUE ) ; } flushCurrentLine ( ) ; if ( line == null ) { line = new PdfLine ( left , right , alignment , leading ) ; } PdfLine imageLine = line ; right = right - left ; left = 0f ; if ( ( image . getAlignment ( ) & Image . RIGHT ) == Image . RIGHT ) { left = right - image . getScaledWidth ( ) ; } else if ( ( image . getAlignment ( ) & Image . MIDDLE ) == Image . MIDDLE ) { left = left + ( ( right - left - image . getScaledWidth ( ) ) / 2f ) ; } Chunk imageChunk = new Chunk ( image , left , 0 ) ; imageLine . add ( new PdfChunk ( imageChunk , null ) ) ; addLine ( imageLine ) ; return imageLine . height ( ) ; }
Adds an image to this Cell .