Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfDictionary


      PdfArray group = new PdfArray();
      group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE));
      group.add(l2.getRef());
      group.add(l3.getRef());
      order.add(group);
      PdfDictionary d = new PdfDictionary();
      d.put(PdfName.ORDER, order);
      p.put(PdfName.D, d);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here


      PdfOCProperties p = writer.getOCProperties();
      PdfArray order = new PdfArray();
      order.add(l1.getRef());
      order.add(l2.getRef());
      order.add(l3.getRef());
      PdfDictionary d = new PdfDictionary();
      d.put(PdfName.ORDER, order);
      p.put(PdfName.D, d);
      // step 5
      document.close();
    } catch (Exception de) {
      de.printStackTrace();
View Full Code Here

   * @see com.lowagie.text.pdf.interfaces.PdfVersion#addDeveloperExtension(com.lowagie.text.pdf.PdfDeveloperExtension)
   * @since  2.1.6
   */
  public void addDeveloperExtension(PdfDeveloperExtension de) {
    if (extensions == null) {
      extensions = new PdfDictionary();
    }
    else {
      PdfDictionary extension = extensions.getAsDict(de.getPrefix());
      if (extension != null) {
        int diff = de.getBaseversion().compareTo(extension.getAsName(PdfName.BASEVERSION));
        if (diff < 0)
          return;
        diff = de.getExtensionLevel() - extension.getAsNumber(PdfName.EXTENSIONLEVEL).intValue();
        if (diff <= 0)
          return;
      }
    }
    extensions.put(de.getPrefix(), de.getDeveloperExtensions());
View Full Code Here

    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);
      }
    }
    return preferences;
  }
View Full Code Here

    }
   
    public void completeExtraCatalog(PdfDictionary extraCatalog) {
        if (isPdfX() && !isPdfA1()) {
            if (extraCatalog.get(PdfName.OUTPUTINTENTS) == null) {
                PdfDictionary out = new PdfDictionary(PdfName.OUTPUTINTENT);
                out.put(PdfName.OUTPUTCONDITION, new PdfString("SWOP CGATS TR 001-1995"));
                out.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("CGATS TR 001"));
                out.put(PdfName.REGISTRYNAME, new PdfString("http://www.color.org"));
                out.put(PdfName.INFO, new PdfString(""));
                out.put(PdfName.S, PdfName.GTS_PDFX);
                extraCatalog.put(PdfName.OUTPUTINTENTS, new PdfArray(out));
            }
        }
    }
View Full Code Here

                        }
                        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(MessageLocalization.getComposedMessage("blend.mode.1.not.allowed", obj.toString()));
                obj = gs.get(PdfName.CA);
                double v = 0.0;
                if (obj != null && (v = ((PdfNumber)obj).doubleValue()) != 1.0)
                    throw new PdfXConformanceException(MessageLocalization.getComposedMessage("transparency.is.not.allowed.ca.eq.1", String.valueOf(v)));
                obj = gs.get(PdfName.ca);
                v = 0.0;
                if (obj != null && (v = ((PdfNumber)obj).doubleValue()) != 1.0)
                    throw new PdfXConformanceException(MessageLocalization.getComposedMessage("transparency.is.not.allowed.ca.eq.1", String.valueOf(v)));
                break;
            case PDFXKEY_LAYER:
