Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfDictionary


      throws IOException {
    this.reader = reader;
        OutputStreamWriter outs = new OutputStreamWriter(os, charset);
    out = new PrintWriter(outs);
    // get the StructTreeRoot from the root object
    PdfDictionary catalog = reader.getCatalog();
    PdfDictionary struct = catalog.getAsDict(PdfName.STRUCTTREEROOT);
    if (struct == null)
      throw new IOException(MessageLocalization.getComposedMessage("no.structtreeroot.found"));
    // Inspect the child or children of the StructTreeRoot
    inspectChild(struct.getDirectObject(PdfName.K));
    out.flush();
    out.close();
  }
View Full Code Here


            String tagN = PdfName.decodeName(s.toString());
      String tag = fixTagName(tagN);
      out.print("<");
      out.print(tag);
      out.print(">");
      PdfDictionary dict = k.getAsDict(PdfName.PG);
      if (dict != null)
        parseTag(tagN, k.getDirectObject(PdfName.K), dict);
      inspectChild(k.getDirectObject(PdfName.K));
      out.print("</");
      out.print(tag);
View Full Code Here

      }
    }
    // if the identifier is a dictionary, we get the resources from the
    // dictionary
    else if (object instanceof PdfDictionary) {
      PdfDictionary mcr = (PdfDictionary) object;
      parseTag(tag, mcr.getDirectObject(PdfName.MCID), mcr
          .getAsDict(PdfName.PG));
    }
  }
View Full Code Here

    /**
     * Displays an XObject using the registered handler for this XObject's subtype
     * @param xobjectName the name of the XObject to retrieve from the resource dictionary
     */
    private void displayXObject(PdfName xobjectName) throws IOException {
        PdfDictionary xobjects = resources.getAsDict(PdfName.XOBJECT);
        PdfObject xobject = xobjects.getDirectObject(xobjectName);
        PdfStream xobjectStream = (PdfStream)xobject;

        PdfName subType = xobjectStream.getAsName(PdfName.SUBTYPE);
        if (xobject.isStream()){
            XObjectDoHandler handler = xobjectDoHandlers.get(subType);
            if (handler == null)
                handler = xobjectDoHandlers.get(PdfName.DEFAULT);
            handler.handleXObject(this, xobjectStream, xobjects.getAsIndirectObject(xobjectName));
        } else {
            throw new IllegalStateException(MessageLocalization.getComposedMessage("XObject.1.is.not.a.stream", xobjectName));
        }

    }
View Full Code Here

            ArrayList<PdfObject> operands = new ArrayList<PdfObject>();
            while (ps.parse(operands).size() > 0){
                PdfLiteral operator = (PdfLiteral)operands.get(operands.size()-1);
                if ("BI".equals(operator.toString())){
                    // we don't call invokeOperator for embedded images - this is one area of the PDF spec that is particularly nasty and inconsistent
                    PdfDictionary colorSpaceDic = resources.getAsDict(PdfName.COLORSPACE);
                    ImageRenderInfo renderInfo = ImageRenderInfo.createdForEmbeddedImage(gs().ctm, InlineImageUtils.parseInlineImage(ps, colorSpaceDic));
                    renderListener.renderImage(renderInfo);
                } else {
                    invokeOperator(operator, operands);
                }
View Full Code Here

        }

        @Override
        public PdfObject getDirectObject(PdfName key) {
            for (int i = resourcesStack.size() - 1; i >= 0; i--){
                PdfDictionary subResource = resourcesStack.get(i);
                if (subResource != null){
                    PdfObject obj =  subResource.getDirectObject(key);
                    if (obj != null) return obj;
                }
            }
            return super.getDirectObject(key); // shouldn't be necessary, but just in case we've done something crazy
        }
View Full Code Here

    private static class SetTextFont implements ContentOperator{
        public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
            PdfName fontResourceName = (PdfName)operands.get(0);
            float size = ((PdfNumber)operands.get(1)).floatValue();

            PdfDictionary fontsDictionary = processor.resources.getAsDict(PdfName.FONT);
            CMapAwareDocumentFont font = processor.getFont((PRIndirectReference)fontsDictionary.get(fontResourceName));

            processor.gs().font = font;
            processor.gs().fontSize = size;

        }
View Full Code Here

     */
    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)
                throw new IllegalArgumentException(MessageLocalization.getComposedMessage("1.is.an.unknown.graphics.state.dictionary", dictionaryName));

            // at this point, all we care about is the FONT entry in the GS dictionary
            PdfArray fontParameter = gsDic.getAsArray(PdfName.FONT);
            if (fontParameter != null){
                CMapAwareDocumentFont font = processor.getFont((PRIndirectReference)fontParameter.getPdfObject(0));
                float size = fontParameter.getAsNumber(1).floatValue();

                processor.gs().font = font;
View Full Code Here

    private static class BeginMarkedContent implements ContentOperator{

    public void invoke(PdfContentStreamProcessor processor,
        PdfLiteral operator, ArrayList<PdfObject> operands)
        throws Exception {
      processor.beginMarkedContent((PdfName)operands.get(0), new PdfDictionary());
    }
View Full Code Here

     */
    private static class FormXObjectDoHandler implements XObjectDoHandler{

        public void handleXObject(PdfContentStreamProcessor processor, PdfStream stream, PdfIndirectReference ref) {

            final PdfDictionary resources = stream.getAsDict(PdfName.RESOURCES);

            // we read the content bytes up here so if it fails we don't leave the graphics state stack corrupted
            // this is probably not necessary (if we fail on this, probably the entire content stream processing
            // operation should be rejected
            byte[] contentBytes;
View Full Code Here

TOP

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