Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfName


    static public String getDictionaryDetail(PdfDictionary dic, int depth){
        StringBuffer builder = new StringBuffer();
        builder.append('(');
        List subDictionaries = new ArrayList();
        for (Iterator i = dic.getKeys().iterator(); i.hasNext(); ) {
            PdfName key = (PdfName)i.next();
            PdfObject val = dic.getDirectObject(key);
            if (val.isDictionary())
                subDictionaries.add(key);
            builder.append(key);
            builder.append('=');
            builder.append(val);
            builder.append(", ");
        }
        builder.setLength(builder.length()-2);
        builder.append(')');
        PdfName pdfSubDictionaryName;
        for (Iterator it = subDictionaries.iterator(); it.hasNext(); ) {
          pdfSubDictionaryName = (PdfName)it.next();
            builder.append('\n');
            for(int i = 0; i < depth+1; i++){
                builder.append('\t');
View Full Code Here


    /**
     * A content operator implementation (Tf).
     */
    private static class SetTextFont implements ContentOperator{
        public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
            PdfName fontResourceName = (PdfName)operands.get(0);
            float size = ((PdfNumber)operands.get(1)).floatValue();
           
            PdfDictionary fontsDictionary = processor.resources.getAsDict(PdfName.FONT);
            CMapAwareDocumentFont font = new CMapAwareDocumentFont((PRIndirectReference)fontsDictionary.get(fontResourceName));
           
View Full Code Here

    /**
     * A content operator implementation (gs).
     */
    private static class ProcessGraphicsStateResource implements ContentOperator{
        public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) {
            PdfName dictionaryName = (PdfName)operands.get(0);
            PdfDictionary extGState = processor.resources.getAsDict(PdfName.EXTGSTATE);
            if (extGState == null)
                throw new IllegalArgumentException("Resources do not contain ExtGState entry. Unable to process operator " + operator);
            PdfDictionary gsDic = extGState.getAsDict(dictionaryName);
            if (gsDic == null)
View Full Code Here

        PdfObject newValue;
        if (cs.isName())
            newValue = cs;
        else {
            newValue = value;
            PdfName first = value.getAsName(0);
            if (PdfName.INDEXED.equals(first)) {
                if (value.size() >= 2) {
                    PdfArray second = value.getAsArray(1);
                    if (second != null) {
                        value.set(1, simplifyColorspace(second));
View Full Code Here

   * Gets a PDF Name from an array or returns the object that was passed.
   */
    private PdfObject simplifyColorspace(PdfArray obj) {
        if (obj == null)
            return obj;
        PdfName first = obj.getAsName(0);
        if (PdfName.CALGRAY.equals(first))
            return PdfName.DEVICEGRAY;
        else if (PdfName.CALRGB.equals(first))
            return PdfName.DEVICERGB;
        else
View Full Code Here

  }

  public static PdfViewerPreferencesImp getViewerPreferences(PdfDictionary catalog) {
    PdfViewerPreferencesImp preferences = new PdfViewerPreferencesImp();
    int prefs = 0;
    PdfName name = null;
    // page layout
    PdfObject obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.PAGELAYOUT));
    if (obj != null && obj.isName()) {
      name = (PdfName) obj;
      if (name.equals(PdfName.SINGLEPAGE))
        prefs |= PdfWriter.PageLayoutSinglePage;
      else if (name.equals(PdfName.ONECOLUMN))
        prefs |= PdfWriter.PageLayoutOneColumn;
      else if (name.equals(PdfName.TWOCOLUMNLEFT))
        prefs |= PdfWriter.PageLayoutTwoColumnLeft;
      else if (name.equals(PdfName.TWOCOLUMNRIGHT))
        prefs |= PdfWriter.PageLayoutTwoColumnRight;
      else if (name.equals(PdfName.TWOPAGELEFT))
        prefs |= PdfWriter.PageLayoutTwoPageLeft;
      else if (name.equals(PdfName.TWOPAGERIGHT))
        prefs |= PdfWriter.PageLayoutTwoPageRight;
    }
    // page mode
    obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.PAGEMODE));
    if (obj != null && obj.isName()) {
      name = (PdfName) obj;
      if (name.equals(PdfName.USENONE))
        prefs |= PdfWriter.PageModeUseNone;
      else if (name.equals(PdfName.USEOUTLINES))
        prefs |= PdfWriter.PageModeUseOutlines;
      else if (name.equals(PdfName.USETHUMBS))
        prefs |= PdfWriter.PageModeUseThumbs;
      else if (name.equals(PdfName.FULLSCREEN))
        prefs |= PdfWriter.PageModeFullScreen;
      else if (name.equals(PdfName.USEOC))
        prefs |= PdfWriter.PageModeUseOC;
      else if (name.equals(PdfName.USEATTACHMENTS))
        prefs |= PdfWriter.PageModeUseAttachments;
    }
    // set page layout and page mode preferences
    preferences.setViewerPreferences(prefs);
    // other preferences
View Full Code Here

    public void completeInfoDictionary(PdfDictionary info) {
        if (isPdfX() && !isPdfA1()) {
            if (info.get(PdfName.GTS_PDFXVERSION) == null) {
                if (isPdfX1A2001()) {
                    info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-1:2001"));
                    info.put(new PdfName("GTS_PDFXConformance"), new PdfString("PDF/X-1a:2001"));
                }
                else if (isPdfX32002())
                    info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-3:2002"));
            }
            if (info.get(PdfName.TITLE) == null) {
                info.put(PdfName.TITLE, new PdfString("Pdf document"));
            }
            if (info.get(PdfName.CREATOR) == null) {
                info.put(PdfName.CREATOR, new PdfString("Unknown"));
            }
            if (info.get(PdfName.TRAPPED) == null) {
                info.put(PdfName.TRAPPED, new PdfName("False"));
            }
        }
    }
View Full Code Here

   * Constructs a PDF Collection Sort Dictionary.
   * @param key  the key of the field that will be used to sort entries
   */
  public PdfCollectionSort(String key) {
    super(PdfName.COLLECTIONSORT);
    put(PdfName.S, new PdfName(key));
  }
View Full Code Here

   */
  public PdfCollectionSort(String[] keys) {
    super(PdfName.COLLECTIONSORT);
    PdfArray array = new PdfArray();
    for (int i = 0; i < keys.length; i++) {
      array.add(new PdfName(keys[i]));
    }
    put(PdfName.S, array);
  }
View Full Code Here

  /**
   * Sets the value of the collection item.
   * @param value
   */
  public void addItem(String key, String value) {
    PdfName fieldname = new PdfName(key);
    PdfCollectionField field = (PdfCollectionField)schema.get(fieldname);
    put(fieldname, field.getValue(value));
  }
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.PdfName

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.