Package org.pdfclown.files

Examples of org.pdfclown.files.File


  @Override
  public boolean run(
    )
  {
    // 1. Opening the PDF file...
    File file;
    {
      String filePath = promptPdfFileChoice("Please select a PDF file");

      try
      {file = new File(filePath);}
      catch(Exception e)
      {throw new RuntimeException(filePath + " file access error.",e);}
    }

    // 2. Modifying the document...
    Document document = file.getDocument();
    {
      // Create the action dictionary!
      PdfDictionary action = new PdfDictionary();
      // Define the action type (in this case: go-to)!
      action.put(new PdfName("S"),new PdfName("GoTo"));
      // Defining the action destination...
      {
        // Create the destination array!
        PdfArray destination = new PdfArray();
        // Define the 2nd page as the destination target!
        destination.add(document.getPages().get(1).getBaseObject());
        // Define the location of the document window on the page (fit vertically)!
        destination.add(new PdfName("FitV"));
        // Define the window's left-edge horizontal coordinate!
        destination.add(new PdfInteger(-32768));
        // Associate the destination to the action!
        action.put(new PdfName("D"),destination);
      }
      // Associate the action to the document!
      document.getBaseDataObject().put(
        new PdfName("OpenAction"),
        file.register(action) // Adds the action to the file, returning its reference.
        ); document.update(); // Updates the existing document object (fundamental to override previous content).
    }

    // (boilerplate metadata insertion -- ignore it)
    buildAccessories(document,"Primitive objects","manipulating a document at primitive object level");
View Full Code Here


    )
  {
    String filePath = promptPdfFileChoice("Please select a PDF file");

    // 1. Open the PDF file!
    File file;
    try
    {file = new File(filePath);}
    catch(Exception e)
    {throw new RuntimeException(filePath + " file access error.",e);}

    Document document = file.getDocument();

    // 2. Link extraction from the document pages.
    TextExtractor extractor = new TextExtractor();
    extractor.setAreaTolerance(2); // 2 pt tolerance on area boundary detection.
    boolean linkFound = false;
View Full Code Here

  @Override
  public boolean run(
    )
  {
    // 1. PDF file instantiation.
    File file = new File();
    Document document = file.getDocument();

    // 2. Content creation.
    populate(document);

    // (boilerplate metadata insertion -- ignore it)
View Full Code Here

    )
  {
    String filePath = promptPdfFileChoice("Please select a PDF file");

    // 1. Open the PDF file!
    File file;
    try
    {file = new File(filePath);}
    catch(Exception e)
    {throw new RuntimeException(filePath + " file access error.",e);}

    Document document = file.getDocument();

    // 2. Content removal.
    for(Page page : document.getPages())
    {
      // Get the page contents!
View Full Code Here

    )
  {
    String filePath = promptPdfFileChoice("Please select a PDF file");

    // 1. Open the PDF file!
    File file;
    try
    {file = new File(filePath);}
    catch(Exception e)
    {throw new RuntimeException(filePath + " file access error.",e);}

    Document document = file.getDocument();
   
    PageStamper stamper = new PageStamper(); // NOTE: Page stamper is used to draw contents on existing pages.
   
    // 2. Iterating through the document pages...
    for(Page page : document.getPages())
View Full Code Here

  @Override
  public boolean run(
    )
  {
    // 1. PDF file instantiation.
    File file = new File();
    Document document = file.getDocument();

    // 2. Content creation.
    populate(document);

    // (boilerplate metadata insertion -- ignore it)
View Full Code Here

    )
  {
    String filePath = promptPdfFileChoice("Please select a PDF file");

    // 1. Open the PDF file!
    File file;
    try
    {file = new File(filePath);}
    catch(Exception e)
    {throw new RuntimeException(filePath + " file access error.",e);}

    Document document = file.getDocument();

    // 2. Text extraction from the document pages.
    TextExtractor extractor = new TextExtractor();
    for(Page page : document.getPages())
    {
View Full Code Here

    )
  {
    String filePath = promptPdfFileChoice("Please select a PDF file");

    // 1. Open the PDF file!
    File file;
    try
    {file = new File(filePath);}
    catch(Exception e)
    {throw new RuntimeException(filePath + " file access error.",e);}

    Document document = file.getDocument();

    // 2. Parsing the document...
    System.out.println("\nLooking for images...");
    for(Page page : document.getPages())
    {
View Full Code Here

  @Override
  public boolean run(
    )
  {
    // 1. PDF file instantiation.
    File file = new File();
    Document document = file.getDocument();

    // 2. Content creation.
    populate(document);

    // (boilerplate metadata insertion -- ignore it)
View Full Code Here

  @Override
  public boolean run(
    )
  {
    // 1. Instantiate a new PDF file!
    File file = new File();
    Document document = file.getDocument();

    // 2. Insert the contents into the document!
    populate(document);

    // (boilerplate metadata insertion -- ignore it)
View Full Code Here

TOP

Related Classes of org.pdfclown.files.File

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.