proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddJavascript.java
AddJavascript
main
class AddJavascript { private AddJavascript() { //static class, should not be instantiated. } /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public stat...
if( args.length != 2 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { PDActionJavaScript javascript = new PDActionJavaScript( "app.alert( {cMsg: 'PDFBox rocks!', nIcon: 3...
182
182
364
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMessageToEachPage.java
AddMessageToEachPage
main
class AddMessageToEachPage { /** * Constructor. */ public AddMessageToEachPage() { super(); } /** * create the second sample document from the PDF file format specification. * * @param file The file to write the PDF to. * @param message The message to write in ...
AddMessageToEachPage app = new AddMessageToEachPage(); if( args.length != 3 ) { app.usage(); } else { app.doIt( args[0], args[1], args[2] ); }
759
71
830
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.java
AddMetadataFromDocInfo
usage
class AddMetadataFromDocInfo { private AddMetadataFromDocInfo() { //utility class } /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. * @throws TransformerExcepti...
System.err.println( "Usage: java " + AddMetadataFromDocInfo.class.getName() + " <input-pdf> <output-pdf>" );
609
40
649
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/BengaliPdfGenerationHelloWorld.java
BengaliPdfGenerationHelloWorld
main
class BengaliPdfGenerationHelloWorld { private static final int LINE_GAP = 5; private static final String LOHIT_BENGALI_TTF = "/org/apache/pdfbox/resources/ttf/Lohit-Bengali.ttf"; private static final String TEXT_SOURCE_FILE = "/org/apache/pdfbox/resources/ttf/bengali-samples.txt"; private static final ...
if (args.length != 1) { System.err.println( "usage: " + BengaliPdfGenerationHelloWorld.class.getName() + " <output-file> "); System.exit(1); } String filename = args[0]; System.out.println("The generated pdf filename is: " + filename...
951
481
1,432
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateBlankPDF.java
CreateBlankPDF
main
class CreateBlankPDF { private CreateBlankPDF() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if (args.length != 1) { System.err.println("usage: " + CreateBlankPDF.class.getName() + " <outputfile.pdf>"); System.exit(1); } String filename = args[0]; try (PDDocument doc = new PDDocument()) { // a valid PDF document requires at ...
55
132
187
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateBookmarks.java
CreateBookmarks
usage
class CreateBookmarks { private CreateBookmarks() { //utility class } /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public static void main( String[] a...
System.err.println( "Usage: java " + CreateBookmarks.class.getName() + " <input-pdf> <output-pdf>" );
539
38
577
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
CreateLandscapePDF
doIt
class CreateLandscapePDF { /** * Constructor. */ public CreateLandscapePDF() { super(); } /** * creates a sample document with a landscape orientation and some text surrounded by a box. * * @param message The message to write in the file. * @param outfile The r...
try (PDDocument doc = new PDDocument()) { PDFont font = new PDType1Font(FontName.HELVETICA); PDPage page = new PDPage(PDRectangle.A4); page.setRotation(90); doc.addPage(page); PDRectangle pageSize = page.getMediaBox(); float pageWi...
333
617
950
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePDFA.java
CreatePDFA
main
class CreatePDFA { private CreatePDFA() { } public static void main(String[] args) throws IOException, TransformerException {<FILL_FUNCTION_BODY>} }
if (args.length != 3) { System.err.println("usage: " + CreatePDFA.class.getName() + " <output-file> <Message> <ttf-file>"); System.exit(1); } String file = args[0]; String message = args[1]; String fontfile = args[2]...
64
951
1,015
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePageLabels.java
CreatePageLabels
main
class CreatePageLabels { /** * Constructor. */ private CreatePageLabels() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
try (PDDocument doc = new PDDocument()) { doc.addPage(new PDPage()); doc.addPage(new PDPage()); doc.addPage(new PDPage()); PDPageLabels pageLabels = new PDPageLabels(doc); PDPageLabelRange pageLabelRange1 = new PDPageLabelRange(); ...
65
264
329
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreatePatternsPDF.java
CreatePatternsPDF
main
class CreatePatternsPDF { private CreatePatternsPDF() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
try (PDDocument doc = new PDDocument()) { PDPage page = new PDPage(); doc.addPage(page); page.setResources(new PDResources()); // Colored pattern, i.e. the pattern content stream will set its own color(s) try (PDPageContentStream ...
53
1,093
1,146
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateSeparationColorBox.java
CreateSeparationColorBox
main
class CreateSeparationColorBox { private CreateSeparationColorBox() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
try (PDDocument doc = new PDDocument()) { PDPage page = new PDPage(); doc.addPage(page); COSArray separationArray = new COSArray(); separationArray.add(COSName.SEPARATION); // type separationArray.add(COSName.getPDFName("Gold")); ...
55
690
745
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java
EmbeddedFiles
doIt
class EmbeddedFiles { /** * Constructor. */ private EmbeddedFiles() { } /** * create the second sample document from the PDF file format specification. * * @param file The file to write the PDF to. * * @throws IOException If there is an error writing the data. ...
try (PDDocument doc = new PDDocument()) { PDPage page = new PDPage(); doc.addPage( page ); PDFont font = new PDType1Font(FontName.HELVETICA_BOLD); try (PDPageContentStream contentStream = new PDPageContentStream(doc, page)) { ...
313
714
1,027
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFonts.java
EmbeddedFonts
main
class EmbeddedFonts { private EmbeddedFonts() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
try (PDDocument document = new PDDocument()) { PDPage page = new PDPage(PDRectangle.A4); document.addPage(page); String dir = "../pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/"; PDType0Font font = PDType0Font.load(document, new F...
57
349
406
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedMultipleFonts.java
EmbeddedMultipleFonts
showTextMultiple
class EmbeddedMultipleFonts { private EmbeddedMultipleFonts() { } public static void main(String[] args) throws IOException { try (PDDocument document = new PDDocument(); TrueTypeCollection ttc2 = new TrueTypeCollection(new File("c:/windows/fonts/batang.ttc")); Tru...
try { // first try all at once fonts.get(0).encode(text); cs.setFont(fonts.get(0), size); cs.showText(text); return; } catch (IllegalArgumentException ex) { // do nothing } // now try separat...
650
516
1,166
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedVerticalFonts.java
EmbeddedVerticalFonts
main
class EmbeddedVerticalFonts { private EmbeddedVerticalFonts() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
PDDocument document = new PDDocument(); PDPage page = new PDPage(); document.addPage(page); // The actual font file // Download: https://moji.or.jp/wp-content/ipafont/IPAfont/ipag00303.zip // (free license: https://www.gnu.org/licenses/license-list.html#IPAFONT) ...
59
822
881
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java
ExtractEmbeddedFiles
extractFilesFromEFTree
class ExtractEmbeddedFiles { private ExtractEmbeddedFiles() { } /** * This is the main method. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public static void main( String[] args ) throws...
Map<String, PDComplexFileSpecification> names = efTree.getNames(); if (names != null) { extractFiles(names, filePath); } else { List<PDNameTreeNode<PDComplexFileSpecification>> kids = efTree.getKids(); if (kids == null) ...
1,306
161
1,467
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractMetadata.java
ExtractMetadata
format
class ExtractMetadata { private ExtractMetadata() { // utility class } /** * This is the main method. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. * @throws XmpParsingException * @throws BadFiel...
if (o instanceof Calendar) { Calendar cal = (Calendar) o; return DateFormat.getDateInstance().format(cal.getTime()); } else { return o.toString(); }
1,142
60
1,202
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
ExtractTTFFonts
writeFont
class ExtractTTFFonts { private int fontCounter = 1; @SuppressWarnings({"squid:S2068"}) private static final String PASSWORD = "-password"; private static final String PREFIX = "-prefix"; private static final String ADDKEY = "-addkey"; private ExtractTTFFonts() { } /** * This...
if (fd != null) { PDStream ff2Stream = fd.getFontFile2(); if (ff2Stream != null) { System.out.println("Writing font: " + name); try (OutputStream os = new FileOutputStream(name + ".ttf"); InputStream is = ff2Stream...
1,355
114
1,469
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/GoToSecondBookmarkOnOpen.java
GoToSecondBookmarkOnOpen
main
class GoToSecondBookmarkOnOpen { private GoToSecondBookmarkOnOpen() { //utility class } /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public static voi...
if( args.length != 2 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { if( document.isEncrypted() ) { System.err.println( "Error: Cannot add bookmark desti...
187
294
481
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorld.java
HelloWorld
main
class HelloWorld { private HelloWorld() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if( args.length != 2 ) { System.err.println("usage: " + HelloWorld.class.getName() + " <output-file> <Message>"); System.exit(1); } String filename = args[0]; String message = args[1]; try (PDDocument doc = new PDDocument()) { ...
52
240
292
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldTTF.java
HelloWorldTTF
main
class HelloWorldTTF { private HelloWorldTTF() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if (args.length != 3) { System.err.println("usage: " + HelloWorldTTF.class.getName() + " <output-file> <Message> <ttf-file>"); System.exit(1); } String pdfPath = args[0]; String message = args[1]; String ttfPath = args[2]; ...
55
274
329
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldType1.java
HelloWorldType1
main
class HelloWorldType1 { private HelloWorldType1() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if (args.length != 3) { System.err.println("usage: " + HelloWorldType1.class.getName() + " <output-file> <Message> <pfb-file>"); System.exit(1); } String file = args[0]; String message = args[1]; String pfbPath = args[2]; ...
57
289
346
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ImageToPDF.java
ImageToPDF
main
class ImageToPDF { private ImageToPDF() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if (args.length != 2) { System.err.println("usage: " + ImageToPDF.class.getName() + " <image> <output-file>"); System.exit(1); } String imagePath = args[0]; String pdfPath = args[1]; if (!pdfPath.endsWith(".pdf")) { ...
52
404
456
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
PrintBookmarks
printBookmark
class PrintBookmarks { /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public static void main( String[] args ) throws IOException { if( args.length != 1 ) ...
PDOutlineItem current = bookmark.getFirstChild(); while( current != null ) { // one could also use current.findDestinationPage(document) to get the page number, // but this example does it the hard way to explain the different types // Note that bookmarks can...
411
702
1,113
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintDocumentMetaData.java
PrintDocumentMetaData
printMetadata
class PrintDocumentMetaData { /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public static void main( String[] args ) throws IOException { if( args.length != 1 )...
PDDocumentInformation info = document.getDocumentInformation(); PDDocumentCatalog cat = document.getDocumentCatalog(); PDMetadata metadata = cat.getMetadata(); System.out.println( "Page Count=" + document.getNumberOfPages() ); System.out.println( "Title=" + info.getTitle() ); ...
431
319
750
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintURLs.java
PrintURLs
main
class PrintURLs { /** * Constructor. */ private PrintURLs() { //utility class } /** * This will output all URLs and the texts in the annotation rectangle of a document. * <br> * see usage() for commandline * * @param args Command line arguments. * ...
PDDocument doc = null; try { if( args.length != 1 ) { usage(); } else { doc = Loader.loadPDF(new File(args[0])); int pageNum = 0; for( PDPage page : doc.getPages() ) ...
422
581
1,003
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/RemoveFirstPage.java
RemoveFirstPage
main
class RemoveFirstPage { private RemoveFirstPage() { //utility class, should not be instantiated. } /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public...
if( args.length != 2 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { if( document.isEncrypted() ) { throw new IOException( "Encrypted documents are not s...
180
170
350
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ReplaceURLs.java
ReplaceURLs
main
class ReplaceURLs { /** * Constructor. */ private ReplaceURLs() { //utility class } /** * This will read in a document and replace all of the urls with * http://pdfbox.apache.org. * <br> * see usage() for commandline * * @param args Command line argum...
PDDocument doc = null; try { if( args.length != 2 ) { usage(); } else { doc = Loader.loadPDF(new File(args[0])); int pageNum = 0; for( PDPage page : doc.getPages() ) ...
223
333
556
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/RubberStamp.java
RubberStamp
main
class RubberStamp { private RubberStamp() { //utility class, should not be instantiated. } /** * This will print the documents data. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the document. */ public static ...
if( args.length != 2 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { if( document.isEncrypted() ) { throw new IOException( "Encrypted documents are not s...
183
240
423
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/RubberStampWithImage.java
RubberStampWithImage
doIt
class RubberStampWithImage { private static final String SAVE_GRAPHICS_STATE = "q\n"; private static final String RESTORE_GRAPHICS_STATE = "Q\n"; private static final String CONCATENATE_MATRIX = "cm\n"; private static final String XOBJECT_DO = "Do\n"; private static final String SPACE = " "; pr...
if( args.length != 3 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { if( document.isEncrypted() ) { throw new IOException( "Encrypted documents are not ...
859
722
1,581
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ShowColorBoxes.java
ShowColorBoxes
main
class ShowColorBoxes { private ShowColorBoxes() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if (args.length != 1) { System.err.println("usage: " +ShowColorBoxes.class.getName() + " <output-file>"); System.exit(1); } String filename = args[0]; try (PDDocument doc = new PDDocument()) { PDPage page = new PDPage(); ...
55
422
477
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ShowTextWithPositioning.java
ShowTextWithPositioning
doIt
class ShowTextWithPositioning { private static final float FONT_SIZE = 20.0f; private ShowTextWithPositioning() { } public static void main(String[] args) throws IOException { doIt("Hello World, this is a test!", "justify-example.pdf"); } public static void doIt(String message...
// the document try (PDDocument doc = new PDDocument(); InputStream is = PDDocument.class.getResourceAsStream("/org/apache/pdfbox/resources/ttf/LiberationSans-Regular.ttf")) { // Page 1 PDFont font = PDType0Font.load(doc, is, true); PDPage page =...
119
1,423
1,542
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/SuperimposePage.java
SuperimposePage
main
class SuperimposePage { private SuperimposePage() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
if (args.length != 2) { System.err.println("usage: " + SuperimposePage.class.getName() + " <source-pdf> <dest-pdf>"); System.exit(1); } String sourcePath = args[0]; String destPath = args[1]; try (PDDocument sourceDoc ...
55
521
576
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/UsingTextMatrix.java
UsingTextMatrix
doIt
class UsingTextMatrix { /** * Constructor. */ public UsingTextMatrix() { } /** * creates a sample document with some text using a text matrix. * * @param message The message to write in the file. * @param outfile The resulting PDF. * * @throws IOException If ...
// the document try (PDDocument doc = new PDDocument()) { // Page 1 PDFont font = new PDType1Font(FontName.HELVETICA); PDPage page = new PDPage(PDRectangle.A4); doc.addPage(page); float fontSize = 12.0f; PDRectangle pageSi...
319
985
1,304
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/printing/OpaquePDFRenderer.java
OpaqueDrawObject
process
class OpaqueDrawObject extends GraphicsOperatorProcessor { public OpaqueDrawObject(PDFGraphicsStreamEngine context) { super(context); } private static final Logger LOG = LogManager.getLogger(OpaqueDrawObject.class); @Override public void process(Operator...
if (operands.isEmpty()) { throw new MissingOperandException(operator, operands); } COSBase base0 = operands.get(0); if (!(base0 instanceof COSName)) { return; } COSName objectName = (COSName)...
140
314
454
<methods>public void <init>(org.apache.pdfbox.pdmodel.PDDocument) ,public org.apache.pdfbox.pdmodel.interactive.annotation.AnnotationFilter getAnnotationsFilter() ,public org.apache.pdfbox.rendering.RenderDestination getDefaultDestination() ,public float getImageDownscalingOptimizationThreshold() ,public java.awt.Rende...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/printing/Printing.java
Printing
main
class Printing { private Printing() { } /** * Entry point. */ public static void main(String[] args) throws PrinterException, IOException {<FILL_FUNCTION_BODY>} /** * Prints the document at its actual size. This is the recommended way to print. */ private static ...
if (args.length != 1) { System.err.println("usage: java " + Printing.class.getName() + " <input>"); System.exit(1); } String filename = args[0]; try (PDDocument document = Loader.loadPDF(new File(filename))) { // choose your printing ...
982
143
1,125
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java
CustomGraphicsStreamEngine
curveTo
class CustomGraphicsStreamEngine extends PDFGraphicsStreamEngine { /** * Constructor. * * @param page PDF Page */ protected CustomGraphicsStreamEngine(PDPage page) { super(page); } public static void main(String[] args) throws IOException { File file = new Fi...
System.out.printf("curveTo %.2f %.2f, %.2f %.2f, %.2f %.2f%n", x1, y1, x2, y2, x3, y3);
1,195
61
1,256
<methods>public abstract void appendRectangle(java.awt.geom.Point2D, java.awt.geom.Point2D, java.awt.geom.Point2D, java.awt.geom.Point2D) throws java.io.IOException,public abstract void clip(int) throws java.io.IOException,public abstract void closePath() throws java.io.IOException,public abstract void curveTo(float, f...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
MyPageDrawer
showGlyph
class MyPageDrawer extends PageDrawer { MyPageDrawer(PageDrawerParameters parameters) throws IOException { super(parameters); } /** * Color replacement. */ @Override protected Paint getPaint(PDColor color) throws IOException { ...
// draw glyph super.showGlyph(textRenderingMatrix, font, code, displacement); // bbox in EM -> user units Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1); AffineTransform at = textRenderingMatrix.createAffineTransform(); ...
593
256
849
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java
CMSProcessableInputStream
write
class CMSProcessableInputStream implements CMSTypedData { private final InputStream in; private final ASN1ObjectIdentifier contentType; CMSProcessableInputStream(InputStream is) { this(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), is); } CMSProcessableInputStre...
// read the content only one time in.transferTo(out); in.close();
235
32
267
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java
CreateEmbeddedTimeStamp
embedTimeStamp
class CreateEmbeddedTimeStamp { private final String tsaUrl; private PDDocument document; private PDSignature signature; private byte[] changedEncodedSignature; public CreateEmbeddedTimeStamp(String tsaUrl) { this.tsaUrl = tsaUrl; } /** * Embeds the given PDF file with sig...
if (inFile == null || !inFile.exists()) { throw new FileNotFoundException("Document for signing does not exist"); } // sign try (PDDocument doc = Loader.loadPDF(inFile)) { document = doc; processTimeStamping(inFile, outFile); ...
1,585
88
1,673
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmptySignatureForm.java
CreateEmptySignatureForm
main
class CreateEmptySignatureForm { private CreateEmptySignatureForm() { } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} }
// Create a new document with an empty page. try (PDDocument document = new PDDocument()) { PDPage page = new PDPage(PDRectangle.A4); document.addPage(page); // Adobe Acrobat uses Helvetica as a default font and // stores that under the name '/He...
54
541
595
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignature.java
CreateSignature
main
class CreateSignature extends CreateSignatureBase { /** * Initialize the signature creator with a keystore and certificate password. * * @param keystore the pkcs12 keystore containing the signing certificate * @param pin the password for recovering the key * @throws KeyStoreException if th...
if (args.length < 3) { usage(); System.exit(1); } String tsaUrl = null; boolean externalSig = false; for (int i = 0; i < args.length; i++) { if (args[i].equals("-tsa")) { i++; if (i ...
1,289
382
1,671
<methods>public void <init>(java.security.KeyStore, char[]) throws java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.NoSuchAlgorithmException, java.io.IOException, java.security.cert.CertificateException,public java.security.cert.Certificate[] getCertificateChain() ,public boolean ...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignatureBase.java
CreateSignatureBase
sign
class CreateSignatureBase implements SignatureInterface { private PrivateKey privateKey; private Certificate[] certificateChain; private String tsaUrl; private boolean externalSigning; /** * Initialize the signature creator with a keystore (pkcs12) and pin that should be used for the * si...
// cannot be done private (interface) try { CMSSignedDataGenerator gen = new CMSSignedDataGenerator(); X509Certificate cert = (X509Certificate) certificateChain[0]; ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA256WithRSA").build(privateKey); ...
1,025
302
1,327
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignedTimeStamp.java
CreateSignedTimeStamp
main
class CreateSignedTimeStamp implements SignatureInterface { private static final Logger LOG = LogManager.getLogger(CreateSignedTimeStamp.class); private final String tsaUrl; /** * Initialize the signed timestamp creator * * @param tsaUrl The url where TS-Request will be done. */ ...
if (args.length != 3) { usage(); System.exit(1); } String tsaUrl = null; if ("-tsa".equals(args[1])) { tsaUrl = args[2]; } else { usage(); System.exit(1); } // sign PDF ...
1,097
204
1,301
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
TSAClient
getTSAResponse
class TSAClient { private static final Logger LOG = LogManager.getLogger(TSAClient.class); private static final DigestAlgorithmIdentifierFinder ALGORITHM_OID_FINDER = new DefaultDigestAlgorithmIdentifierFinder(); private final URL url; private final String username; private fi...
LOG.debug("Opening connection to TSA server"); // todo: support proxy servers URLConnection connection = url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestProperty("Content-Type", "application/timestamp-query");...
884
439
1,323
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/ValidationTimeStamp.java
ValidationTimeStamp
signTimeStamp
class ValidationTimeStamp { private TSAClient tsaClient; /** * @param tsaUrl The url where TS-Request will be done. * @throws NoSuchAlgorithmException * @throws MalformedURLException * @throws java.net.URISyntaxException */ public ValidationTimeStamp(String tsaUrl) thro...
AttributeTable unsignedAttributes = signer.getUnsignedAttributes(); ASN1EncodableVector vector = new ASN1EncodableVector(); if (unsignedAttributes != null) { vector = unsignedAttributes.toASN1EncodableVector(); } TimeStampToken timeStampToken = tsaClient.ge...
649
283
932
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/signature/validation/CertInformationHelper.java
CertInformationHelper
extractCrlUrlFromSequence
class CertInformationHelper { private static final Logger LOG = LogManager.getLogger(CertInformationHelper.class); private CertInformationHelper() { } /** * Gets the SHA-1-Hash has of given byte[]-content. * * @param content to be hashed * @return SHA-1 hash String */ ...
ASN1TaggedObject taggedObject = (ASN1TaggedObject) sequence.getObjectAt(0); taggedObject = (ASN1TaggedObject) taggedObject.getBaseObject(); if (taggedObject.getBaseObject() instanceof ASN1TaggedObject) { taggedObject = (ASN1TaggedObject) taggedObject.getBaseObject(); ...
936
363
1,299
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/AddWatermarkText.java
AddWatermarkText
addWatermarkText
class AddWatermarkText { private AddWatermarkText() { } public static void main(String[] args) throws IOException { if (args.length != 3) { usage(); } else { File srcFile = new File(args[0]); File dstFile = new File(args[1]...
try (PDPageContentStream cs = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND, true, true)) { float fontHeight = 100; // arbitrary for short text float width = page.getMediaBox().getWidth(); float height = page.getMediaBox().g...
320
652
972
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/ExtractTextByArea.java
ExtractTextByArea
main
class ExtractTextByArea { private ExtractTextByArea() { //utility class and should not be constructed. } /** * This will print the documents text in a certain area. * * @param args The command line arguments. * * @throws IOException If there is an error parsing the doc...
if( args.length != 1 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { PDFTextStripperByArea stripper = new PDFTextStripperByArea(); stripper.setSortByPosition( true ); ...
187
205
392
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/ExtractTextSimple.java
ExtractTextSimple
main
class ExtractTextSimple { private ExtractTextSimple() { // example class should not be instantiated } /** * This will print the documents text page by page. * * @param args The command line arguments. * * @throws IOException If there is an error parsing or extracting th...
if (args.length != 1) { usage(); } try (PDDocument document = Loader.loadPDF(new File(args[0]))) { AccessPermission ap = document.getCurrentAccessPermission(); if (!ap.canExtractContent()) { throw new IOException("...
188
443
631
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java
PDFHighlighter
main
class PDFHighlighter extends PDFTextStripper { private Writer highlighterOutput = null; private String[] searchedWords; private ByteArrayOutputStream textOS = null; private Writer textWriter = null; private static final Charset ENCODING = StandardCharsets.UTF_16; /** * Default constructor...
PDFHighlighter xmlExtractor = new PDFHighlighter(); if (args.length < 2) { usage(); } String[] highlightStrings = new String[args.length - 1]; System.arraycopy(args, 1, highlightStrings, 0, highlightStrings.length); try (PDDocument doc = Loader.loadPD...
1,012
144
1,156
<methods>public void <init>() ,public boolean getAddMoreFormatting() ,public java.lang.String getArticleEnd() ,public java.lang.String getArticleStart() ,public float getAverageCharTolerance() ,public float getDropThreshold() ,public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndB...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/PDFMergerExample.java
PDFMergerExample
createXMPMetadata
class PDFMergerExample { private static final Logger LOG = LogManager.getLogger(PDFMergerExample.class); /** * Creates a compound PDF document from a list of input documents. * <p> * The merged document is PDF/A-1b compliant, provided the source documents are as well. It contains document *...
LOG.info("Setting XMP metadata (title, author, subject) for merged PDF"); XMPMetadata xmpMetadata = XMPMetadata.createXMPMetadata(); // PDF/A-1b properties PDFAIdentificationSchema pdfaSchema = xmpMetadata.createAndAddPDFAIdentificationSchema(); pdfaSchema.setPart(1); p...
855
360
1,215
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/PrintImageLocations.java
PrintImageLocations
main
class PrintImageLocations extends PDFStreamEngine { /** * Default constructor. * * @throws IOException If there is an error loading text stripper properties. */ public PrintImageLocations() throws IOException { addOperator(new Concatenate(this)); addOperator(new DrawObjec...
if( args.length != 1 ) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { PrintImageLocations printer = new PrintImageLocations(); int pageNum = 0; for( PDPage pa...
953
138
1,091
<methods>public final void addOperator(org.apache.pdfbox.contentstream.operator.OperatorProcessor) ,public void beginMarkedContentSequence(org.apache.pdfbox.cos.COSName, org.apache.pdfbox.cos.COSDictionary) ,public void beginText() throws java.io.IOException,public void decreaseLevel() ,public void endMarkedContentSequ...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextColors.java
PrintTextColors
processTextPosition
class PrintTextColors extends PDFTextStripper { /** * Instantiate a new PDFTextStripper object. * * @throws IOException If there is an error loading the properties. */ public PrintTextColors() throws IOException { addOperator(new SetStrokingColorSpace(this)); addOperator(...
super.processTextPosition(text); PDColor strokingColor = getGraphicsState().getStrokingColor(); PDColor nonStrokingColor = getGraphicsState().getNonStrokingColor(); String unicode = text.getUnicode(); RenderingMode renderingMode = getGraphicsState().getTextState().getRenderingM...
577
210
787
<methods>public void <init>() ,public boolean getAddMoreFormatting() ,public java.lang.String getArticleEnd() ,public java.lang.String getArticleStart() ,public float getAverageCharTolerance() ,public float getDropThreshold() ,public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndB...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
PrintTextLocations
writeString
class PrintTextLocations extends PDFTextStripper { /** * Instantiate a new PDFTextStripper object. * * @throws IOException If there is an error loading the properties. */ public PrintTextLocations() throws IOException { } /** * This will print the documents data. * ...
for (TextPosition text : textPositions) { System.out.println( "String[" + text.getXDirAdj() + "," + text.getYDirAdj() + " fs=" + text.getFontSize() + " xscale=" + text.getXScale() + " height=" + text.getHeightDir() + " space=" + te...
414
136
550
<methods>public void <init>() ,public boolean getAddMoreFormatting() ,public java.lang.String getArticleEnd() ,public java.lang.String getArticleStart() ,public float getAverageCharTolerance() ,public float getDropThreshold() ,public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndB...
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/RemoveAllText.java
RemoveAllText
main
class RemoveAllText { /** * Default constructor. */ private RemoveAllText() { // example class should not be instantiated } /** * This will remove all text from a PDF document. * * @param args The command line arguments. * * @throws IOException If there is...
if (args.length != 2) { usage(); } else { try (PDDocument document = Loader.loadPDF(new File(args[0]))) { if (document.isEncrypted()) { System.err.println( "Error:...
896
206
1,102
<no_super_class>
apache_pdfbox
pdfbox/examples/src/main/java/org/apache/pdfbox/examples/util/SplitBooklet.java
SplitBooklet
main
class SplitBooklet { /** * Default constructor. */ private SplitBooklet() { // example class should not be instantiated } public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>} private static void usage() { System.err.println("Usa...
if (args.length < 2) { usage(); System.exit(-1); } try (PDDocument document = Loader.loadPDF(new File(args[0])); PDDocument outdoc = new PDDocument()) { for (PDPage page : document.getPages()) { PDRecta...
126
566
692
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/CFFCIDFont.java
CFFCIDFont
getType2CharString
class CFFCIDFont extends CFFFont { private String registry; private String ordering; private int supplement; private List<Map<String, Object>> fontDictionaries = Collections.emptyList(); private List<Map<String, Object>> privateDictionaries = Collections.emptyList(); private FDSelect fdSelect; ...
CIDKeyedType2CharString type2 = charStringCache.get(cid); if (type2 == null) { int gid = getCharset().getGIDForCID(cid); byte[] bytes = charStrings[gid]; if (bytes == null) { bytes = charStrings[0]; // .notdef } ...
1,822
219
2,041
<methods>public non-sealed void <init>() ,public void addValueToTopDict(java.lang.String, java.lang.Object) ,public final List<byte[]> getCharStringBytes() ,public org.apache.fontbox.cff.CFFCharset getCharset() ,public byte[] getData() throws java.io.IOException,public org.apache.fontbox.util.BoundingBox getFontBBox() ...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/CFFCharsetCID.java
CFFCharsetCID
getGIDForCID
class CFFCharsetCID implements CFFCharset { private static final String EXCEPTION_MESSAGE = "Not a Type 1-equivalent font"; private final Map<Integer, Integer> sidOrCidToGid = new HashMap<>(250); // inverse private final Map<Integer, Integer> gidToCid = new HashMap<>(); @Override public bool...
Integer gid = sidOrCidToGid.get(cid); if (gid == null) { return 0; } return gid;
499
49
548
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/CFFCharsetType1.java
CFFCharsetType1
getGIDForSID
class CFFCharsetType1 implements CFFCharset { private static final String EXCEPTION_MESSAGE = "Not a CIDFont"; private final Map<Integer, Integer> sidOrCidToGid = new HashMap<>(250); private final Map<Integer, Integer> gidToSid = new HashMap<>(250); private final Map<String, Integer> nameToSid = new Ha...
Integer gid = sidOrCidToGid.get(sid); if (gid == null) { return 0; } return gid;
598
50
648
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java
CFFFont
getFontBBox
class CFFFont implements FontBoxFont { private String fontName; private CFFCharset charset; private CFFParser.ByteSource source; protected final Map<String, Object> topDict = new LinkedHashMap<>(); protected byte[][] charStrings; protected byte[][] globalSubrIndex; /** * The name of th...
List<Number> numbers = (List<Number>) topDict.get("FontBBox"); if (numbers.size() < 4) { throw new IOException("FontBBox must have 4 numbers, but is " + numbers); } return new BoundingBox(numbers);
1,179
77
1,256
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java
PrivateType1CharStringReader
getNominalWidthX
class PrivateType1CharStringReader implements Type1CharStringReader { @Override public Type1CharString getType1CharString(String name) throws IOException { return CFFType1Font.this.getType1CharString(name); } } @Override public GeneralPath getPath(String name...
if (nominalWidthX == Integer.MIN_VALUE) { Number num = (Number) getProperty("nominalWidthX"); nominalWidthX = num != null ? num.intValue() : 0; } return nominalWidthX;
1,386
67
1,453
<methods>public non-sealed void <init>() ,public void addValueToTopDict(java.lang.String, java.lang.Object) ,public final List<byte[]> getCharStringBytes() ,public org.apache.fontbox.cff.CFFCharset getCharset() ,public byte[] getData() throws java.io.IOException,public org.apache.fontbox.util.BoundingBox getFontBBox() ...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/DataInputByteArray.java
DataInputByteArray
setPosition
class DataInputByteArray implements DataInput { private final byte[] inputBuffer; private int bufferPosition = 0; /** * Constructor. * @param buffer the buffer to be read */ public DataInputByteArray(byte[] buffer) { inputBuffer = buffer; } /** * Determines if ...
if (position < 0) { throw new IOException("position is negative"); } if (position >= inputBuffer.length) { throw new IOException( "New position is out of range " + position + " >= " + inputBuffer.length); } bufferPositi...
861
79
940
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cff/DataInputRandomAccessRead.java
DataInputRandomAccessRead
peekUnsignedByte
class DataInputRandomAccessRead implements DataInput { private final RandomAccessRead randomAccessRead; /** * Constructor. * * @param randomAccessRead the source to be read from */ public DataInputRandomAccessRead(RandomAccessRead randomAccessRead) { this.randomAccessRead =...
if (offset < 0) { throw new IOException("offset is negative"); } if (offset == 0) { return randomAccessRead.peek(); } long currentPosition = randomAccessRead.getPosition(); if (currentPosition + offset >= randomAccessRead.length())...
1,135
162
1,297
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cmap/CIDRange.java
CIDRange
extend
class CIDRange { private final int from; private int to; private final int unicode; private final int codeLength; /** * Constructor. * * @param from start value of COD range * @param to end value of CID range * @param unicode unicode start value ...
if (codeLength == length && (newFrom == to + 1) && (newCid == unicode + to - from + 1)) { to = newTo; return true; } return false;
757
58
815
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/cmap/CodespaceRange.java
CodespaceRange
isFullMatch
class CodespaceRange { private final int[] start; private final int[] end; private final int codeLength; /** * Creates a new instance of CodespaceRange. The length of both arrays has to be the same.<br> * For one byte ranges startBytes and endBytes define a linear range of values. Double ...
// code must be the same length as the bounding codes if (codeLength != codeLen) { return false; } for (int i = 0; i < codeLength; i++) { int codeAsInt = code[i] & 0xFF; if (codeAsInt < start[i] || codeAsInt > end[i]) { ...
720
116
836
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/encoding/Encoding.java
Encoding
getName
class Encoding { /** * This is a mapping from a character code to a character name. */ private final Map<Integer, String> codeToName = new HashMap<>(250); /** * This is a mapping from a character name to a character code. */ private final Map<String, Integer> nameToCode = new HashMa...
String name = codeToName.get( code ); if (name != null) { return name; } return ".notdef";
442
43
485
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/pfb/PfbParser.java
PfbParser
parsePfb
class PfbParser { private static final Logger LOG = LogManager.getLogger(PfbParser.class); /** * the pfb header length. * (start-marker (1 byte), ascii-/binary-marker (1 byte), size (4 byte)) * 3*6 == 18 */ private static final int PFB_HEADER_LENGTH = 18; /** * the start ...
if (pfb.length < PFB_HEADER_LENGTH) { throw new IOException("PFB header missing"); } // read into segments and keep them List<Integer> typeList = new ArrayList<>(3); List<byte[]> barrList = new ArrayList<>(3); ByteArrayInputStream in = new ByteArrayIn...
1,021
872
1,893
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/CFFTable.java
CFFTable
read
class CFFTable extends TTFTable { /** * A tag that identifies this table type. */ public static final String TAG = "CFF "; private CFFFont cffFont; CFFTable() { super(); } /** * This will read the required data from the stream. * * @param ttf The font that...
byte[] bytes = data.read((int)getLength()); CFFParser parser = new CFFParser(); cffFont = parser.parse(bytes, new CFFBytesource(ttf)).get(0); initialized = true;
385
63
448
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/CmapTable.java
CmapTable
read
class CmapTable extends TTFTable { /** * A tag used to identify this table. */ public static final String TAG = "cmap"; // platform public static final int PLATFORM_UNICODE = 0; public static final int PLATFORM_MACINTOSH = 1; public static final int PLATFORM_WINDOWS = 3; // Mac e...
@SuppressWarnings({"unused", "squid:S1854", "squid:S1481"}) int version = data.readUnsignedShort(); int numberOfTables = data.readUnsignedShort(); cmaps = new CmapSubtable[numberOfTables]; for (int i = 0; i < numberOfTables; i++) { CmapSubtable cmap = new Cma...
822
214
1,036
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java
GlyfSimpleDescript
readFlags
class GlyfSimpleDescript extends GlyfDescript { private int[] endPtsOfContours; private byte[] flags; private short[] xCoordinates; private short[] yCoordinates; private final int pointCount; /** * Constructor for an empty description. */ GlyfSimpleDescript() { ...
for (int index = 0; index < flagCount; index++) { flags[index] = (byte) bais.readUnsignedByte(); if ((flags[index] & REPEAT) != 0) { int repeats = bais.readUnsignedByte(); for (int i = 1; i <= repeats; i++) { ...
1,480
185
1,665
<methods>public int getContourCount() ,public int[] getInstructions() ,public void resolve() <variables>public static final byte ON_CURVE,public static final byte REPEAT,public static final byte X_DUAL,public static final byte X_SHORT_VECTOR,public static final byte Y_DUAL,public static final byte Y_SHORT_VECTOR,privat...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java
GlyphData
initData
class GlyphData { private short xMin; private short yMin; private short xMax; private short yMax; private BoundingBox boundingBox = null; private short numberOfContours; private GlyfDescript glyphDescription = null; /** * This will read the required data from the stream. *...
numberOfContours = data.readSignedShort(); xMin = data.readSignedShort(); yMin = data.readSignedShort(); xMax = data.readSignedShort(); yMax = data.readSignedShort(); boundingBox = new BoundingBox(xMin, yMin, xMax, yMax); if (numberOfContours >= 0) { ...
636
196
832
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java
GlyphRenderer
describe
class GlyphRenderer { private static final Logger LOG = LogManager.getLogger(GlyphRenderer.class); private final GlyphDescription glyphDescription; GlyphRenderer(GlyphDescription glyphDescription) { this.glyphDescription = glyphDescription; } /** * Returns the path of...
int endPtIndex = 0; int endPtOfContourIndex = -1; Point[] points = new Point[gd.getPointCount()]; for (int i = 0; i < points.length; i++) { if (endPtOfContourIndex == -1) { endPtOfContourIndex = gd.getEndPtOfContours(endPtIndex); ...
1,506
253
1,759
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java
GlyphTable
read
class GlyphTable extends TTFTable { /** * Tag to identify this table. */ public static final String TAG = "glyf"; private GlyphData[] glyphs; // lazy table reading private TTFDataStream data; private IndexToLocationTable loca; private int numGlyphs; private int cached = 0; ...
loca = ttf.getIndexToLocation(); numGlyphs = ttf.getNumberOfGlyphs(); if (numGlyphs < MAX_CACHE_SIZE) { // don't cache the huge fonts to save memory glyphs = new GlyphData[numGlyphs]; } // we don't actually read the complete table here because i...
962
258
1,220
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java
HorizontalMetricsTable
read
class HorizontalMetricsTable extends TTFTable { /** * A tag that identifies this table type. */ public static final String TAG = "hmtx"; private int[] advanceWidth; private short[] leftSideBearing; private short[] nonHorizontalLeftSideBearing; private int numHMetrics; HorizontalM...
HorizontalHeaderTable hHeader = ttf.getHorizontalHeader(); if (hHeader == null) { throw new IOException("Could not get hmtx table"); } numHMetrics = hHeader.getNumberOfHMetrics(); int numGlyphs = ttf.getNumberOfGlyphs(); int bytesRead = 0; ad...
528
387
915
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/IndexToLocationTable.java
IndexToLocationTable
read
class IndexToLocationTable extends TTFTable { private static final short SHORT_OFFSETS = 0; private static final short LONG_OFFSETS = 1; /** * A tag that identifies this table type. */ public static final String TAG = "loca"; private long[] offsets; IndexToLocationTable() { ...
HeaderTable head = ttf.getHeader(); if (head == null) { throw new IOException("Could not get head table"); } int numGlyphs = ttf.getNumberOfGlyphs(); offsets = new long[ numGlyphs +1]; for( int i=0; i<numGlyphs+1; i++ ) { if( head....
289
297
586
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/KerningTable.java
KerningTable
read
class KerningTable extends TTFTable { private static final Logger LOG = LogManager.getLogger(KerningTable.class); /** * Tag to identify this table. */ public static final String TAG = "kern"; private KerningSubtable[] subtables; KerningTable() { } /** * This will read ...
int version = data.readUnsignedShort(); if (version != 0) { version = (version << 16) | data.readUnsignedShort(); } int numSubtables = 0; switch (version) { case 0: numSubtables = data.readUnsignedShort(); b...
415
255
670
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java
MaximumProfileTable
read
class MaximumProfileTable extends TTFTable { /** * A tag that identifies this table type. */ public static final String TAG = "maxp"; private float version; private int numGlyphs; private int maxPoints; private int maxContours; private int maxCompositePoints; private int maxCo...
version = data.read32Fixed(); numGlyphs = data.readUnsignedShort(); if (version >= 1.0f) { maxPoints = data.readUnsignedShort(); maxContours = data.readUnsignedShort(); maxCompositePoints = data.readUnsignedShort(); maxCompositeContours = ...
1,774
241
2,015
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/NameRecord.java
NameRecord
toString
class NameRecord { // platform ids public static final int PLATFORM_UNICODE = 0; public static final int PLATFORM_MACINTOSH = 1; public static final int PLATFORM_ISO = 2; public static final int PLATFORM_WINDOWS = 3; // Unicode encoding ids public static final int ENCODING_UNICODE_1_0 = 0; ...
return "platform=" + platformId + " pEncoding=" + platformEncodingId + " language=" + languageId + " name=" + nameId + " " + string;
1,417
56
1,473
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/OTFParser.java
OTFParser
readTable
class OTFParser extends TTFParser { /** * Constructor. */ public OTFParser() { super(); } /** * Constructor. * * @param isEmbedded true if the font is embedded in PDF */ public OTFParser(boolean isEmbedded) { super(isEmbedded); } @Overr...
// todo: this is a stub, a full implementation is needed switch (tag) { case "BASE": case "GDEF": case "GPOS": case GlyphSubstitutionTable.TAG: case OTLTable.TAG: return new OTLTable(); case CFFTable.TAG: ...
284
110
394
<methods>public void <init>() ,public void <init>(boolean) ,public org.apache.fontbox.ttf.TrueTypeFont parse(org.apache.pdfbox.io.RandomAccessRead) throws java.io.IOException,public org.apache.fontbox.ttf.TrueTypeFont parseEmbedded(java.io.InputStream) throws java.io.IOException<variables>private static final Logger LO...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/OpenTypeFont.java
OpenTypeFont
isSupportedOTF
class OpenTypeFont extends TrueTypeFont { private boolean isPostScript; /** * Constructor. Clients should use the OTFParser to create a new OpenTypeFont object. * * @param fontData The font data. */ OpenTypeFont(TTFDataStream fontData) { super(fontData); } @Over...
// OTF using CFF2 based outlines aren't yet supported return !(isPostScript // && !tables.containsKey(CFFTable.TAG) // && tables.containsKey("CFF2") // );
803
61
864
<methods>public void close() throws java.io.IOException,public void disableGsubFeature(java.lang.String) ,public void enableGsubFeature(java.lang.String) ,public void enableVerticalSubstitutions() ,public int getAdvanceHeight(int) throws java.io.IOException,public int getAdvanceWidth(int) throws java.io.IOException,pub...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/RandomAccessReadDataStream.java
RandomAccessReadDataStream
seek
class RandomAccessReadDataStream extends TTFDataStream { private final long length; private final byte[] data; private int currentPosition = 0; /** * Constructor. * * @param randomAccessRead source to be read from * * @throws IOException If there is a problem reading the source...
if (pos < 0) { throw new IOException("Invalid position " + pos); } currentPosition = pos < length ? (int) pos : (int) length;
1,201
48
1,249
<methods>public abstract long getCurrentPosition() throws java.io.IOException,public abstract java.io.InputStream getOriginalData() throws java.io.IOException,public abstract long getOriginalDataSize() ,public abstract int read() throws java.io.IOException,public byte[] read(int) throws java.io.IOException,public abstr...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/SubstitutingCmapLookup.java
SubstitutingCmapLookup
getGlyphId
class SubstitutingCmapLookup implements CmapLookup { private final CmapSubtable cmap; private final GlyphSubstitutionTable gsub; private final List<String> enabledFeatures; public SubstitutingCmapLookup(CmapSubtable cmap, GlyphSubstitutionTable gsub, List<String> enabledFeatures) { ...
int gid = cmap.getGlyphId(characterCode); String[] scriptTags = OpenTypeScript.getScriptTags(characterCode); return gsub.getSubstitution(gid, scriptTags, enabledFeatures);
208
58
266
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/TTCDataStream.java
TTCDataStream
close
class TTCDataStream extends TTFDataStream { private final TTFDataStream stream; TTCDataStream(TTFDataStream stream) { this.stream = stream; } @Override public int read() throws IOException { return stream.read(); } @Override public long readLong() thro...
// don't close the underlying stream, as it is shared by all fonts from the same TTC // TrueTypeCollection.close() must be called instead
302
39
341
<methods>public abstract long getCurrentPosition() throws java.io.IOException,public abstract java.io.InputStream getOriginalData() throws java.io.IOException,public abstract long getOriginalDataSize() ,public abstract int read() throws java.io.IOException,public byte[] read(int) throws java.io.IOException,public abstr...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java
TrueTypeCollection
getFontAtIndex
class TrueTypeCollection implements Closeable { private final TTFDataStream stream; private final int numFonts; private final long[] fontOffsets; /** * Creates a new TrueTypeCollection from a .ttc file. * * @param file The TTC file. * @throws IOException If the font could not be par...
stream.seek(fontOffsets[idx]); TTFParser parser; if (stream.readTag().equals("OTTO")) { parser = new OTFParser(false); } else { parser = new TTFParser(false); } stream.seek(fontOffsets[idx]); return parser.parse(new...
952
100
1,052
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/VerticalHeaderTable.java
VerticalHeaderTable
read
class VerticalHeaderTable extends TTFTable { /** * A tag that identifies this table type. */ public static final String TAG = "vhea"; private float version; private short ascender; private short descender; private short lineGap; private int advanceHeightMax; private short ...
version = data.read32Fixed(); ascender = data.readSignedShort(); descender = data.readSignedShort(); lineGap = data.readSignedShort(); advanceHeightMax = data.readUnsignedShort(); minTopSideBearing = data.readSignedShort(); minBottomSideBearing = data.readSignedS...
993
235
1,228
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/VerticalMetricsTable.java
VerticalMetricsTable
getAdvanceHeight
class VerticalMetricsTable extends TTFTable { /** * A tag that identifies this table type. */ public static final String TAG = "vmtx"; private int[] advanceHeight; private short[] topSideBearing; private short[] additionalTopSideBearing; private int numVMetrics; VerticalMetri...
if (gid < numVMetrics) { return advanceHeight[gid]; } else { // monospaced fonts may not have a height for every glyph // the last one is for subsequent glyphs return advanceHeight[advanceHeight.length -1]; }
742
80
822
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/VerticalOriginTable.java
VerticalOriginTable
read
class VerticalOriginTable extends TTFTable { /** * A tag that identifies this table type. */ public static final String TAG = "VORG"; private float version; private int defaultVertOriginY; private Map<Integer, Integer> origins; VerticalOriginTable() { super(); } ...
version = data.read32Fixed(); defaultVertOriginY = data.readSignedShort(); int numVertOriginYMetrics = data.readUnsignedShort(); origins = new ConcurrentHashMap<>(numVertOriginYMetrics); for (int i = 0; i < numVertOriginYMetrics; ++i) { int g = data.readUnsi...
371
132
503
<methods>public long getCheckSum() ,public boolean getInitialized() ,public long getLength() ,public long getOffset() ,public java.lang.String getTag() <variables>private long checkSum,protected boolean initialized,private long length,private long offset,private java.lang.String tag
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java
WGL4Names
getAllNames
class WGL4Names { /** * The number of standard mac glyph names. */ public static final int NUMBER_OF_MAC_GLYPHS = 258; /** * The 258 standard mac glyph names a used in 'post' format 1 and 2. */ private static final String[] MAC_GLYPH_NAMES = { ".notdef",".null", "...
String[] glyphNames = new String[NUMBER_OF_MAC_GLYPHS]; System.arraycopy(MAC_GLYPH_NAMES, 0, glyphNames, 0, NUMBER_OF_MAC_GLYPHS); return glyphNames;
1,814
76
1,890
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/CompoundCharacterTokenizer.java
CompoundCharacterTokenizer
tokenize
class CompoundCharacterTokenizer { private final Pattern regexExpression; /** * Constructor. Calls getRegexFromTokens which returns strings like * (_79_99_)|(_80_99_)|(_92_99_) and creates a regexp assigned to regexExpression. See the code * in GlyphArraySplitterRegexImpl on how these strings we...
List<String> tokens = new ArrayList<>(); Matcher regexMatcher = regexExpression.matcher(text); int lastIndexOfPrevMatch = 0; while (regexMatcher.find()) // this is where the magic happens: // the regexp is used to find a matching pattern for substi...
312
234
546
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/DefaultGsubWorker.java
DefaultGsubWorker
applyTransforms
class DefaultGsubWorker implements GsubWorker { private static final Logger LOG = LogManager.getLogger(DefaultGsubWorker.class); @Override public List<Integer> applyTransforms(List<Integer> originalGlyphIds) {<FILL_FUNCTION_BODY>} }
LOG.warn( "{} class does not perform actual GSUB substitutions. Perhaps the selected language is not yet supported by the FontBox library.", getClass().getSimpleName()); // Make the result read-only to prevent accidental modifications of the source list return Co...
79
81
160
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphArraySplitterRegexImpl.java
GlyphArraySplitterRegexImpl
getMatchersAsStrings
class GlyphArraySplitterRegexImpl implements GlyphArraySplitter { private static final String GLYPH_ID_SEPARATOR = "_"; private final CompoundCharacterTokenizer compoundCharacterTokenizer; public GlyphArraySplitterRegexImpl(Set<List<Integer>> matchers) { compoundCharacterTokenizer = new Compou...
Set<String> stringMatchers = new TreeSet<>((String s1, String s2) -> { // comparator to ensure that strings with the same beginning // put the larger string first if (s1.length() == s2.length()) { return s2.compareTo(s1); ...
516
138
654
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerFactory.java
GsubWorkerFactory
getGsubWorker
class GsubWorkerFactory { private static final Logger LOG = LogManager.getLogger(GsubWorkerFactory.class); public GsubWorker getGsubWorker(CmapLookup cmapLookup, GsubData gsubData) {<FILL_FUNCTION_BODY>} }
//TODO this needs to be redesigned / improved because if a font supports several languages, // it will choose one of them and maybe not the one expected. LOG.debug("Language: {}", gsubData.getLanguage()); switch (gsubData.getLanguage()) { case BENGALI: return...
79
213
292
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatin.java
GsubWorkerForLatin
applyGsubFeature
class GsubWorkerForLatin implements GsubWorker { private static final Logger LOG = LogManager.getLogger(GsubWorkerForLatin.class); /** * This sequence is very important. This has been taken from <a href= * "https://docs.microsoft.com/en-us/typography/script-development/standard">https://docs.microsof...
if (scriptFeature.getAllGlyphIdsForSubstitution().isEmpty()) { LOG.debug("getAllGlyphIdsForSubstitution() for {} is empty", scriptFeature.getName()); return originalGlyphs; } GlyphArraySplitter glyphArraySplitter = new GlyphArrayS...
473
314
787
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/model/MapBackedGsubData.java
MapBackedGsubData
getFeature
class MapBackedGsubData implements GsubData { private final Language language; private final String activeScriptName; private final Map<String, Map<List<Integer>, Integer>> glyphSubstitutionMap; public MapBackedGsubData(Language language, String activeScriptName, Map<String, Map<List<Integ...
if (!isFeatureSupported(featureName)) { throw new UnsupportedOperationException( "The feature " + featureName + " is not supported!"); } return new MapBackedScriptFeature(featureName, glyphSubstitutionMap.get(featureName));
301
72
373
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/model/MapBackedScriptFeature.java
MapBackedScriptFeature
equals
class MapBackedScriptFeature implements ScriptFeature { private final String name; private final Map<List<Integer>, Integer> featureMap; public MapBackedScriptFeature(String name, Map<List<Integer>, Integer> featureMap) { this.name = name; this.featureMap = featureMap; } @Over...
if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } MapBackedScriptFeature other = (MapBackedScriptFeature) obj; return Objects.equals(other.name, this.name) && Objects.equals(other....
341
101
442
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/table/common/CoverageTableFormat2.java
CoverageTableFormat2
getRangeRecordsAsArray
class CoverageTableFormat2 extends CoverageTableFormat1 { private final RangeRecord[] rangeRecords; public CoverageTableFormat2(int coverageFormat, RangeRecord[] rangeRecords) { super(coverageFormat, getRangeRecordsAsArray(rangeRecords)); this.rangeRecords = rangeRecords; } public ...
List<Integer> glyphIds = new ArrayList<>(); for (RangeRecord rangeRecord : rangeRecords) { for (int glyphId = rangeRecord.getStartGlyphID(); glyphId <= rangeRecord.getEndGlyphID(); glyphId++) { glyphIds.add(glyphId); } } int[...
193
162
355
<methods>public void <init>(int, int[]) ,public int getCoverageIndex(int) ,public int[] getGlyphArray() ,public int getGlyphId(int) ,public int getSize() ,public java.lang.String toString() <variables>private final non-sealed int[] glyphArray
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/table/gsub/LookupTypeSingleSubstFormat1.java
LookupTypeSingleSubstFormat1
doSubstitution
class LookupTypeSingleSubstFormat1 extends LookupSubTable { private final short deltaGlyphID; public LookupTypeSingleSubstFormat1(int substFormat, CoverageTable coverageTable, short deltaGlyphID) { super(substFormat, coverageTable); this.deltaGlyphID = deltaGlyphID; } @...
return coverageIndex < 0 ? gid : gid + deltaGlyphID;
213
22
235
<methods>public void <init>(int, org.apache.fontbox.ttf.table.common.CoverageTable) ,public abstract int doSubstitution(int, int) ,public org.apache.fontbox.ttf.table.common.CoverageTable getCoverageTable() ,public int getSubstFormat() <variables>private final non-sealed org.apache.fontbox.ttf.table.common.CoverageTabl...
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/ttf/table/gsub/SequenceTable.java
SequenceTable
toString
class SequenceTable { private final int glyphCount; private final int[] substituteGlyphIDs; public SequenceTable(int glyphCount, int[] substituteGlyphIDs) { this.glyphCount = glyphCount; this.substituteGlyphIDs = substituteGlyphIDs; } public int getGlyphCount() { re...
return "SequenceTable{" + "glyphCount=" + glyphCount + ", substituteGlyphIDs=" + Arrays.toString(substituteGlyphIDs) + '}';
166
47
213
<no_super_class>
apache_pdfbox
pdfbox/fontbox/src/main/java/org/apache/fontbox/type1/Token.java
Token
toString
class Token { /** * All different types of tokens. * */ enum Kind { NONE, STRING, NAME, LITERAL, REAL, INTEGER, START_ARRAY, END_ARRAY, START_PROC, END_PROC, START_DICT, END_DICT, CHARSTRING } // exposed statically for convenience stat...
if (kind == CHARSTRING) { return "Token[kind=CHARSTRING, data=" + data.length + " bytes]"; } else { return "Token[kind=" + kind + ", text=" + text + "]"; }
727
72
799
<no_super_class>