Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfObject


  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.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
    obj = PdfReader.getPdfObjectRelease(catalog
        .get(PdfName.VIEWERPREFERENCES));
    if (obj != null && obj.isDictionary()) {
      PdfDictionary vp = (PdfDictionary) obj;
      for (int i = 0; i < VIEWER_PREFERENCES.length; i++) {
        obj = PdfReader.getPdfObjectRelease(vp.get(VIEWER_PREFERENCES[i]));
        preferences.addViewerPreference(VIEWER_PREFERENCES[i], obj);
      }
View Full Code Here


                PdfImage image = (PdfImage)obj1;
                if (image.get(PdfName.SMASK) != null)
                    throw new PdfXConformanceException("The /SMask key is not allowed in images.");
                switch (conf) {
                    case PdfWriter.PDFX1A2001:
                        PdfObject cs = image.get(PdfName.COLORSPACE);
                        if (cs == null)
                            return;
                        if (cs.isName()) {
                            if (PdfName.DEVICERGB.equals(cs))
                                throw new PdfXConformanceException("Colorspace RGB is not allowed.");
                        }
                        else if (cs.isArray()) {
                            if (PdfName.CALRGB.equals(((PdfArray)cs).getArrayList().get(0)))
                                throw new PdfXConformanceException("Colorspace CalRGB is not allowed.");
                        }
                        break;
                }
                break;
            case PDFXKEY_GSTATE:
                PdfDictionary gs = (PdfDictionary)obj1;
                PdfObject obj = gs.get(PdfName.BM);
                if (obj != null && !PdfGState.BM_NORMAL.equals(obj) && !PdfGState.BM_COMPATIBLE.equals(obj))
                    throw new PdfXConformanceException("Blend mode " + obj.toString() + " not allowed.");
                obj = gs.get(PdfName.CA);
                double v = 0.0;
                if (obj != null && (v = ((PdfNumber)obj).doubleValue()) != 1.0)
                    throw new PdfXConformanceException("Transparency is not allowed: /CA = " + v);
                obj = gs.get(PdfName.ca);
View Full Code Here

                dic.put(PdfName.GAMMA, new PdfNumber(gamma));
                dic.put(PdfName.WHITEPOINT, new PdfLiteral("[1 1 1]"));
                array.add(dic);
            }
            else {
                PdfObject wp = new PdfLiteral("[1 1 1]");
                array.add(PdfName.CALRGB);
                if (gamma != 1f) {
                    PdfArray gm = new PdfArray();
                    PdfNumber n = new PdfNumber(gamma);
                    gm.add(n);
View Full Code Here

        if (info != null) {
          DublinCoreSchema dc = new DublinCoreSchema();
          PdfSchema p = new PdfSchema();
          XmpBasicSchema basic = new XmpBasicSchema();
          PdfName key;
          PdfObject obj;
          for (Iterator it = info.getKeys().iterator(); it.hasNext();) {
            key = (PdfName)it.next();
            obj = info.get(key);
            if (obj == null)
              continue;
View Full Code Here

    public static Image getInstance(PRIndirectReference ref) throws BadElementException {
        PdfDictionary dic = (PdfDictionary)PdfReader.getPdfObjectRelease(ref);
        int width = ((PdfNumber)PdfReader.getPdfObjectRelease(dic.get(PdfName.WIDTH))).intValue();
        int height = ((PdfNumber)PdfReader.getPdfObjectRelease(dic.get(PdfName.HEIGHT))).intValue();
        Image imask = null;
        PdfObject obj = dic.get(PdfName.SMASK);
        if (obj != null && obj.isIndirect()) {
            imask = getInstance((PRIndirectReference)obj);
        }
        else {
            obj = dic.get(PdfName.MASK);
            if (obj != null && obj.isIndirect()) {
                PdfObject obj2 = PdfReader.getPdfObjectRelease(obj);
                if (obj2 instanceof PdfDictionary)
                    imask = getInstance((PRIndirectReference)obj);
            }
        }
        Image img = new ImgRaw(width, height, 1, 1, null);
View Full Code Here

     * Replaces CalRGB and CalGray colorspaces with DeviceRGB and DeviceGray.
     */   
    public void simplifyColorspace() {
        if (additional == null)
            return;
        PdfObject value = additional.get(PdfName.COLORSPACE);
        if (value == null || !value.isArray())
            return;
        PdfObject cs = simplifyColorspace(value);
        if (cs.isName())
            value = cs;
        else {
            PdfObject first = (PdfObject)(((PdfArray)value).getArrayList().get(0));
            if (PdfName.INDEXED.equals(first)) {
                ArrayList array = ((PdfArray)value).getArrayList();
                if (array.size() >= 2 && ((PdfObject)array.get(1)).isArray()) {
                     array.set(1, simplifyColorspace((PdfObject)array.get(1)));
                }
View Full Code Here

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

        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(", ");
View Full Code Here

                        PdfObject tuValue = dict.get(new PdfName("/TU"));
                        annotation = tuValue.toString();
                    }
                    */

                    PdfObject typeValue = null;
                    PdfObject tuValue = null;

                    Set<PdfName> dictKeys = UtilGenerics.checkSet(dict.getKeys());
                    Iterator<PdfName> dictKeyIter = dictKeys.iterator();
                    while (dictKeyIter.hasNext()) {
                        PdfName dictKeyName = dictKeyIter.next();
                        PdfObject dictObject = dict.get(dictKeyName);

                        if ("/Type".equals(dictKeyName.toString())) {
                            typeValue = dictObject;
                        } else if ("/TU".equals(dictKeyName.toString())) {
                            tuValue = dictObject;
View Full Code Here

                        PdfObject tuValue = dict.get(new PdfName("/TU"));
                        annotation = tuValue.toString();
                    }
                    */

                    PdfObject typeValue = null;
                    PdfObject tuValue = null;

                    Set<PdfName> dictKeys = UtilGenerics.checkSet(dict.getKeys());
                    for(PdfName dictKeyName : dictKeys) {
                        PdfObject dictObject = dict.get(dictKeyName);

                        if ("/Type".equals(dictKeyName.toString())) {
                            typeValue = dictObject;
                        } else if ("/TU".equals(dictKeyName.toString())) {
                            tuValue = dictObject;
View Full Code Here

TOP

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

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.