ConvertPagesToImages.writeAllPagesAsImagesToDir("inputFileOrDir", "outputDir", "bmp", 1.33f);
PdfA3Converter converter = new PdfA3Converter(PdfA3Converter.Level.B);
PdfA3Converter.ConversionResult result = converter.convert(new File("inputFile.pdf"), new File("outputFile.pdf"));
if (result.issues().isEmpty()) {
// If no issues reported then file converted successfully
// A list of changes to the file are also reported
Set<String> changes = result.changes();
System.out.println("Success!");
} else {
// File was not able to convert
System.out.println("Failure");
}
final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));
pdf.writeDocument(new File("outputFile.pdf"), "encryptionPassword".getBytes());
pdf.closeDocument();
// Extract text
ExtractTextAsWordList.writeAllWordlistsToDir("inputFileOrDirectory", "outputDir", -1);
// Extract images
ExtractClippedImages.writeAllClippedImagesToDir("inputFileOrDirectory", "outputDir", "outputImageFormat", new String[] {"imageHeightAsFloat", "subDirectoryForHeight"});
// Extract metadata
final PdfUtilities utilities = new PdfUtilities("path/to/exampleFile.pdf");
try {
if (utilities.openPDFFile()) {
// Returns a String containing all metadata fields for the document
final String documentPropertiesAsXML = utilities.getDocumentPropertyFieldsInXML();
// Returns the total page count as an int
final int totalPageCount = utilities.getPageCount();
for (int i = 1; i != totalPageCount; i++) {
// Get the page dimensions for the specified page in the given units and type
final float[] pageDimensions = utilities.getPageDimensions(i, PdfUtilities.PageUnits.Pixels, PdfUtilities.PageSizeType.CropBox);
// Returns the image data as a String for the specified page
final String xImageDataForPage = utilities.getXImageDataForPage(i);
}
}
} catch (final PdfException e) {
e.printStackTrace();
}
utilities.closePDFfile();
Viewer viewer = new Viewer();
viewer.setupViewer();
viewer.executeCommand(ViewerCommands.OPENFILE, "inputFile.pdf");
final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));
pdf.addPage(1, PaperSize.A4_LANDSCAPE);
pdf.addText(1, "Hello World", 10, 10, BaseFont.HelveticaBold, 12, 1, 0.3f, 0.2f);
pdf.addImage(1, new BufferedImage(), new float[] {0, 0, 100, 100});
pdf.rotatePage(1, 90);
pdf.apply();
pdf.writeDocument(new File("outputFile.pdf"));
PrintPdfPages print = new PrintPdfPages("inputFile.pdf");
if (print.openPDFFile()) {
print.printAllPages("Printer Name");
}
ArrayList<Float[]> resultsForPages = FindTextInRectangle.findTextOnAllPages("/path/to/file.pdf", "textToFind");