Package org.pdfclown.documents.contents

Examples of org.pdfclown.documents.contents.FontResources


    Font value
    )
  {
    // Ensuring that the font exists within the context resources...
    Resources resources = scanner.getContentContext().getResources();
    FontResources fonts = resources.getFonts();
    // No font resources collection?
    if(fonts == null)
    {
      // Create the font resources collection!
      fonts = new FontResources(scanner.getContents().getDocument());
      resources.setFonts(fonts); resources.update();
    }
    // Get the key associated to the font!
    PdfName name = fonts.getBaseDataObject().getKey(value.getBaseObject());
    // No key found?
    if(name == null)
    {
      // Insert the font within the resources!
      int fontIndex = fonts.size();
      do
      {name = new PdfName(String.valueOf(++fontIndex));}
      while(fonts.containsKey(name));
      fonts.put(name,value); fonts.update();
    }

    return name;
  }
View Full Code Here


    // 2. Setting the document resources...
    // 2.1. Resources collection.
    Resources resources = new Resources(document); // Instantiates the resources collection inside the document context.
    document.setResources(resources); // Puts the resources collection in the common resources role.
    // 2.2. Fonts collection.
    FontResources fonts = new FontResources(document); // Instantiates the fonts collection inside the document context.
    resources.setFonts(fonts); // Puts the fonts collection in the common resources role.
    // Add a font to the fonts collection!
    fonts.put(
      ResourceName_DefaultFont,
      new StandardType1Font(
        document,
        StandardType1Font.FamilyEnum.Courier,
        true,
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.contents.FontResources

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.