Package org.pdfclown.documents

Examples of org.pdfclown.documents.Document$Configuration


    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

      @Override
      public Configuration upgradeConfiguration(
          final org.sonatype.nexus.configuration.model.v2_2_0.Configuration oldConfig)
      {
        final Configuration newConfig = super.upgradeConfiguration(oldConfig);

        if (oldConfig.getGlobalHttpProxySettings() != null) {
          newConfig.setRemoteProxySettings(new CRemoteProxySettings());
          newConfig.getRemoteProxySettings().setHttpProxySettings(
              upgradeCRemoteHttpProxySettings(oldConfig.getGlobalHttpProxySettings())
          );
          newConfig.getRemoteProxySettings().setNonProxyHosts(
              oldConfig.getGlobalHttpProxySettings().getNonProxyHosts()
          );
        }

        return newConfig;
View Full Code Here

    org.sonatype.nexus.configuration.model.v2_5_0.Configuration oldc =
        (org.sonatype.nexus.configuration.model.v2_5_0.Configuration) message.getConfiguration();

    BasicVersionUpgrade versionConverter = new BasicVersionUpgrade();

    Configuration newc = versionConverter.upgradeConfiguration(oldc);
    newc.setVersion(Configuration.MODEL_VERSION);

    upgradeEmptyTrashTaskConfiguration(newc);
    updateSmtpSslTlsSettings(newc);

    message.setModelVersion(Configuration.MODEL_VERSION);
View Full Code Here

  }

  public void upgrade(UpgradeMessage message)
      throws ConfigurationIsCorruptedException
  {
    Configuration oldc = (Configuration) message.getConfiguration();

    org.sonatype.security.model.v2_0_0.Configuration newc = new org.sonatype.security.model.v2_0_0.Configuration();

    newc.setVersion(org.sonatype.security.model.v2_0_0.Configuration.MODEL_VERSION);

    for (CUser oldu : (List<CUser>) oldc.getUsers()) {
      org.sonatype.security.model.v2_0_0.CUser newu = new org.sonatype.security.model.v2_0_0.CUser();

      newu.setEmail(oldu.getEmail());
      newu.setId(oldu.getUserId());
      newu.setName(oldu.getName());
      newu.setPassword(oldu.getPassword());
      newu.setStatus(oldu.getStatus());
      newu.setRoles(oldu.getRoles());

      newc.addUser(newu);
    }

    for (CRole oldr : (List<CRole>) oldc.getRoles()) {
      org.sonatype.security.model.v2_0_0.CRole newr = new org.sonatype.security.model.v2_0_0.CRole();

      newr.setDescription(oldr.getDescription());
      newr.setId(oldr.getId());
      newr.setName(oldr.getName());
      newr.setPrivileges(oldr.getPrivileges());
      newr.setRoles(oldr.getRoles());
      newr.setSessionTimeout(oldr.getSessionTimeout());

      newc.addRole(newr);
    }

    for (CRepoTargetPrivilege oldp : (List<CRepoTargetPrivilege>) oldc.getRepositoryTargetPrivileges()) {
      org.sonatype.security.model.v2_0_0.CPrivilege newp = new org.sonatype.security.model.v2_0_0.CPrivilege();

      newp.setDescription(oldp.getDescription());
      newp.setId(oldp.getId());
      newp.setName(oldp.getName());
      newp.setType("target");

      org.sonatype.security.model.v2_0_0.CProperty prop = new org.sonatype.security.model.v2_0_0.CProperty();
      prop.setKey("method");
      prop.setValue(oldp.getMethod());
      newp.addProperty(prop);

      if (!StringUtils.isEmpty(oldp.getRepositoryId())) {
        prop = new org.sonatype.security.model.v2_0_0.CProperty();
        prop.setKey("repositoryGroupId");
        prop.setValue(oldp.getGroupId());
        newp.addProperty(prop);
      }

      if (!StringUtils.isEmpty(oldp.getRepositoryId())) {
        prop = new org.sonatype.security.model.v2_0_0.CProperty();
        prop.setKey("repositoryId");
        prop.setValue(oldp.getRepositoryId());
        newp.addProperty(prop);
      }

      prop = new org.sonatype.security.model.v2_0_0.CProperty();
      prop.setKey("repositoryTargetId");
      prop.setValue(oldp.getRepositoryTargetId());
      newp.addProperty(prop);

      newc.addPrivilege(newp);
    }

    for (CApplicationPrivilege oldp : (List<CApplicationPrivilege>) oldc.getApplicationPrivileges()) {
      org.sonatype.security.model.v2_0_0.CPrivilege newp = new org.sonatype.security.model.v2_0_0.CPrivilege();

      newp.setDescription(oldp.getDescription());
      newp.setId(oldp.getId());
      newp.setName(oldp.getName());
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.Document$Configuration

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.