idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
4,800
|
public Hyphenation hyphenate ( char [ ] w , int offset , int len , int remainCharCount , int pushCharCount ) { int i ; char [ ] word = new char [ len + 3 ] ; char [ ] c = new char [ 2 ] ; int iIgnoreAtBeginning = 0 ; int iLength = len ; boolean bEndOfLetters = false ; for ( i = 1 ; i <= len ; i ++ ) { c [ 0 ] = w [ offset + i - 1 ] ; int nc = classmap . find ( c , 0 ) ; if ( nc < 0 ) { if ( i == ( 1 + iIgnoreAtBeginning ) ) { iIgnoreAtBeginning ++ ; } else { bEndOfLetters = true ; } iLength -- ; } else { if ( ! bEndOfLetters ) { word [ i - iIgnoreAtBeginning ] = ( char ) nc ; } else { return null ; } } } len = iLength ; if ( len < ( remainCharCount + pushCharCount ) ) { return null ; } int [ ] result = new int [ len + 1 ] ; int k = 0 ; String sw = new String ( word , 1 , len ) ; if ( stoplist . containsKey ( sw ) ) { ArrayList hw = ( ArrayList ) stoplist . get ( sw ) ; int j = 0 ; for ( i = 0 ; i < hw . size ( ) ; i ++ ) { Object o = hw . get ( i ) ; if ( o instanceof String ) { j += ( ( String ) o ) . length ( ) ; if ( j >= remainCharCount && j < ( len - pushCharCount ) ) { result [ k ++ ] = j + iIgnoreAtBeginning ; } } } } else { word [ 0 ] = '.' ; word [ len + 1 ] = '.' ; word [ len + 2 ] = 0 ; byte [ ] il = new byte [ len + 3 ] ; for ( i = 0 ; i < len + 1 ; i ++ ) { searchPatterns ( word , i , il ) ; } for ( i = 0 ; i < len ; i ++ ) { if ( ( ( il [ i + 1 ] & 1 ) == 1 ) && i >= remainCharCount && i <= ( len - pushCharCount ) ) { result [ k ++ ] = i + iIgnoreAtBeginning ; } } } if ( k > 0 ) { int [ ] res = new int [ k ] ; System . arraycopy ( result , 0 , res , 0 , k ) ; return new Hyphenation ( new String ( w , offset , len ) , res ) ; } else { return null ; } }
|
Hyphenate word and return an array of hyphenation points .
|
4,801
|
public static PdfFileSpecification url ( PdfWriter writer , String url ) { PdfFileSpecification fs = new PdfFileSpecification ( ) ; fs . writer = writer ; fs . put ( PdfName . FS , PdfName . URL ) ; fs . put ( PdfName . F , new PdfString ( url ) ) ; return fs ; }
|
Creates a file specification of type URL .
|
4,802
|
public static PdfFileSpecification fileExtern ( PdfWriter writer , String filePath ) { PdfFileSpecification fs = new PdfFileSpecification ( ) ; fs . writer = writer ; fs . put ( PdfName . F , new PdfString ( filePath ) ) ; fs . setUnicodeFileName ( filePath , false ) ; return fs ; }
|
Creates a file specification for an external file .
|
4,803
|
public PdfIndirectReference getReference ( ) throws IOException { if ( ref != null ) return ref ; ref = writer . addToBody ( this ) . getIndirectReference ( ) ; return ref ; }
|
Gets the indirect reference to this file specification . Multiple invocations will retrieve the same value .
|
4,804
|
public void addDescription ( String description , boolean unicode ) { put ( PdfName . DESC , new PdfString ( description , unicode ? PdfObject . TEXT_UNICODE : PdfObject . TEXT_PDFDOCENCODING ) ) ; }
|
Adds a description for the file that is specified here .
|
4,805
|
public void writeContent ( final OutputStream result ) throws IOException { result . write ( PARAGRAPH_DEFAULTS ) ; result . write ( PLAIN ) ; if ( inTable ) { result . write ( IN_TABLE ) ; } if ( this . lineLeading > 0 ) { result . write ( LINE_SPACING ) ; result . write ( intToByteArray ( this . lineLeading ) ) ; } for ( int i = 0 ; i < chunks . size ( ) ; i ++ ) { RtfBasicElement rbe = ( RtfBasicElement ) chunks . get ( i ) ; rbe . writeContent ( result ) ; } }
|
Write the content of this RtfPhrase . First resets to the paragraph defaults then if the RtfPhrase is in a RtfCell a marker for this is written and finally the RtfChunks of this RtfPhrase are written .
|
4,806
|
public void setInTable ( boolean inTable ) { super . setInTable ( inTable ) ; for ( int i = 0 ; i < this . chunks . size ( ) ; i ++ ) { ( ( RtfBasicElement ) this . chunks . get ( i ) ) . setInTable ( inTable ) ; } }
|
Sets whether this RtfPhrase is in a table . Sets the correct inTable setting for all child elements .
|
4,807
|
public void setInHeader ( boolean inHeader ) { super . setInHeader ( inHeader ) ; for ( int i = 0 ; i < this . chunks . size ( ) ; i ++ ) { ( ( RtfBasicElement ) this . chunks . get ( i ) ) . setInHeader ( inHeader ) ; } }
|
Sets whether this RtfPhrase is in a header . Sets the correct inTable setting for all child elements .
|
4,808
|
public void setRtfDocument ( RtfDocument doc ) { super . setRtfDocument ( doc ) ; for ( int i = 0 ; i < this . chunks . size ( ) ; i ++ ) { ( ( RtfBasicElement ) this . chunks . get ( i ) ) . setRtfDocument ( this . document ) ; } }
|
Sets the RtfDocument this RtfPhrase belongs to . Also sets the RtfDocument for all child elements .
|
4,809
|
protected static String getBaseName ( String name ) { if ( name . endsWith ( ",Bold" ) ) return name . substring ( 0 , name . length ( ) - 5 ) ; else if ( name . endsWith ( ",Italic" ) ) return name . substring ( 0 , name . length ( ) - 7 ) ; else if ( name . endsWith ( ",BoldItalic" ) ) return name . substring ( 0 , name . length ( ) - 11 ) ; else return name ; }
|
Gets the name without the modifiers Bold Italic or BoldItalic .
|
4,810
|
protected static String normalizeEncoding ( String enc ) { if ( enc . equals ( "winansi" ) || enc . equals ( "" ) ) return CP1252 ; else if ( enc . equals ( "macroman" ) ) return MACROMAN ; else return enc ; }
|
Normalize the encoding names . winansi is changed to Cp1252 and macroman is changed to MacRoman .
|
4,811
|
public static String createSubsetPrefix ( ) { StringBuilder sb = new StringBuilder ( 8 ) ; for ( int k = 0 ; k < 6 ; ++ k ) { sb . append ( ( char ) ( Math . random ( ) * 26 + 'A' ) ) ; } sb . append ( "+" ) ; return sb . toString ( ) ; }
|
Creates a unique subset prefix to be added to the font name when the font is embedded and subset .
|
4,812
|
public static InputStream getResourceStream ( String key , ClassLoader loader ) { if ( key . startsWith ( "/" ) ) key = key . substring ( 1 ) ; InputStream is = null ; if ( loader != null ) { is = loader . getResourceAsStream ( key ) ; if ( is != null ) return is ; } try { ClassLoader contextClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( contextClassLoader != null ) { is = contextClassLoader . getResourceAsStream ( key ) ; } } catch ( Throwable e ) { } if ( is == null ) { is = BaseFont . class . getResourceAsStream ( "/" + key ) ; } if ( is == null ) { is = ClassLoader . getSystemResourceAsStream ( key ) ; } return is ; }
|
Gets the font resources .
|
4,813
|
public void setCompressionLevel ( int compressionLevel ) { if ( compressionLevel < PdfStream . NO_COMPRESSION || compressionLevel > PdfStream . BEST_COMPRESSION ) this . compressionLevel = PdfStream . DEFAULT_COMPRESSION ; else this . compressionLevel = compressionLevel ; }
|
Sets the compression level to be used for the font streams .
|
4,814
|
public void listAnyObject ( PdfObject object ) { switch ( object . type ( ) ) { case PdfObject . ARRAY : listArray ( ( PdfArray ) object ) ; break ; case PdfObject . DICTIONARY : listDict ( ( PdfDictionary ) object ) ; break ; case PdfObject . STRING : out . println ( "(" + object . toString ( ) + ")" ) ; break ; default : out . println ( object . toString ( ) ) ; break ; } }
|
Visualizes a PDF object .
|
4,815
|
public void listDict ( PdfDictionary dictionary ) { out . println ( "<<" ) ; PdfName key ; PdfObject value ; for ( Iterator i = dictionary . getKeys ( ) . iterator ( ) ; i . hasNext ( ) ; ) { key = ( PdfName ) i . next ( ) ; value = dictionary . get ( key ) ; out . print ( key . toString ( ) ) ; out . print ( ' ' ) ; listAnyObject ( value ) ; } out . println ( ">>" ) ; }
|
Visualizes a PdfDictionary object .
|
4,816
|
public void listArray ( PdfArray array ) { out . println ( '[' ) ; for ( Iterator i = array . listIterator ( ) ; i . hasNext ( ) ; ) { PdfObject item = ( PdfObject ) i . next ( ) ; listAnyObject ( item ) ; } out . println ( ']' ) ; }
|
Visualizes a PdfArray object .
|
4,817
|
public void listStream ( PRStream stream , PdfReaderInstance reader ) { try { listDict ( stream ) ; out . println ( "startstream" ) ; byte [ ] b = PdfReader . getStreamBytes ( stream ) ; int len = b . length - 1 ; for ( int k = 0 ; k < len ; ++ k ) { if ( b [ k ] == '\r' && b [ k + 1 ] != '\n' ) b [ k ] = ( byte ) '\n' ; } out . println ( new String ( b ) ) ; out . println ( "endstream" ) ; } catch ( IOException e ) { System . err . println ( "I/O exception: " + e ) ; } }
|
Visualizes a Stream .
|
4,818
|
public void listPage ( PdfImportedPage iPage ) { int pageNum = iPage . getPageNumber ( ) ; PdfReaderInstance readerInst = iPage . getPdfReaderInstance ( ) ; PdfReader reader = readerInst . getReader ( ) ; PdfDictionary page = reader . getPageN ( pageNum ) ; listDict ( page ) ; PdfObject obj = PdfReader . getPdfObject ( page . get ( PdfName . CONTENTS ) ) ; if ( obj == null ) return ; switch ( obj . type ) { case PdfObject . STREAM : listStream ( ( PRStream ) obj , readerInst ) ; break ; case PdfObject . ARRAY : for ( Iterator i = ( ( PdfArray ) obj ) . listIterator ( ) ; i . hasNext ( ) ; ) { PdfObject o = PdfReader . getPdfObject ( ( PdfObject ) i . next ( ) ) ; listStream ( ( PRStream ) o , readerInst ) ; out . println ( "-----------" ) ; } break ; } }
|
Visualizes an imported page
|
4,819
|
protected void writeFieldInstContent ( OutputStream result ) throws IOException { result . write ( HYPERLINK ) ; result . write ( DELIMITER ) ; this . document . filterSpecialChar ( result , url , true , true ) ; }
|
Write the field instructions for this RtfAnchor . Sets the field type to HYPERLINK and then writes the url .
|
4,820
|
public boolean replace ( String namespaceURI , String localName , String value ) { NodeList nodes = domDocument . getElementsByTagNameNS ( namespaceURI , localName ) ; Node node ; if ( nodes . getLength ( ) == 0 ) return false ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { node = nodes . item ( i ) ; setNodeText ( domDocument , node , value ) ; } return true ; }
|
Replaces the content of a tag .
|
4,821
|
public byte [ ] serializeDoc ( ) throws IOException { XmlDomWriter xw = new XmlDomWriter ( ) ; ByteArrayOutputStream fout = new ByteArrayOutputStream ( ) ; xw . setOutput ( fout , null ) ; fout . write ( XmpWriter . XPACKET_PI_BEGIN . getBytes ( "UTF-8" ) ) ; fout . flush ( ) ; NodeList xmpmeta = domDocument . getElementsByTagName ( "x:xmpmeta" ) ; xw . write ( xmpmeta . item ( 0 ) ) ; fout . flush ( ) ; for ( int i = 0 ; i < 20 ; i ++ ) { fout . write ( XmpWriter . EXTRASPACE . getBytes ( ) ) ; } fout . write ( XmpWriter . XPACKET_PI_END_W . getBytes ( ) ) ; fout . close ( ) ; return fout . toByteArray ( ) ; }
|
Writes the document to a byte array .
|
4,822
|
public static String getJavaEncoding ( String iana ) { String IANA = iana . toUpperCase ( ) ; String jdec = ( String ) map . get ( IANA ) ; if ( jdec == null ) jdec = iana ; return jdec ; }
|
Gets the java encoding from the IANA encoding . If the encoding cannot be found it returns the input .
|
4,823
|
protected void copyFormat ( PdfPTable sourceTable ) { relativeWidths = new float [ sourceTable . getNumberOfColumns ( ) ] ; absoluteWidths = new float [ sourceTable . getNumberOfColumns ( ) ] ; System . arraycopy ( sourceTable . relativeWidths , 0 , relativeWidths , 0 , getNumberOfColumns ( ) ) ; System . arraycopy ( sourceTable . absoluteWidths , 0 , absoluteWidths , 0 , getNumberOfColumns ( ) ) ; totalWidth = sourceTable . totalWidth ; totalHeight = sourceTable . totalHeight ; currentRowIdx = 0 ; tableEvent = sourceTable . tableEvent ; runDirection = sourceTable . runDirection ; defaultCell = new PdfPCell ( sourceTable . defaultCell ) ; currentRow = new PdfPCell [ sourceTable . currentRow . length ] ; isColspan = sourceTable . isColspan ; splitRows = sourceTable . splitRows ; spacingAfter = sourceTable . spacingAfter ; spacingBefore = sourceTable . spacingBefore ; headerRows = sourceTable . headerRows ; footerRows = sourceTable . footerRows ; lockedWidth = sourceTable . lockedWidth ; extendLastRow = sourceTable . extendLastRow ; headersInEvent = sourceTable . headersInEvent ; widthPercentage = sourceTable . widthPercentage ; splitLate = sourceTable . splitLate ; skipFirstHeader = sourceTable . skipFirstHeader ; skipLastFooter = sourceTable . skipLastFooter ; horizontalAlignment = sourceTable . horizontalAlignment ; keepTogether = sourceTable . keepTogether ; complete = sourceTable . complete ; }
|
Copies the format of the sourceTable without copying the content .
|
4,824
|
protected byte [ ] getTSAResponse ( byte [ ] requestBytes ) throws Exception { URL url = new URL ( tsaURL ) ; URLConnection tsaConnection ; tsaConnection = ( URLConnection ) url . openConnection ( ) ; tsaConnection . setDoInput ( true ) ; tsaConnection . setDoOutput ( true ) ; tsaConnection . setUseCaches ( false ) ; tsaConnection . setRequestProperty ( "Content-Type" , "application/timestamp-query" ) ; tsaConnection . setRequestProperty ( "Content-Transfer-Encoding" , "binary" ) ; if ( ( tsaUsername != null ) && ! tsaUsername . equals ( "" ) ) { String userPassword = tsaUsername + ":" + tsaPassword ; tsaConnection . setRequestProperty ( "Authorization" , "Basic " + Base64 . encodeBytes ( userPassword . getBytes ( ) ) ) ; } OutputStream out = tsaConnection . getOutputStream ( ) ; out . write ( requestBytes ) ; out . close ( ) ; InputStream inp = tsaConnection . getInputStream ( ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ 1024 ] ; int bytesRead = 0 ; while ( ( bytesRead = inp . read ( buffer , 0 , buffer . length ) ) >= 0 ) { baos . write ( buffer , 0 , bytesRead ) ; } byte [ ] respBytes = baos . toByteArray ( ) ; String encoding = tsaConnection . getContentEncoding ( ) ; if ( encoding != null && encoding . equalsIgnoreCase ( "base64" ) ) { respBytes = Base64 . decode ( new String ( respBytes ) ) ; } return respBytes ; }
|
Get timestamp token - communications layer
|
4,825
|
byte [ ] convertToBytes ( String text ) { byte b [ ] = null ; switch ( fontType ) { case BaseFont . FONT_TYPE_T3 : return baseFont . convertToBytes ( text ) ; case BaseFont . FONT_TYPE_T1 : case BaseFont . FONT_TYPE_TT : { b = baseFont . convertToBytes ( text ) ; int len = b . length ; for ( int k = 0 ; k < len ; ++ k ) shortTag [ b [ k ] & 0xff ] = 1 ; break ; } case BaseFont . FONT_TYPE_CJK : { int len = text . length ( ) ; for ( int k = 0 ; k < len ; ++ k ) cjkTag . put ( cjkFont . getCidCode ( text . charAt ( k ) ) , 0 ) ; b = baseFont . convertToBytes ( text ) ; break ; } case BaseFont . FONT_TYPE_DOCUMENT : { b = baseFont . convertToBytes ( text ) ; break ; } case BaseFont . FONT_TYPE_TTUNI : { try { int len = text . length ( ) ; int metrics [ ] = null ; char glyph [ ] = new char [ len ] ; int i = 0 ; if ( symbolic ) { b = PdfEncodings . convertToBytes ( text , "symboltt" ) ; len = b . length ; for ( int k = 0 ; k < len ; ++ k ) { metrics = ttu . getMetricsTT ( b [ k ] & 0xff ) ; if ( metrics == null ) continue ; longTag . put ( Integer . valueOf ( metrics [ 0 ] ) , new int [ ] { metrics [ 0 ] , metrics [ 1 ] , ttu . getUnicodeDifferences ( b [ k ] & 0xff ) } ) ; glyph [ i ++ ] = ( char ) metrics [ 0 ] ; } } else { for ( int k = 0 ; k < len ; ++ k ) { int val ; if ( Utilities . isSurrogatePair ( text , k ) ) { val = Utilities . convertToUtf32 ( text , k ) ; k ++ ; } else { val = text . charAt ( k ) ; } metrics = ttu . getMetricsTT ( val ) ; if ( metrics == null ) continue ; int m0 = metrics [ 0 ] ; Integer gl = Integer . valueOf ( m0 ) ; if ( ! longTag . containsKey ( gl ) ) longTag . put ( gl , new int [ ] { m0 , metrics [ 1 ] , val } ) ; glyph [ i ++ ] = ( char ) m0 ; } } String s = new String ( glyph , 0 , i ) ; b = s . getBytes ( CJKFont . CJK_ENCODING ) ; } catch ( UnsupportedEncodingException e ) { throw new ExceptionConverter ( e ) ; } break ; } } return b ; }
|
Converts the text into bytes to be placed in the document . The conversion is done according to the font and the encoding and the characters used are stored .
|
4,826
|
void writeFont ( PdfWriter writer ) { try { switch ( fontType ) { case BaseFont . FONT_TYPE_T3 : baseFont . writeFont ( writer , indirectReference , null ) ; break ; case BaseFont . FONT_TYPE_T1 : case BaseFont . FONT_TYPE_TT : { int firstChar ; int lastChar ; for ( firstChar = 0 ; firstChar < 256 ; ++ firstChar ) { if ( shortTag [ firstChar ] != 0 ) break ; } for ( lastChar = 255 ; lastChar >= firstChar ; -- lastChar ) { if ( shortTag [ lastChar ] != 0 ) break ; } if ( firstChar > 255 ) { firstChar = 255 ; lastChar = 255 ; } baseFont . writeFont ( writer , indirectReference , new Object [ ] { Integer . valueOf ( firstChar ) , Integer . valueOf ( lastChar ) , shortTag , Boolean . valueOf ( subset ) } ) ; break ; } case BaseFont . FONT_TYPE_CJK : baseFont . writeFont ( writer , indirectReference , new Object [ ] { cjkTag } ) ; break ; case BaseFont . FONT_TYPE_TTUNI : baseFont . writeFont ( writer , indirectReference , new Object [ ] { longTag , Boolean . valueOf ( subset ) } ) ; break ; } } catch ( Exception e ) { throw new ExceptionConverter ( e ) ; } }
|
Writes the font definition to the document .
|
4,827
|
public void addSimpleColumn ( float left , float right ) { ColumnDef newCol = new ColumnDef ( left , right ) ; columnDefs . add ( newCol ) ; }
|
Add a simple rectangular column with specified left and right x position boundaries .
|
4,828
|
public void addRegularColumns ( float left , float right , float gutterWidth , int numColumns ) { float currX = left ; float width = right - left ; float colWidth = ( width - ( gutterWidth * ( numColumns - 1 ) ) ) / numColumns ; for ( int i = 0 ; i < numColumns ; i ++ ) { addSimpleColumn ( currX , currX + colWidth ) ; currX += colWidth + gutterWidth ; } }
|
Add the specified number of evenly spaced rectangular columns . Columns will be separated by the specified gutterWidth .
|
4,829
|
private float getHeight ( float [ ] left , float [ ] right ) { float max = Float . MIN_VALUE ; float min = Float . MAX_VALUE ; for ( int i = 0 ; i < left . length ; i += 2 ) { min = Math . min ( min , left [ i + 1 ] ) ; max = Math . max ( max , left [ i + 1 ] ) ; } for ( int i = 0 ; i < right . length ; i += 2 ) { min = Math . min ( min , right [ i + 1 ] ) ; max = Math . max ( max , right [ i + 1 ] ) ; } return max - min ; }
|
Figure out the height of a column from the border extents
|
4,830
|
private float getColumnBottom ( ) { if ( desiredHeight == AUTOMATIC ) { return document . bottom ( ) ; } else { return Math . max ( top - ( desiredHeight - totalHeight ) , document . bottom ( ) ) ; } }
|
Calculates the appropriate y position for the bottom of the columns on this page .
|
4,831
|
public void nextColumn ( ) throws DocumentException { currentColumn = ( currentColumn + 1 ) % columnDefs . size ( ) ; top = nextY ; if ( currentColumn == 0 ) { newPage ( ) ; } }
|
Moves the text insertion point to the beginning of the next column issuing a page break if needed .
|
4,832
|
int getElementID ( int column ) { if ( cells [ column ] == null ) return NULL ; else if ( Cell . class . isInstance ( cells [ column ] ) ) return CELL ; else if ( Table . class . isInstance ( cells [ column ] ) ) return TABLE ; return - 1 ; }
|
Returns the type - id of the element in a Row .
|
4,833
|
int getObjectID ( Object element ) { if ( element == null ) return NULL ; else if ( Cell . class . isInstance ( element ) ) return CELL ; else if ( Table . class . isInstance ( element ) ) return TABLE ; return - 1 ; }
|
Returns the type - id of an Object .
|
4,834
|
public boolean isEmpty ( ) { for ( int i = 0 ; i < columns ; i ++ ) { if ( cells [ i ] != null ) { return false ; } } return true ; }
|
Checks if the row is empty .
|
4,835
|
protected void closeIt ( ) throws IOException { for ( int k = 0 ; k < readers . size ( ) ; ++ k ) { ( ( PdfReader ) readers . get ( k ) ) . removeFields ( ) ; } for ( int r = 0 ; r < readers . size ( ) ; ++ r ) { PdfReader reader = ( PdfReader ) readers . get ( r ) ; for ( int page = 1 ; page <= reader . getNumberOfPages ( ) ; ++ page ) { pageRefs . add ( getNewReference ( reader . getPageOrigRef ( page ) ) ) ; pageDics . add ( reader . getPageN ( page ) ) ; } } mergeFields ( ) ; createAcroForms ( ) ; for ( int r = 0 ; r < readers . size ( ) ; ++ r ) { PdfReader reader = ( PdfReader ) readers . get ( r ) ; for ( int page = 1 ; page <= reader . getNumberOfPages ( ) ; ++ page ) { PdfDictionary dic = reader . getPageN ( page ) ; PdfIndirectReference pageRef = getNewReference ( reader . getPageOrigRef ( page ) ) ; PdfIndirectReference parent = root . addPageRef ( pageRef ) ; dic . put ( PdfName . PARENT , parent ) ; propagate ( dic , pageRef , false ) ; } } for ( Iterator it = readers2intrefs . entrySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) it . next ( ) ; PdfReader reader = ( PdfReader ) entry . getKey ( ) ; try { file = reader . getSafeFile ( ) ; file . reOpen ( ) ; IntHashtable t = ( IntHashtable ) entry . getValue ( ) ; int keys [ ] = t . toOrderedKeys ( ) ; for ( int k = 0 ; k < keys . length ; ++ k ) { PRIndirectReference ref = new PRIndirectReference ( reader , keys [ k ] ) ; addToBody ( PdfReader . getPdfObjectRelease ( ref ) , t . get ( keys [ k ] ) ) ; } } finally { try { file . close ( ) ; reader . close ( ) ; } catch ( Exception e ) { } } } pdf . close ( ) ; }
|
Creates the new PDF by merging the fields and forms .
|
4,836
|
protected boolean setVisited ( PRIndirectReference ref ) { IntHashtable refs = ( IntHashtable ) visited . get ( ref . getReader ( ) ) ; if ( refs != null ) return ( refs . put ( ref . getNumber ( ) , 1 ) != 0 ) ; else return false ; }
|
Sets a reference to visited in the copy process .
|
4,837
|
protected boolean isVisited ( PRIndirectReference ref ) { IntHashtable refs = ( IntHashtable ) visited . get ( ref . getReader ( ) ) ; if ( refs != null ) return refs . containsKey ( ref . getNumber ( ) ) ; else return false ; }
|
Checks if a reference has already been visited in the copy process .
|
4,838
|
protected boolean isPage ( PRIndirectReference ref ) { IntHashtable refs = ( IntHashtable ) pages2intrefs . get ( ref . getReader ( ) ) ; if ( refs != null ) return refs . containsKey ( ref . getNumber ( ) ) ; else return false ; }
|
Checks if a reference refers to a page object .
|
4,839
|
public static PdfObject getXfaObject ( PdfReader reader ) { PdfDictionary af = ( PdfDictionary ) PdfReader . getPdfObjectRelease ( reader . getCatalog ( ) . get ( PdfName . ACROFORM ) ) ; if ( af == null ) { return null ; } return PdfReader . getPdfObjectRelease ( af . get ( PdfName . XFA ) ) ; }
|
Return the XFA Object could be an array could be a Stream . Returns null f no XFA Object is present .
|
4,840
|
private void extractNodes ( ) { Node n = domDocument . getFirstChild ( ) ; while ( n . getChildNodes ( ) . getLength ( ) == 0 ) { n = n . getNextSibling ( ) ; } n = n . getFirstChild ( ) ; while ( n != null ) { if ( n . getNodeType ( ) == Node . ELEMENT_NODE ) { String s = n . getLocalName ( ) ; if ( s . equals ( "template" ) ) { templateNode = n ; templateSom = new Xml2SomTemplate ( n ) ; } else if ( s . equals ( "datasets" ) ) { datasetsNode = n ; datasetsSom = new Xml2SomDatasets ( n . getFirstChild ( ) ) ; } } n = n . getNextSibling ( ) ; } }
|
Extracts the nodes from the domDocument .
|
4,841
|
public static void setXfa ( XfaForm form , PdfReader reader , PdfWriter writer ) throws IOException { PdfDictionary af = ( PdfDictionary ) PdfReader . getPdfObjectRelease ( reader . getCatalog ( ) . get ( PdfName . ACROFORM ) ) ; if ( af == null ) { return ; } PdfObject xfa = getXfaObject ( reader ) ; if ( xfa . isArray ( ) ) { PdfArray ar = ( PdfArray ) xfa ; int t = - 1 ; int d = - 1 ; for ( int k = 0 ; k < ar . size ( ) ; k += 2 ) { PdfString s = ar . getAsString ( k ) ; if ( "template" . equals ( s . toString ( ) ) ) { t = k + 1 ; } if ( "datasets" . equals ( s . toString ( ) ) ) { d = k + 1 ; } } if ( t > - 1 && d > - 1 ) { reader . killXref ( ar . getAsIndirectObject ( t ) ) ; reader . killXref ( ar . getAsIndirectObject ( d ) ) ; PdfStream tStream = new PdfStream ( serializeDoc ( form . templateNode ) ) ; tStream . flateCompress ( writer . getCompressionLevel ( ) ) ; ar . set ( t , writer . addToBody ( tStream ) . getIndirectReference ( ) ) ; PdfStream dStream = new PdfStream ( serializeDoc ( form . datasetsNode ) ) ; dStream . flateCompress ( writer . getCompressionLevel ( ) ) ; ar . set ( d , writer . addToBody ( dStream ) . getIndirectReference ( ) ) ; af . put ( PdfName . XFA , new PdfArray ( ar ) ) ; return ; } } reader . killXref ( af . get ( PdfName . XFA ) ) ; PdfStream str = new PdfStream ( serializeDoc ( form . domDocument ) ) ; str . flateCompress ( writer . getCompressionLevel ( ) ) ; PdfIndirectReference ref = writer . addToBody ( str ) . getIndirectReference ( ) ; af . put ( PdfName . XFA , ref ) ; }
|
Sets the XFA key from a byte array . The old XFA is erased .
|
4,842
|
public static byte [ ] serializeDoc ( Node n ) throws IOException { XmlDomWriter xw = new XmlDomWriter ( ) ; ByteArrayOutputStream fout = new ByteArrayOutputStream ( ) ; xw . setOutput ( fout , null ) ; xw . setCanonical ( false ) ; xw . write ( n ) ; fout . close ( ) ; return fout . toByteArray ( ) ; }
|
Serializes a XML document to a byte array .
|
4,843
|
public String findFieldName ( String name , AcroFields af ) { HashMap items = af . getFields ( ) ; if ( items . containsKey ( name ) ) return name ; if ( acroFieldsSom == null ) { if ( items . isEmpty ( ) && xfaPresent ) acroFieldsSom = new AcroFieldsSearch ( datasetsSom . getName2Node ( ) . keySet ( ) ) ; else acroFieldsSom = new AcroFieldsSearch ( items . keySet ( ) ) ; } if ( acroFieldsSom . getAcroShort2LongName ( ) . containsKey ( name ) ) return ( String ) acroFieldsSom . getAcroShort2LongName ( ) . get ( name ) ; return acroFieldsSom . inverseSearchGlobal ( Xml2Som . splitParts ( name ) ) ; }
|
Finds the complete field name contained in the classic forms from a partial name .
|
4,844
|
public String findDatasetsName ( String name ) { if ( datasetsSom . getName2Node ( ) . containsKey ( name ) ) return name ; return datasetsSom . inverseSearchGlobal ( Xml2Som . splitParts ( name ) ) ; }
|
Finds the complete SOM name contained in the datasets section from a possibly partial name .
|
4,845
|
public void writeDefinition ( final OutputStream result ) throws IOException { if ( document . getDocumentSettings ( ) . isDocumentProtected ( ) ) { switch ( document . getDocumentSettings ( ) . getProtectionLevelRaw ( ) ) { case RtfProtection . LEVEL_FORMPROT : result . write ( FORMPROT ) ; break ; case RtfProtection . LEVEL_ANNOTPROT : result . write ( ANNOTPROT ) ; break ; case RtfProtection . LEVEL_REVPROT : result . write ( REVPROT ) ; break ; case RtfProtection . LEVEL_READPROT : result . write ( ANNOTPROT ) ; result . write ( READPROT ) ; break ; } result . write ( ENFORCEPROT ) ; result . write ( ( byte ) '1' ) ; result . write ( PROTLEVEL ) ; result . write ( document . getDocumentSettings ( ) . getProtectionLevelBytes ( ) ) ; } if ( document . getDocumentSettings ( ) . getReadOnlyRecommended ( ) ) { result . write ( READONLYRECOMMENDED ) ; result . write ( DELIMITER ) ; } }
|
Writes the RTF protection control words
|
4,846
|
public void emit ( byte [ ] buffer ) { buffer [ myOffset + 0 ] = ( byte ) ( ( value >>> 24 ) & 0xff ) ; buffer [ myOffset + 1 ] = ( byte ) ( ( value >>> 16 ) & 0xff ) ; buffer [ myOffset + 2 ] = ( byte ) ( ( value >>> 8 ) & 0xff ) ; buffer [ myOffset + 3 ] = ( byte ) ( ( value >>> 0 ) & 0xff ) ; }
|
this is incomplete!
|
4,847
|
PdfStream getFormXObject ( int compressionLevel ) throws IOException { PdfStream s = new PdfStream ( content . toByteArray ( ) ) ; s . put ( PdfName . TYPE , PdfName . XOBJECT ) ; s . put ( PdfName . SUBTYPE , PdfName . PS ) ; s . flateCompress ( compressionLevel ) ; return s ; }
|
Gets the stream representing this object .
|
4,848
|
private void processFont ( ) { this . fontName = this . fontName . trim ( ) ; if ( fontName . length ( ) == 0 ) return ; if ( fontNr . length ( ) == 0 ) return ; if ( fontName . length ( ) > 0 && fontName . indexOf ( ';' ) >= 0 ) { fontName = fontName . substring ( 0 , fontName . indexOf ( ';' ) ) ; } if ( this . rtfParser . isImport ( ) ) { if ( ! this . importHeader . importFont ( this . fontNr , this . fontName , Integer . parseInt ( "" . equals ( this . charset ) ? CHARSET_DEFAULT : this . charset ) ) ) { if ( this . falt . length ( ) > 0 ) { this . importHeader . importFont ( this . fontNr , this . falt , Integer . parseInt ( "" . equals ( this . charset ) ? CHARSET_DEFAULT : this . charset ) ) ; } } } if ( this . rtfParser . isConvert ( ) ) { String fName = this . fontName ; Font f1 = createfont ( fName ) ; if ( f1 . getBaseFont ( ) == null && this . falt . length ( ) > 0 ) f1 = createfont ( this . falt ) ; if ( f1 . getBaseFont ( ) == null ) { if ( FontFactory . COURIER . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . COURIER ) ; } else if ( FontFactory . HELVETICA . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . HELVETICA ) ; } else if ( FontFactory . TIMES . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . TIMES ) ; } else if ( FontFactory . SYMBOL . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . SYMBOL ) ; } else if ( FontFactory . ZAPFDINGBATS . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . ZAPFDINGBATS ) ; } else { f1 = FontFactory . getFont ( FontFactory . HELVETICA ) ; } } fontMap . put ( this . fontNr , f1 ) ; } this . setToDefaults ( ) ; }
|
Process the font information that was parsed from the input .
|
4,849
|
private Properties getEnvironmentVariables ( ) throws Throwable { Properties environmentVariables = new Properties ( ) ; String operatingSystem = System . getProperty ( "os.name" ) . toLowerCase ( ) ; Runtime runtime = Runtime . getRuntime ( ) ; Process process = null ; if ( operatingSystem . startsWith ( "windows 95" ) || operatingSystem . startsWith ( "windows 98" ) || operatingSystem . startsWith ( "me" ) ) { process = runtime . exec ( "command.com /c set" ) ; } else if ( operatingSystem . startsWith ( "windows" ) ) { process = runtime . exec ( "cmd.exe /c set" ) ; } else { process = runtime . exec ( "env" ) ; } BufferedReader environmentStream = new BufferedReader ( new InputStreamReader ( process . getInputStream ( ) ) ) ; String inputLine = "" ; int idx = - 1 ; while ( ( inputLine = environmentStream . readLine ( ) ) != null ) { idx = inputLine . indexOf ( '=' ) ; environmentVariables . setProperty ( inputLine . substring ( 0 , idx ) , inputLine . substring ( idx + 1 ) ) ; } return environmentVariables ; }
|
Utility method to load the environment variables .
|
4,850
|
public PdfObject getValue ( String v ) { switch ( fieldType ) { case TEXT : return new PdfString ( v , PdfObject . TEXT_UNICODE ) ; case DATE : return new PdfDate ( PdfDate . decode ( v ) ) ; case NUMBER : return new PdfNumber ( v ) ; } throw new IllegalArgumentException ( v + " is not an acceptable value for the field " + get ( PdfName . N ) . toString ( ) ) ; }
|
Returns a PdfObject that can be used as the value of a Collection Item .
|
4,851
|
public static PdfAction createLaunch ( String application , String parameters , String operation , String defaultDir ) { return new PdfAction ( application , parameters , operation , defaultDir ) ; }
|
Launches an application or a document .
|
4,852
|
public static PdfAction rendition ( String file , PdfFileSpecification fs , String mimeType , PdfIndirectReference ref ) throws IOException { PdfAction js = new PdfAction ( ) ; js . put ( PdfName . S , PdfName . RENDITION ) ; js . put ( PdfName . R , new PdfRendition ( file , fs , mimeType ) ) ; js . put ( new PdfName ( "OP" ) , new PdfNumber ( 0 ) ) ; js . put ( new PdfName ( "AN" ) , ref ) ; return js ; }
|
Creates a Rendition action
|
4,853
|
public static PdfAction javaScript ( String code , PdfWriter writer , boolean unicode ) { PdfAction js = new PdfAction ( ) ; js . put ( PdfName . S , PdfName . JAVASCRIPT ) ; if ( unicode && code . length ( ) < 50 ) { js . put ( PdfName . JS , new PdfString ( code , PdfObject . TEXT_UNICODE ) ) ; } else if ( ! unicode && code . length ( ) < 100 ) { js . put ( PdfName . JS , new PdfString ( code ) ) ; } else { try { byte b [ ] = PdfEncodings . convertToBytes ( code , unicode ? PdfObject . TEXT_UNICODE : PdfObject . TEXT_PDFDOCENCODING ) ; PdfStream stream = new PdfStream ( b ) ; stream . flateCompress ( writer . getCompressionLevel ( ) ) ; js . put ( PdfName . JS , writer . addToBody ( stream ) . getIndirectReference ( ) ) ; } catch ( Exception e ) { js . put ( PdfName . JS , new PdfString ( code ) ) ; } } return js ; }
|
Creates a JavaScript action . If the JavaScript is smaller than 50 characters it will be placed as a string otherwise it will be placed as a compressed stream .
|
4,854
|
public static PdfAction javaScript ( String code , PdfWriter writer ) { return javaScript ( code , writer , false ) ; }
|
Creates a JavaScript action . If the JavaScript is smaller than 50 characters it will be place as a string otherwise it will be placed as a compressed stream .
|
4,855
|
static PdfAction createHide ( PdfObject obj , boolean hide ) { PdfAction action = new PdfAction ( ) ; action . put ( PdfName . S , PdfName . HIDE ) ; action . put ( PdfName . T , obj ) ; if ( ! hide ) action . put ( PdfName . H , PdfBoolean . PDFFALSE ) ; return action ; }
|
A Hide action hides or shows an object .
|
4,856
|
public static PdfAction createSubmitForm ( String file , Object names [ ] , int flags ) { PdfAction action = new PdfAction ( ) ; action . put ( PdfName . S , PdfName . SUBMITFORM ) ; PdfDictionary dic = new PdfDictionary ( ) ; dic . put ( PdfName . F , new PdfString ( file ) ) ; dic . put ( PdfName . FS , PdfName . URL ) ; action . put ( PdfName . F , dic ) ; if ( names != null ) action . put ( PdfName . FIELDS , buildArray ( names ) ) ; action . put ( PdfName . FLAGS , new PdfNumber ( flags ) ) ; return action ; }
|
Creates a submit form .
|
4,857
|
public static PdfAction createResetForm ( Object names [ ] , int flags ) { PdfAction action = new PdfAction ( ) ; action . put ( PdfName . S , PdfName . RESETFORM ) ; if ( names != null ) action . put ( PdfName . FIELDS , buildArray ( names ) ) ; action . put ( PdfName . FLAGS , new PdfNumber ( flags ) ) ; return action ; }
|
Creates a resetform .
|
4,858
|
public static PdfAction createImportData ( String file ) { PdfAction action = new PdfAction ( ) ; action . put ( PdfName . S , PdfName . IMPORTDATA ) ; action . put ( PdfName . F , new PdfString ( file ) ) ; return action ; }
|
Creates an Import field .
|
4,859
|
public void next ( PdfAction na ) { PdfObject nextAction = get ( PdfName . NEXT ) ; if ( nextAction == null ) put ( PdfName . NEXT , na ) ; else if ( nextAction . isDictionary ( ) ) { PdfArray array = new PdfArray ( nextAction ) ; array . add ( na ) ; put ( PdfName . NEXT , array ) ; } else { ( ( PdfArray ) nextAction ) . add ( na ) ; } }
|
Add a chained action .
|
4,860
|
public static PdfAction gotoLocalPage ( int page , PdfDestination dest , PdfWriter writer ) { PdfIndirectReference ref = writer . getPageReference ( page ) ; dest . addPage ( ref ) ; PdfAction action = new PdfAction ( ) ; action . put ( PdfName . S , PdfName . GOTO ) ; action . put ( PdfName . D , dest ) ; return action ; }
|
Creates a GoTo action to an internal page .
|
4,861
|
public static PdfAction gotoLocalPage ( String dest , boolean isName ) { PdfAction action = new PdfAction ( ) ; action . put ( PdfName . S , PdfName . GOTO ) ; if ( isName ) action . put ( PdfName . D , new PdfName ( dest ) ) ; else action . put ( PdfName . D , new PdfString ( dest , null ) ) ; return action ; }
|
Creates a GoTo action to a named destination .
|
4,862
|
public static PdfAction gotoRemotePage ( String filename , String dest , boolean isName , boolean newWindow ) { PdfAction action = new PdfAction ( ) ; action . put ( PdfName . F , new PdfString ( filename ) ) ; action . put ( PdfName . S , PdfName . GOTOR ) ; if ( isName ) action . put ( PdfName . D , new PdfName ( dest ) ) ; else action . put ( PdfName . D , new PdfString ( dest , null ) ) ; if ( newWindow ) action . put ( PdfName . NEWWINDOW , PdfBoolean . PDFTRUE ) ; return action ; }
|
Creates a GoToR action to a named destination .
|
4,863
|
public void addIdentifiers ( String [ ] id ) { XmpArray array = new XmpArray ( XmpArray . UNORDERED ) ; for ( int i = 0 ; i < id . length ; i ++ ) { array . add ( id [ i ] ) ; } setProperty ( IDENTIFIER , array ) ; }
|
Adds the identifier .
|
4,864
|
protected void setGreekFont ( ) { float fontsize = symbol . getFont ( ) . getSize ( ) ; symbol . setFont ( FontFactory . getFont ( FontFactory . SYMBOL , fontsize , Font . NORMAL ) ) ; }
|
change the font to SYMBOL
|
4,865
|
public void writeContent ( final OutputStream result ) throws IOException { result . write ( OPEN_GROUP ) ; result . write ( INFO_GROUP ) ; for ( int i = 0 ; i < infoElements . size ( ) ; i ++ ) { RtfInfoElement infoElement = ( RtfInfoElement ) infoElements . get ( i ) ; infoElement . writeContent ( result ) ; } if ( document . getDocumentSettings ( ) . isDocumentProtected ( ) ) { result . write ( OPEN_GROUP ) ; result . write ( INFO_PASSWORD ) ; result . write ( DELIMITER ) ; result . write ( document . getDocumentSettings ( ) . getProtectionHashBytes ( ) ) ; result . write ( CLOSE_GROUP ) ; } result . write ( CLOSE_GROUP ) ; this . document . outputDebugLinebreak ( result ) ; }
|
Writes the RTF information group and its elements .
|
4,866
|
private void processColor ( ) { if ( red != - 1 && green != - 1 && blue != - 1 ) { if ( this . rtfParser . isImport ( ) ) { this . importHeader . importColor ( Integer . toString ( this . colorNr ) , new Color ( this . red , this . green , this . blue ) ) ; } if ( this . rtfParser . isConvert ( ) ) { colorMap . put ( Integer . toString ( this . colorNr ) , new Color ( this . red , this . green , this . blue ) ) ; } } this . setToDefaults ( ) ; this . colorNr ++ ; }
|
Processes the color triplet parsed from the document . Add it to the import mapping so colors can be mapped when encountered in the RTF import or conversion .
|
4,867
|
public Phrase process ( String text ) { int fsize = fonts . size ( ) ; if ( fsize == 0 ) throw new IndexOutOfBoundsException ( "No font is defined." ) ; char cc [ ] = text . toCharArray ( ) ; int len = cc . length ; StringBuffer sb = new StringBuffer ( ) ; Font font = null ; int lastidx = - 1 ; Phrase ret = new Phrase ( ) ; for ( int k = 0 ; k < len ; ++ k ) { char c = cc [ k ] ; if ( c == '\n' || c == '\r' ) { sb . append ( c ) ; continue ; } if ( Utilities . isSurrogatePair ( cc , k ) ) { int u = Utilities . convertToUtf32 ( cc , k ) ; for ( int f = 0 ; f < fsize ; ++ f ) { font = ( Font ) fonts . get ( f ) ; if ( font . getBaseFont ( ) . charExists ( u ) ) { if ( lastidx != f ) { if ( sb . length ( ) > 0 && lastidx != - 1 ) { Chunk ck = new Chunk ( sb . toString ( ) , ( Font ) fonts . get ( lastidx ) ) ; ret . add ( ck ) ; sb . setLength ( 0 ) ; } lastidx = f ; } sb . append ( c ) ; sb . append ( cc [ ++ k ] ) ; break ; } } } else { for ( int f = 0 ; f < fsize ; ++ f ) { font = ( Font ) fonts . get ( f ) ; if ( font . getBaseFont ( ) . charExists ( c ) ) { if ( lastidx != f ) { if ( sb . length ( ) > 0 && lastidx != - 1 ) { Chunk ck = new Chunk ( sb . toString ( ) , ( Font ) fonts . get ( lastidx ) ) ; ret . add ( ck ) ; sb . setLength ( 0 ) ; } lastidx = f ; } sb . append ( c ) ; break ; } } } } if ( sb . length ( ) > 0 ) { Chunk ck = new Chunk ( sb . toString ( ) , ( Font ) fonts . get ( lastidx == - 1 ? 0 : lastidx ) ) ; ret . add ( ck ) ; } return ret ; }
|
Process the text so that it will render with a combination of fonts if needed .
|
4,868
|
public PdfDictionary getDeveloperExtensions ( ) { PdfDictionary developerextensions = new PdfDictionary ( ) ; developerextensions . put ( PdfName . BASEVERSION , baseversion ) ; developerextensions . put ( PdfName . EXTENSIONLEVEL , new PdfNumber ( extensionLevel ) ) ; return developerextensions ; }
|
Generations the developer extension dictionary corresponding with the prefix .
|
4,869
|
public PdfFormField getField ( ) throws IOException , DocumentException { PdfFormField field = PdfFormField . createPushButton ( writer ) ; field . setWidget ( box , PdfAnnotation . HIGHLIGHT_INVERT ) ; if ( fieldName != null ) { field . setFieldName ( fieldName ) ; if ( ( options & READ_ONLY ) != 0 ) field . setFieldFlags ( PdfFormField . FF_READ_ONLY ) ; if ( ( options & REQUIRED ) != 0 ) field . setFieldFlags ( PdfFormField . FF_REQUIRED ) ; } if ( text != null ) field . setMKNormalCaption ( text ) ; if ( rotation != 0 ) field . setMKRotation ( rotation ) ; field . setBorderStyle ( new PdfBorderDictionary ( borderWidth , borderStyle , new PdfDashPattern ( 3 ) ) ) ; PdfAppearance tpa = getAppearance ( ) ; field . setAppearance ( PdfAnnotation . APPEARANCE_NORMAL , tpa ) ; PdfAppearance da = ( PdfAppearance ) tpa . getDuplicate ( ) ; da . setFontAndSize ( getRealFont ( ) , fontSize ) ; if ( textColor == null ) da . setGrayFill ( 0 ) ; else da . setColorFill ( textColor ) ; field . setDefaultAppearanceString ( da ) ; if ( borderColor != null ) field . setMKBorderColor ( borderColor ) ; if ( backgroundColor != null ) field . setMKBackgroundColor ( backgroundColor ) ; switch ( visibility ) { case HIDDEN : field . setFlags ( PdfAnnotation . FLAGS_PRINT | PdfAnnotation . FLAGS_HIDDEN ) ; break ; case VISIBLE_BUT_DOES_NOT_PRINT : break ; case HIDDEN_BUT_PRINTABLE : field . setFlags ( PdfAnnotation . FLAGS_PRINT | PdfAnnotation . FLAGS_NOVIEW ) ; break ; default : field . setFlags ( PdfAnnotation . FLAGS_PRINT ) ; break ; } if ( tp != null ) field . setMKNormalIcon ( tp ) ; field . setMKTextPosition ( layout - 1 ) ; PdfName scale = PdfName . A ; if ( scaleIcon == SCALE_ICON_IS_TOO_BIG ) scale = PdfName . B ; else if ( scaleIcon == SCALE_ICON_IS_TOO_SMALL ) scale = PdfName . S ; else if ( scaleIcon == SCALE_ICON_NEVER ) scale = PdfName . N ; field . setMKIconFit ( scale , proportionalIcon ? PdfName . P : PdfName . A , iconHorizontalAdjustment , iconVerticalAdjustment , iconFitToBounds ) ; return field ; }
|
Gets the pushbutton field .
|
4,870
|
public void setEncryption ( Certificate [ ] certs , int [ ] permissions , int encryptionType ) throws DocumentException { if ( stamper . isAppend ( ) ) throw new DocumentException ( "Append mode does not support changing the encryption status." ) ; if ( stamper . isContentWritten ( ) ) throw new DocumentException ( "Content was already written to the output." ) ; stamper . setEncryption ( certs , permissions , encryptionType ) ; }
|
Sets the certificate encryption options for this document . An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate . The open permissions for the document can be AllowPrinting AllowModifyContents AllowCopy AllowModifyAnnotations AllowFillIn AllowScreenReaders AllowAssembly and AllowDegradedPrinting . The permissions can be combined by ORing them . Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
|
4,871
|
public PdfFormField addSignature ( String name , int page , float llx , float lly , float urx , float ury ) { PdfAcroForm acroForm = stamper . getAcroForm ( ) ; PdfFormField signature = PdfFormField . createSignature ( stamper ) ; acroForm . setSignatureParams ( signature , name , llx , lly , urx , ury ) ; acroForm . drawSignatureAppearences ( signature , llx , lly , urx , ury ) ; addAnnotation ( signature , page ) ; return signature ; }
|
Adds an empty signature .
|
4,872
|
public void setThumbnail ( Image image , int page ) throws PdfException , DocumentException { stamper . setThumbnail ( image , page ) ; }
|
Sets the thumbnail image for a page .
|
4,873
|
public void setListSymbol ( Chunk symbol ) { if ( this . symbol == null ) { this . symbol = symbol ; if ( this . symbol . getFont ( ) . isStandardFont ( ) ) { this . symbol . setFont ( font ) ; } } }
|
Sets the listsymbol .
|
4,874
|
protected static String getTTCName ( String name ) { int idx = name . toLowerCase ( ) . indexOf ( ".ttc," ) ; if ( idx < 0 ) return name ; else return name . substring ( 0 , idx + 4 ) ; }
|
Gets the name from a composed TTC file name . If I have for input myfont . ttc 2 the return will be myfont . ttc .
|
4,875
|
String getBaseFont ( ) throws DocumentException , IOException { int table_location [ ] ; table_location = ( int [ ] ) tables . get ( "name" ) ; if ( table_location == null ) throw new DocumentException ( "Table 'name' does not exist in " + fileName + style ) ; rf . seek ( table_location [ 0 ] + 2 ) ; int numRecords = rf . readUnsignedShort ( ) ; int startOfStorage = rf . readUnsignedShort ( ) ; for ( int k = 0 ; k < numRecords ; ++ k ) { int platformID = rf . readUnsignedShort ( ) ; @ SuppressWarnings ( "unused" ) int platformEncodingID = rf . readUnsignedShort ( ) ; @ SuppressWarnings ( "unused" ) int languageID = rf . readUnsignedShort ( ) ; int nameID = rf . readUnsignedShort ( ) ; int length = rf . readUnsignedShort ( ) ; int offset = rf . readUnsignedShort ( ) ; if ( nameID == 6 ) { rf . seek ( table_location [ 0 ] + startOfStorage + offset ) ; if ( platformID == 0 || platformID == 3 ) return readUnicodeString ( length ) ; else return readStandardString ( length ) ; } } File file = new File ( fileName ) ; return file . getName ( ) . replace ( ' ' , '-' ) ; }
|
Gets the Postscript font name .
|
4,876
|
String [ ] [ ] getNames ( int id ) throws DocumentException , IOException { int table_location [ ] ; table_location = ( int [ ] ) tables . get ( "name" ) ; if ( table_location == null ) throw new DocumentException ( "Table 'name' does not exist in " + fileName + style ) ; rf . seek ( table_location [ 0 ] + 2 ) ; int numRecords = rf . readUnsignedShort ( ) ; int startOfStorage = rf . readUnsignedShort ( ) ; ArrayList names = new ArrayList ( ) ; for ( int k = 0 ; k < numRecords ; ++ k ) { int platformID = rf . readUnsignedShort ( ) ; int platformEncodingID = rf . readUnsignedShort ( ) ; int languageID = rf . readUnsignedShort ( ) ; int nameID = rf . readUnsignedShort ( ) ; int length = rf . readUnsignedShort ( ) ; int offset = rf . readUnsignedShort ( ) ; if ( nameID == id ) { int pos = rf . getFilePointer ( ) ; rf . seek ( table_location [ 0 ] + startOfStorage + offset ) ; String name ; if ( platformID == 0 || platformID == 3 || ( platformID == 2 && platformEncodingID == 1 ) ) { name = readUnicodeString ( length ) ; } else { name = readStandardString ( length ) ; } names . add ( new String [ ] { String . valueOf ( platformID ) , String . valueOf ( platformEncodingID ) , String . valueOf ( languageID ) , name } ) ; rf . seek ( pos ) ; } } String thisName [ ] [ ] = new String [ names . size ( ) ] [ ] ; for ( int k = 0 ; k < names . size ( ) ; ++ k ) thisName [ k ] = ( String [ ] ) names . get ( k ) ; return thisName ; }
|
Extracts the names of the font in all the languages available .
|
4,877
|
void process ( byte ttfAfm [ ] , boolean preload ) throws DocumentException , IOException { tables = new HashMap ( ) ; try { if ( ttfAfm == null ) rf = new RandomAccessFileOrArray ( fileName , preload , Document . plainRandomAccess ) ; else rf = new RandomAccessFileOrArray ( ttfAfm ) ; if ( ttcIndex . length ( ) > 0 ) { int dirIdx = Integer . parseInt ( ttcIndex ) ; if ( dirIdx < 0 ) throw new DocumentException ( "The font index for " + fileName + " must be positive." ) ; String mainTag = readStandardString ( 4 ) ; if ( ! mainTag . equals ( "ttcf" ) ) throw new DocumentException ( fileName + " is not a valid TTC file." ) ; rf . skipBytes ( 4 ) ; int dirCount = rf . readInt ( ) ; if ( dirIdx >= dirCount ) throw new DocumentException ( "The font index for " + fileName + " must be between 0 and " + ( dirCount - 1 ) + ". It was " + dirIdx + "." ) ; rf . skipBytes ( dirIdx * 4 ) ; directoryOffset = rf . readInt ( ) ; } rf . seek ( directoryOffset ) ; int ttId = rf . readInt ( ) ; if ( ttId != 0x00010000 && ttId != 0x4F54544F ) throw new DocumentException ( fileName + " is not a valid TTF or OTF file." ) ; int num_tables = rf . readUnsignedShort ( ) ; rf . skipBytes ( 6 ) ; for ( int k = 0 ; k < num_tables ; ++ k ) { String tag = readStandardString ( 4 ) ; rf . skipBytes ( 4 ) ; int table_location [ ] = new int [ 2 ] ; table_location [ 0 ] = rf . readInt ( ) ; table_location [ 1 ] = rf . readInt ( ) ; tables . put ( tag , table_location ) ; } checkCff ( ) ; fontName = getBaseFont ( ) ; fullName = getNames ( 4 ) ; familyName = getNames ( 1 ) ; allNameEntries = getAllNames ( ) ; if ( ! justNames ) { fillTables ( ) ; readGlyphWidths ( ) ; readCMaps ( ) ; readKerning ( ) ; readBbox ( ) ; } } finally { if ( rf != null ) { rf . close ( ) ; if ( ! embedded ) rf = null ; } } }
|
Reads the font data .
|
4,878
|
protected void readGlyphWidths ( ) throws DocumentException , IOException { int table_location [ ] ; table_location = ( int [ ] ) tables . get ( "hmtx" ) ; if ( table_location == null ) throw new DocumentException ( "Table 'hmtx' does not exist in " + fileName + style ) ; rf . seek ( table_location [ 0 ] ) ; GlyphWidths = new int [ hhea . numberOfHMetrics ] ; for ( int k = 0 ; k < hhea . numberOfHMetrics ; ++ k ) { GlyphWidths [ k ] = ( rf . readUnsignedShort ( ) * 1000 ) / head . unitsPerEm ; rf . readUnsignedShort ( ) ; } }
|
Reads the glyphs widths . The widths are extracted from the table hmtx . The glyphs are normalized to 1000 units .
|
4,879
|
protected int getGlyphWidth ( int glyph ) { if ( glyph >= GlyphWidths . length ) glyph = GlyphWidths . length - 1 ; return GlyphWidths [ glyph ] ; }
|
Gets a glyph width .
|
4,880
|
void readCMaps ( ) throws DocumentException , IOException { int table_location [ ] ; table_location = ( int [ ] ) tables . get ( "cmap" ) ; if ( table_location == null ) throw new DocumentException ( "Table 'cmap' does not exist in " + fileName + style ) ; rf . seek ( table_location [ 0 ] ) ; rf . skipBytes ( 2 ) ; int num_tables = rf . readUnsignedShort ( ) ; fontSpecific = false ; int map10 = 0 ; int map31 = 0 ; int map30 = 0 ; int mapExt = 0 ; for ( int k = 0 ; k < num_tables ; ++ k ) { int platId = rf . readUnsignedShort ( ) ; int platSpecId = rf . readUnsignedShort ( ) ; int offset = rf . readInt ( ) ; if ( platId == 3 && platSpecId == 0 ) { fontSpecific = true ; map30 = offset ; } else if ( platId == 3 && platSpecId == 1 ) { map31 = offset ; } else if ( platId == 3 && platSpecId == 10 ) { mapExt = offset ; } if ( platId == 1 && platSpecId == 0 ) { map10 = offset ; } } if ( map10 > 0 ) { rf . seek ( table_location [ 0 ] + map10 ) ; int format = rf . readUnsignedShort ( ) ; switch ( format ) { case 0 : cmap10 = readFormat0 ( ) ; break ; case 4 : cmap10 = readFormat4 ( ) ; break ; case 6 : cmap10 = readFormat6 ( ) ; break ; } } if ( map31 > 0 ) { rf . seek ( table_location [ 0 ] + map31 ) ; int format = rf . readUnsignedShort ( ) ; if ( format == 4 ) { cmap31 = readFormat4 ( ) ; } } if ( map30 > 0 ) { rf . seek ( table_location [ 0 ] + map30 ) ; int format = rf . readUnsignedShort ( ) ; if ( format == 4 ) { cmap10 = readFormat4 ( ) ; } } if ( mapExt > 0 ) { rf . seek ( table_location [ 0 ] + mapExt ) ; int format = rf . readUnsignedShort ( ) ; switch ( format ) { case 0 : cmapExt = readFormat0 ( ) ; break ; case 4 : cmapExt = readFormat4 ( ) ; break ; case 6 : cmapExt = readFormat6 ( ) ; break ; case 12 : cmapExt = readFormat12 ( ) ; break ; } } }
|
Reads the several maps from the table cmap . The maps of interest are 1 . 0 for symbolic fonts and 3 . 1 for all others . A symbolic font is defined as having the map 3 . 0 .
|
4,881
|
HashMap readFormat0 ( ) throws IOException { HashMap h = new HashMap ( ) ; rf . skipBytes ( 4 ) ; for ( int k = 0 ; k < 256 ; ++ k ) { int r [ ] = new int [ 2 ] ; r [ 0 ] = rf . readUnsignedByte ( ) ; r [ 1 ] = getGlyphWidth ( r [ 0 ] ) ; h . put ( Integer . valueOf ( k ) , r ) ; } return h ; }
|
The information in the maps of the table cmap is coded in several formats . Format 0 is the Apple standard character to glyph index mapping table .
|
4,882
|
HashMap readFormat4 ( ) throws IOException { HashMap h = new HashMap ( ) ; int table_lenght = rf . readUnsignedShort ( ) ; rf . skipBytes ( 2 ) ; int segCount = rf . readUnsignedShort ( ) / 2 ; rf . skipBytes ( 6 ) ; int endCount [ ] = new int [ segCount ] ; for ( int k = 0 ; k < segCount ; ++ k ) { endCount [ k ] = rf . readUnsignedShort ( ) ; } rf . skipBytes ( 2 ) ; int startCount [ ] = new int [ segCount ] ; for ( int k = 0 ; k < segCount ; ++ k ) { startCount [ k ] = rf . readUnsignedShort ( ) ; } int idDelta [ ] = new int [ segCount ] ; for ( int k = 0 ; k < segCount ; ++ k ) { idDelta [ k ] = rf . readUnsignedShort ( ) ; } int idRO [ ] = new int [ segCount ] ; for ( int k = 0 ; k < segCount ; ++ k ) { idRO [ k ] = rf . readUnsignedShort ( ) ; } int glyphId [ ] = new int [ table_lenght / 2 - 8 - segCount * 4 ] ; for ( int k = 0 ; k < glyphId . length ; ++ k ) { glyphId [ k ] = rf . readUnsignedShort ( ) ; } for ( int k = 0 ; k < segCount ; ++ k ) { int glyph ; for ( int j = startCount [ k ] ; j <= endCount [ k ] && j != 0xFFFF ; ++ j ) { if ( idRO [ k ] == 0 ) { glyph = ( j + idDelta [ k ] ) & 0xFFFF ; } else { int idx = k + idRO [ k ] / 2 - segCount + j - startCount [ k ] ; if ( idx >= glyphId . length ) continue ; glyph = ( glyphId [ idx ] + idDelta [ k ] ) & 0xFFFF ; } int r [ ] = new int [ 2 ] ; r [ 0 ] = glyph ; r [ 1 ] = getGlyphWidth ( r [ 0 ] ) ; h . put ( Integer . valueOf ( fontSpecific ? ( ( j & 0xff00 ) == 0xf000 ? j & 0xff : j ) : j ) , r ) ; } } return h ; }
|
The information in the maps of the table cmap is coded in several formats . Format 4 is the Microsoft standard character to glyph index mapping table .
|
4,883
|
HashMap readFormat6 ( ) throws IOException { HashMap h = new HashMap ( ) ; rf . skipBytes ( 4 ) ; int start_code = rf . readUnsignedShort ( ) ; int code_count = rf . readUnsignedShort ( ) ; for ( int k = 0 ; k < code_count ; ++ k ) { int r [ ] = new int [ 2 ] ; r [ 0 ] = rf . readUnsignedShort ( ) ; r [ 1 ] = getGlyphWidth ( r [ 0 ] ) ; h . put ( Integer . valueOf ( k + start_code ) , r ) ; } return h ; }
|
The information in the maps of the table cmap is coded in several formats . Format 6 is a trimmed table mapping . It is similar to format 0 but can have less than 256 entries .
|
4,884
|
void readKerning ( ) throws IOException { int table_location [ ] ; table_location = ( int [ ] ) tables . get ( "kern" ) ; if ( table_location == null ) return ; rf . seek ( table_location [ 0 ] + 2 ) ; int nTables = rf . readUnsignedShort ( ) ; int checkpoint = table_location [ 0 ] + 4 ; int length = 0 ; for ( int k = 0 ; k < nTables ; ++ k ) { checkpoint += length ; rf . seek ( checkpoint ) ; rf . skipBytes ( 2 ) ; length = rf . readUnsignedShort ( ) ; int coverage = rf . readUnsignedShort ( ) ; if ( ( coverage & 0xfff7 ) == 0x0001 ) { int nPairs = rf . readUnsignedShort ( ) ; rf . skipBytes ( 6 ) ; for ( int j = 0 ; j < nPairs ; ++ j ) { int pair = rf . readInt ( ) ; int value = rf . readShort ( ) * 1000 / head . unitsPerEm ; kerning . put ( pair , value ) ; } } } }
|
Reads the kerning information from the kern table .
|
4,885
|
public int getKerning ( int char1 , int char2 ) { int metrics [ ] = getMetricsTT ( char1 ) ; if ( metrics == null ) return 0 ; int c1 = metrics [ 0 ] ; metrics = getMetricsTT ( char2 ) ; if ( metrics == null ) return 0 ; int c2 = metrics [ 0 ] ; return kerning . get ( ( c1 << 16 ) + c2 ) ; }
|
Gets the kerning between two Unicode chars .
|
4,886
|
protected PdfDictionary getFontDescriptor ( PdfIndirectReference fontStream , String subsetPrefix , PdfIndirectReference cidset ) { PdfDictionary dic = new PdfDictionary ( PdfName . FONTDESCRIPTOR ) ; dic . put ( PdfName . ASCENT , new PdfNumber ( os_2 . sTypoAscender * 1000 / head . unitsPerEm ) ) ; dic . put ( PdfName . CAPHEIGHT , new PdfNumber ( os_2 . sCapHeight * 1000 / head . unitsPerEm ) ) ; dic . put ( PdfName . DESCENT , new PdfNumber ( os_2 . sTypoDescender * 1000 / head . unitsPerEm ) ) ; dic . put ( PdfName . FONTBBOX , new PdfRectangle ( head . xMin * 1000 / head . unitsPerEm , head . yMin * 1000 / head . unitsPerEm , head . xMax * 1000 / head . unitsPerEm , head . yMax * 1000 / head . unitsPerEm ) ) ; if ( cidset != null ) dic . put ( PdfName . CIDSET , cidset ) ; if ( cff ) { if ( encoding . startsWith ( "Identity-" ) ) dic . put ( PdfName . FONTNAME , new PdfName ( subsetPrefix + fontName + "-" + encoding ) ) ; else dic . put ( PdfName . FONTNAME , new PdfName ( subsetPrefix + fontName + style ) ) ; } else dic . put ( PdfName . FONTNAME , new PdfName ( subsetPrefix + fontName + style ) ) ; dic . put ( PdfName . ITALICANGLE , new PdfNumber ( italicAngle ) ) ; dic . put ( PdfName . STEMV , new PdfNumber ( 80 ) ) ; if ( fontStream != null ) { if ( cff ) dic . put ( PdfName . FONTFILE3 , fontStream ) ; else dic . put ( PdfName . FONTFILE2 , fontStream ) ; } int flags = 0 ; if ( isFixedPitch ) flags |= 1 ; flags |= fontSpecific ? 4 : 32 ; if ( ( head . macStyle & 2 ) != 0 ) flags |= 64 ; if ( ( head . macStyle & 1 ) != 0 ) flags |= 262144 ; dic . put ( PdfName . FLAGS , new PdfNumber ( flags ) ) ; return dic ; }
|
Generates the font descriptor for this font .
|
4,887
|
public PdfStream getFullFontStream ( ) throws IOException , DocumentException { if ( cff ) { return new StreamFont ( readCffFont ( ) , "Type1C" , compressionLevel ) ; } else { byte [ ] b = getFullFont ( ) ; int lengths [ ] = new int [ ] { b . length } ; return new StreamFont ( b , lengths , compressionLevel ) ; } }
|
Returns a PdfStream object with the full font program .
|
4,888
|
public String [ ] getCodePagesSupported ( ) { long cp = ( ( ( long ) os_2 . ulCodePageRange2 ) << 32 ) + ( os_2 . ulCodePageRange1 & 0xffffffffL ) ; int count = 0 ; long bit = 1 ; for ( int k = 0 ; k < 64 ; ++ k ) { if ( ( cp & bit ) != 0 && codePages [ k ] != null ) ++ count ; bit <<= 1 ; } String ret [ ] = new String [ count ] ; count = 0 ; bit = 1 ; for ( int k = 0 ; k < 64 ; ++ k ) { if ( ( cp & bit ) != 0 && codePages [ k ] != null ) ret [ count ++ ] = codePages [ k ] ; bit <<= 1 ; } return ret ; }
|
Gets the code pages supported by the font .
|
4,889
|
public void writeContent ( final OutputStream result ) throws IOException { result . write ( NEW_PAGE ) ; result . write ( RtfParagraph . PARAGRAPH_DEFAULTS ) ; }
|
Writes a new page
|
4,890
|
public void writeDefinition ( final OutputStream result ) throws IOException { if ( this . mergeType == MERGE_VERT_PARENT ) { result . write ( DocWriter . getISOBytes ( "\\clvmgf" ) ) ; } else if ( this . mergeType == MERGE_VERT_CHILD ) { result . write ( DocWriter . getISOBytes ( "\\clvmrg" ) ) ; } switch ( verticalAlignment ) { case Element . ALIGN_BOTTOM : result . write ( DocWriter . getISOBytes ( "\\clvertalb" ) ) ; break ; case Element . ALIGN_CENTER : case Element . ALIGN_MIDDLE : result . write ( DocWriter . getISOBytes ( "\\clvertalc" ) ) ; break ; case Element . ALIGN_TOP : result . write ( DocWriter . getISOBytes ( "\\clvertalt" ) ) ; break ; } this . borders . writeContent ( result ) ; if ( this . backgroundColor != null ) { result . write ( DocWriter . getISOBytes ( "\\clcbpat" ) ) ; result . write ( intToByteArray ( this . backgroundColor . getColorNumber ( ) ) ) ; } this . document . outputDebugLinebreak ( result ) ; result . write ( DocWriter . getISOBytes ( "\\clftsWidth3" ) ) ; this . document . outputDebugLinebreak ( result ) ; result . write ( DocWriter . getISOBytes ( "\\clwWidth" ) ) ; result . write ( intToByteArray ( this . cellWidth ) ) ; this . document . outputDebugLinebreak ( result ) ; if ( this . cellPadding > 0 ) { result . write ( DocWriter . getISOBytes ( "\\clpadl" ) ) ; result . write ( intToByteArray ( this . cellPadding / 2 ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadt" ) ) ; result . write ( intToByteArray ( this . cellPadding / 2 ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadr" ) ) ; result . write ( intToByteArray ( this . cellPadding / 2 ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadb" ) ) ; result . write ( intToByteArray ( this . cellPadding / 2 ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadfl3" ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadft3" ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadfr3" ) ) ; result . write ( DocWriter . getISOBytes ( "\\clpadfb3" ) ) ; } result . write ( DocWriter . getISOBytes ( "\\cellx" ) ) ; result . write ( intToByteArray ( this . cellRight ) ) ; }
|
Write the cell definition part of this RtfCell
|
4,891
|
public void writeContent ( final OutputStream result ) throws IOException { if ( this . content . size ( ) == 0 ) { result . write ( RtfParagraph . PARAGRAPH_DEFAULTS ) ; if ( this . parentRow . getParentTable ( ) . getTableFitToPage ( ) ) { result . write ( RtfParagraphStyle . KEEP_TOGETHER_WITH_NEXT ) ; } result . write ( RtfParagraph . IN_TABLE ) ; } else { for ( int i = 0 ; i < this . content . size ( ) ; i ++ ) { RtfBasicElement rtfElement = ( RtfBasicElement ) this . content . get ( i ) ; if ( rtfElement instanceof RtfParagraph ) { ( ( RtfParagraph ) rtfElement ) . setKeepTogetherWithNext ( this . parentRow . getParentTable ( ) . getTableFitToPage ( ) ) ; } rtfElement . writeContent ( result ) ; if ( rtfElement instanceof RtfParagraph && i < ( this . content . size ( ) - 1 ) ) { result . write ( RtfParagraph . PARAGRAPH ) ; } } } result . write ( DocWriter . getISOBytes ( "\\cell" ) ) ; }
|
Write the content of this RtfCell
|
4,892
|
protected void setCellMergeChild ( RtfCell mergeParent ) { this . mergeType = MERGE_VERT_CHILD ; this . cellWidth = mergeParent . getCellWidth ( ) ; this . cellRight = mergeParent . getCellRight ( ) ; this . cellPadding = mergeParent . getCellpadding ( ) ; this . borders = mergeParent . getBorders ( ) ; this . verticalAlignment = mergeParent . getVerticalAlignment ( ) ; this . backgroundColor = mergeParent . getRtfBackgroundColor ( ) ; }
|
Merge this cell into the parent cell .
|
4,893
|
public void setInHeader ( boolean inHeader ) { this . inHeader = inHeader ; for ( int i = 0 ; i < this . content . size ( ) ; i ++ ) { ( ( RtfBasicElement ) this . content . get ( i ) ) . setInHeader ( inHeader ) ; } }
|
Sets whether this RtfCell is in a header
|
4,894
|
public Table createTable ( ) throws BadElementException { if ( content . isEmpty ( ) ) throw new BadElementException ( "Trying to create a table without rows." ) ; SimpleCell row = ( SimpleCell ) content . get ( 0 ) ; SimpleCell cell ; int columns = 0 ; for ( Iterator i = row . getContent ( ) . iterator ( ) ; i . hasNext ( ) ; ) { cell = ( SimpleCell ) i . next ( ) ; columns += cell . getColspan ( ) ; } float [ ] widths = new float [ columns ] ; float [ ] widthpercentages = new float [ columns ] ; Table table = new Table ( columns ) ; table . setAlignment ( alignment ) ; table . setSpacing ( cellspacing ) ; table . setPadding ( cellpadding ) ; table . cloneNonPositionParameters ( this ) ; int pos ; for ( Iterator rows = content . iterator ( ) ; rows . hasNext ( ) ; ) { row = ( SimpleCell ) rows . next ( ) ; pos = 0 ; for ( Iterator cells = row . getContent ( ) . iterator ( ) ; cells . hasNext ( ) ; ) { cell = ( SimpleCell ) cells . next ( ) ; table . addCell ( cell . createCell ( row ) ) ; if ( cell . getColspan ( ) == 1 ) { if ( cell . getWidth ( ) > 0 ) widths [ pos ] = cell . getWidth ( ) ; if ( cell . getWidthpercentage ( ) > 0 ) widthpercentages [ pos ] = cell . getWidthpercentage ( ) ; } pos += cell . getColspan ( ) ; } } float sumWidths = 0f ; for ( int i = 0 ; i < columns ; i ++ ) { if ( widths [ i ] == 0 ) { sumWidths = 0 ; break ; } sumWidths += widths [ i ] ; } if ( sumWidths > 0 ) { table . setWidth ( sumWidths ) ; table . setLocked ( true ) ; table . setWidths ( widths ) ; } else { for ( int i = 0 ; i < columns ; i ++ ) { if ( widthpercentages [ i ] == 0 ) { sumWidths = 0 ; break ; } sumWidths += widthpercentages [ i ] ; } if ( sumWidths > 0 ) { table . setWidths ( widthpercentages ) ; } } if ( width > 0 ) { table . setWidth ( width ) ; table . setLocked ( true ) ; } else if ( widthpercentage > 0 ) { table . setWidth ( widthpercentage ) ; } return table ; }
|
Creates a Table object based on this TableAttributes object .
|
4,895
|
public int handleKeyword ( RtfCtrlWordData ctrlWordData , int groupLevel ) { int result = RtfParser . errOK ; beforeCtrlWord ( ctrlWordData ) ; result = dispatchKeyword ( ctrlWordData , groupLevel ) ; afterCtrlWord ( ctrlWordData ) ; return result ; }
|
Internal to control word manager class .
|
4,896
|
private int dispatchKeyword ( RtfCtrlWordData ctrlWordData , int groupLevel ) { int result = RtfParser . errOK ; if ( ctrlWordData != null ) { RtfCtrlWordHandler ctrlWord = ctrlWordMap . getCtrlWordHandler ( ctrlWordData . ctrlWord ) ; if ( ctrlWord != null ) { ctrlWord . handleControlword ( ctrlWordData ) ; if ( debug && debugFound ) { System . out . println ( "Keyword found:" + " New:" + ctrlWordData . ctrlWord + " Param:" + ctrlWordData . param + " bParam=" + ctrlWordData . hasParam ) ; } } else { result = RtfParser . errCtrlWordNotFound ; if ( debug && debugNotFound ) { System . out . println ( "Keyword unknown:" + " New:" + ctrlWordData . ctrlWord + " Param:" + ctrlWordData . param + " bParam=" + ctrlWordData . hasParam ) ; } } } return result ; }
|
Dispatch the token to the correct control word handling object .
|
4,897
|
public Rectangle2D getBounds2D ( ) { int [ ] r = rect ( ) ; return r == null ? null : new Rectangle2D . Double ( r [ 0 ] , r [ 1 ] , r [ 2 ] , r [ 3 ] ) ; }
|
Returns the bounding box of this polyline .
|
4,898
|
public PdfImportedPage getImportedPage ( PdfReader reader , int pageNumber ) { if ( currentPdfReaderInstance != null ) { if ( currentPdfReaderInstance . getReader ( ) != reader ) { try { currentPdfReaderInstance . getReader ( ) . close ( ) ; currentPdfReaderInstance . getReaderFile ( ) . close ( ) ; } catch ( IOException ioe ) { } currentPdfReaderInstance = reader . getPdfReaderInstance ( this ) ; } } else { currentPdfReaderInstance = reader . getPdfReaderInstance ( this ) ; } return currentPdfReaderInstance . getImportedPage ( pageNumber ) ; }
|
Grabs a page from the input document
|
4,899
|
protected PdfDictionary copyDictionary ( PdfDictionary in ) throws IOException , BadPdfFormatException { PdfDictionary out = new PdfDictionary ( ) ; PdfObject type = PdfReader . getPdfObjectRelease ( in . get ( PdfName . TYPE ) ) ; for ( Iterator it = in . getKeys ( ) . iterator ( ) ; it . hasNext ( ) ; ) { PdfName key = ( PdfName ) it . next ( ) ; PdfObject value = in . get ( key ) ; if ( type != null && PdfName . PAGE . equals ( type ) ) { if ( ! key . equals ( PdfName . B ) && ! key . equals ( PdfName . PARENT ) ) out . put ( key , copyObject ( value ) ) ; } else out . put ( key , copyObject ( value ) ) ; } return out ; }
|
Translate a PRDictionary to a PdfDictionary . Also translate all of the objects contained in it .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.