Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfName


     * A content operator implementation (gs).
     */
    private static class ProcessGraphicsStateResource implements ContentOperator{
        public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {

            PdfName dictionaryName = (PdfName)operands.get(0);
            PdfDictionary extGState = processor.resources.getAsDict(PdfName.EXTGSTATE);
            if (extGState == null)
                throw new IllegalArgumentException(MessageLocalization.getComposedMessage("resources.do.not.contain.extgstate.entry.unable.to.process.operator.1", operator));
            PdfDictionary gsDic = extGState.getAsDict(dictionaryName);
            if (gsDic == null)
View Full Code Here


    private PdfDictionary getPropertiesDictionary(PdfObject operand1, ResourceDictionary resources){
            if (operand1.isDictionary())
                return (PdfDictionary)operand1;

            PdfName dictionaryName = ((PdfName)operand1);
            return resources.getAsDict(dictionaryName);
    }
View Full Code Here

    /**
     * A content operator implementation (Do).
     */
    private static class Do implements ContentOperator{
        public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) throws IOException {
            PdfName xobjectName = (PdfName)operands.get(0);
            processor.displayXObject(xobjectName);
        }
View Full Code Here

        PdfDictionary dictionary = new PdfDictionary();
       
        for(PdfObject key = ps.readPRObject(); key != null && !"ID".equals(key.toString()); key = ps.readPRObject()){
            PdfObject value = ps.readPRObject();

            PdfName resolvedKey = inlineImageEntryAbbreviationMap.get(key);
            if (resolvedKey == null)
                resolvedKey = (PdfName)key;

            dictionary.put(resolvedKey, getAlternateValue(resolvedKey, value));
        }
View Full Code Here

     * @return if value is an allowed abbreviation for the key, the expanded value for that abbreviation.  Otherwise, value is returned without modification
     */
    private static PdfObject getAlternateValue(PdfName key, PdfObject value){
        if (key == PdfName.FILTER){
            if (value instanceof PdfName){
                PdfName altValue = inlineImageFilterAbbreviationMap.get(value);
                if (altValue != null)
                    return altValue;
            } else if (value instanceof PdfArray){
                PdfArray array = ((PdfArray)value);
                PdfArray altArray = new PdfArray();
                int count = array.size();
                for(int i = 0; i < count; i++){
                    altArray.add(getAlternateValue(key, array.getPdfObject(i)));
                }
                return altArray;
            }
        } else if (key == PdfName.COLORSPACE){
            PdfName altValue = inlineImageColorSpaceAbbreviationMap.get(value);
            if (altValue != null)
                return altValue;
        }
       
        return value;
View Full Code Here

                if (PdfName.INDEXED.equals(colorSpace.getAsName(0))){
                    return 1;
                }
            }
            else {
              PdfName tempName = colorSpaceDic.getAsName(colorSpaceName);
              if (tempName != null) {
                return getComponentsPerPixel(tempName, colorSpaceDic);
              }
            }
        }
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

    LOGGER.info("Using MCID " + mcid);
      structElem.put(PdfName.K, new PdfNumber(mcid));
      // removing the annotation from the parent tree
      items.removeFromParentTree(structParent);
      // Adding the XObject to the page
      PdfName xobj = new PdfName("XObj" + structParent.intValue());
      LOGGER.info("Creating XObject with name " + xobj);
      xobjects.put(xobj, xobjr);
      PdfArray array = dict.getAsArray(PdfName.RECT);
      // Getting the position of the annotation
      Rectangle rect = new Rectangle(
          array.getAsNumber(0).floatValue(), array.getAsNumber(1).floatValue(),
          array.getAsNumber(2).floatValue(), array.getAsNumber(3).floatValue());
      rect.normalize();
      // A Do operator is forbidden inside a text block
      if (inText && !btWrite) {
        LOGGER.debug("Introducing extra ET");
        baos.write("ET\n".getBytes());
        etExtra = true;
      }
      // Writing the marked-content sequence with the Do operator
      // Note that the position assumes that the CTM wasn't changed in the graphics state
      // TODO: do the math if the CTM did change!
      ByteBuffer buf = new ByteBuffer();
      buf.append("/P <</MCID ");
      buf.append(mcid);
      buf.append(">> BDC\n");
      buf.append("q 1 0 0 1 ");
      buf.append(rect.getLeft());
      buf.append(" ");
      buf.append(rect.getBottom());
      buf.append(" cm ");
      buf.append(xobj.getBytes());
      buf.append(" Do Q\n");
      buf.append("EMC\n");
      buf.flush();
      buf.writeTo(baos);
      // if we were inside a text block, we've introduced an ET, so we'll need to write a BT
View Full Code Here

   * be specified.
   *
   * @param scaleratio
   */
  public void setScaleRatio(PdfString scaleratio) {
    put(new PdfName("R"), scaleratio);
  }
View Full Code Here

   * determined by the BBox of the containing {@link Viewport}
   *
   * @param x
   */
  public void setX(NumberFormatArray x) {
    put(new PdfName("X"), x);
  }
View Full Code Here

TOP

Related Classes of com.itextpdf.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.