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 [ off...
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 ) ) ; } f...
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 , n...
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 . curr...
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 ; defau...
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 ( ' ' ) ; l...
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'...
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 (...
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 ) ; setNodeT...
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 . getEleme...
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 ( s...
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 ) ; t...
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 ...
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...
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 ) ; ...
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 ...
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 . getNumberOfPag...
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 ( "temp...
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 . isArra...
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 acroFie...
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 ...
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 . rtfPa...
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" ...
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...
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 ...
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 ...
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...
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 actio...
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 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 actio...
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 ( des...
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 ( d...
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 ( I...
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 ...
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 . setFieldF...
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 ( "Co...
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 Allo...
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 . d...
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 = r...
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 nu...
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 ) ...
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 ] ) ; GlyphWidth...
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...
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...
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 ] = getGlyphW...
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 = ...
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 ( PdfNam...
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...
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 ( verticalAl...
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 . wr...
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 . vertical...
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 . hasNe...
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...
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 ( IOExcepti...
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...
Translate a PRDictionary to a PdfDictionary . Also translate all of the objects contained in it .