View Full Code Here

                // TODO: need to find something better to put into these fields...
                String annotation = null;
                Iterator widgetIter = item.widgets.iterator();
                while (widgetIter.hasNext()) {
                    PdfDictionary dict = (PdfDictionary) widgetIter.next();

                    // if the "/Type" value is "/Annot", then get the value of "/TU" for the annotation

                    /* Interesting... this doesn't work, I guess we have to iterate to find the stuff...
                    PdfObject typeValue = dict.get(new PdfName("/Type"));
                    if (typeValue != null && "/Annot".equals(typeValue.toString())) {
                        PdfObject tuValue = dict.get(new PdfName("/TU"));
                        annotation = tuValue.toString();
                    }
                    */

                    PdfObject typeValue = null;
                    PdfObject tuValue = null;

                    Set dictKeys = dict.getKeys();
                    Iterator dictKeyIter = dictKeys.iterator();
                    while (dictKeyIter.hasNext()) {
                        PdfName dictKeyName = (PdfName) 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

      }

      byte[] paddedSig = new byte[contentEstimated];
      System.arraycopy(encodedSig, 0, paddedSig, 0, encodedSig.length);

      PdfDictionary dic2 = new PdfDictionary();
      dic2.put(PdfName.CONTENTS, new PdfString(paddedSig).setHexWriting(true));
      options.log("console.closeStream");
      sap.close(dic2);
      fout.close();

    } catch (Exception e) {
View Full Code Here

          try{
            pdfReader = new PdfReader(new RandomAccessFileOrArray(fileList[i].getFile().getAbsolutePath()),fileList[i].getPasswordBytes());
            pdfReader.removeUnusedObjects();
            pdfReader.consolidateNamedDestinations();
           
            PdfDictionary catalog = pdfReader.getCatalog();
            PdfDictionary names = (PdfDictionary) PdfReader.getPdfObject(catalog.get(PdfName.NAMES));
            if (names != null) {
              PdfDictionary embFiles = (PdfDictionary) PdfReader.getPdfObject(names.get(new PdfName("EmbeddedFiles")));
              if (embFiles != null) {
                HashMap embMap = PdfNameTree.readTree(embFiles);
                for (Iterator iter = embMap.values().iterator(); iter.hasNext();) {
                  PdfDictionary filespec = (PdfDictionary) PdfReader.getPdfObject((PdfObject) iter.next());
                  unpackedFiles += unpackFile(filespec, inputCommand.getOutputFile(), inputCommand.isOverwrite());
                }
              }
            }
            for (int k = 1; k <= pdfReader.getNumberOfPages(); ++k) {
              PdfArray annots = (PdfArray) PdfReader.getPdfObject(pdfReader.getPageN(k).get(PdfName.ANNOTS));
              if (annots != null){
                for (Iterator iter = annots.listIterator(); iter.hasNext();) {
                  PdfDictionary annot = (PdfDictionary) PdfReader.getPdfObject((PdfObject) iter.next());
                  PdfName subType = (PdfName) PdfReader.getPdfObject(annot.get(PdfName.SUBTYPE));
                  if (PdfName.FILEATTACHMENT.equals(subType)){
                    PdfDictionary filespec = (PdfDictionary) PdfReader.getPdfObject(annot.get(PdfName.FS));
                    unpackedFiles += unpackFile(filespec, inputCommand.getOutputFile(), inputCommand.isOverwrite());
                  }
                }
              }
            }
View Full Code Here

  private int unpackFile(PdfDictionary filespec, File outPath, boolean overwrite) throws IOException {
    int retVal = 0;
    if (filespec != null){
      PdfName type = (PdfName) PdfReader.getPdfObject(filespec.get(PdfName.TYPE));
      if (PdfName.F.equals(type) || PdfName.FILESPEC.equals(type)){
        PdfDictionary ef = (PdfDictionary) PdfReader.getPdfObject(filespec.get(PdfName.EF));
        PdfString fn = (PdfString) PdfReader.getPdfObject(filespec.get(PdfName.F));
        if (fn != null && ef != null){
          LOG.debug("Unpacking file " + fn + " to " + outPath);
          File fLast = new File(fn.toUnicodeString());
          File fullPath = new File(outPath, fLast.getName());
          if (fullPath.exists()){
                  //check if overwrite is allowed
                  if (overwrite){
                      if(!fullPath.delete()){
                   LOG.warn("Unable to overwrite "+fullPath.getAbsolutePath()+", unable to unpack.");
                      }
                  }else{
                    LOG.warn("Cannot overwrite "+fullPath.getAbsolutePath()+" (overwrite is false), unable to unpack.");
                  }   
            }       
          else{
            PRStream prs = (PRStream) PdfReader.getPdfObject(ef.get(PdfName.F));
            if (prs != null){
              byte b[] = PdfReader.getStreamBytes(prs);
              FileOutputStream fout = new FileOutputStream(fullPath);
              fout.write(b);
              fout.close();
View Full Code Here

TOP

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

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.