Package org.pdfclown.documents

Examples of org.pdfclown.documents.Document


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

    Document document = file.getDocument();

    // 2. Content tweaking.
    for(Page page : document.getPages())
    {
      // Get the page contents!
      Contents contents = page.getContents();
      contents.add(0,new SetLineWidth(10)); // Forces the override of line width's initial value (1.0) [PDF:1.6:4.3] setting it at 10 user-space units.
      for(ContentObject obj : contents)
View Full Code Here


    catch(FileFormatException e)
    {throw new RuntimeException(filePath + " file has a bad file format.",e);}
    catch(Exception e)
    {throw new RuntimeException(filePath + " file access error.",e);}

    Document document = file.getDocument();

    // 2. Document parsing.
    // 2.1. Showing basic metadata...
    System.out.println("\nDocument information:");
    Information info = document.getInformation();
    if(info == null)
    {System.out.println("No information available (Info dictionary doesn't exist).");}
    else
    {
      System.out.println("Author: " + info.getAuthor());
      System.out.println("Title: " + info.getTitle());
      System.out.println("Subject: " + info.getSubject());
      System.out.println("CreationDate: " + info.getCreationDate());
    }

    System.out.println("\nIterating through the indirect-object collection (please wait)...");

    // 2.2. Counting the indirect objects, grouping them by type...
    HashMap<String,Integer> objCounters = new HashMap<String,Integer>();
    objCounters.put("xref free entry",0);
    for(PdfIndirectObject object : file.getIndirectObjects())
    {
      if(object.isInUse()) // In-use entry.
      {
        String typeName = object.getDataObject().getClass().getSimpleName();
        if(objCounters.containsKey(typeName))
        {objCounters.put(typeName, objCounters.get(typeName) + 1);}
        else
        {objCounters.put(typeName, 1);}
      }
      else // Free entry.
      {objCounters.put("xref free entry", objCounters.get("xref free entry") + 1);}
    }
    System.out.println("\nIndirect objects partial counts (grouped by PDF object type):");
    for(Map.Entry<String,Integer> entry : objCounters.entrySet())
    {System.out.println(" " + entry.getKey() + ": " + entry.getValue());}
    System.out.println("Indirect objects total count: " + file.getIndirectObjects().size());

    // 2.3. Showing some page information...
    Pages pages = document.getPages();
    int pageCount = pages.size();
    System.out.println("\nPage count: " + pageCount);

    int pageIndex = (int)Math.floor((float)pageCount / 2);
    System.out.println("Mid page:");
View Full Code Here

  public boolean run(
    )
  {
    // 1. Creating the document...
    File file = new File();
    Document document = file.getDocument();

    // 2. Applying links...
    buildLinks(document);

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

  public Document extract(
    int startIndex,
    int endIndex
    )
  {
    Document extractedDocument = new File().getDocument();
    {
      // Add the pages to the target file!
      /*
        NOTE: To be added to an alien document,
        pages MUST be contextualized within it first,
        then added to the target pages collection.
      */
      extractedDocument.getPages().addAll(
        (Collection<Page>)extractedDocument.contextualize(
          pages.subList(startIndex,endIndex)
          )
        );
    }
    return extractedDocument;
View Full Code Here

    )
  {
    List<Document> documents = new ArrayList<Document>();
    for(Page page : pages)
    {
      Document pageDocument = new File().getDocument();
      pageDocument.getPages().add(
        page.clone(pageDocument)
        );
      documents.add(pageDocument);
    }
    return documents;
View Full Code Here

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

    // 2. Insert the contents into the document!
    buildCurvesPage(document);
    buildMiscellaneousPage(document);
    buildSimpleTextPage(document);
View Full Code Here

  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

    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())
    {
      System.out.println("\nScanning page " + (page.getIndex()+1) + "...\n");

      stamper.setPage(page);
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.Document

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.