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...
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 ) ;...
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 ; PdfOb...
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 ( origR...
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 . add...
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...
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 ( ) ) setDestinati...
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_RIG...
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 ( intToB...
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 )...
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 . TIM...
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 ( t...
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 [ ] {...
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 ) continu...
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 ...
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 ...
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...
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 ( ...
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 ) ) ; th...
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 ( ) ; i...
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...
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 ...
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 ...
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...
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_LE...
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_STYL...
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 ...
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 =...
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 ...
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...
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 =...
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 . wordSpa...
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...
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 . se...
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" ) . a...
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 . getI...
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 ...
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 ) ; conte...
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 ...
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 ( ) ) ; ...
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 )...
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 ( " c...
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 ( ) ;...
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...
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 ...
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 (...
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." ) ; } whil...
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 ( ...
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 (...
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 ) ...
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 )...
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 . docum...
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 ( ) ...
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 ) { tot...
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 ; } } calcu...
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 ( ) + yPo...
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 ( ...
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 ) ; va...
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...
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 ...
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 ) { permission...
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 ( ) ; } e...
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 ( l...
Adds an image to this Cell .