Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PRStream


   * @param parser  the OCGParser
   * @param page    the page dictionary of the page that needs to be parsed.
   * @throws IOException
   */
  private void parse(OCGParser parser, PdfDictionary page) throws IOException {
    PRStream stream = (PRStream)page.getAsStream(PdfName.CONTENTS);
    PdfDictionary resources = page.getAsDict(PdfName.RESOURCES);
    parser.parse(stream, resources);
  }
View Full Code Here


    public void parse(PRStream stream, PdfDictionary resources) throws IOException {
      baos = new ByteArrayOutputStream();
      properties = resources.getAsDict(PdfName.PROPERTIES);
      xobj = new HashSet<PdfName>();
      PdfDictionary xobjects = resources.getAsDict(PdfName.XOBJECT);
      PRStream xobject;
      PdfDictionary oc;
      PdfString ocname;
    if (xobjects != null) {
      // remove XObject (form or image) that belong to an OCG that needs to be removed
      for (PdfName name : xobjects.getKeys()) {
        xobject = (PRStream)xobjects.getAsStream(name);
        oc = xobject.getAsDict(PdfName.OC);
        if (oc != null) {
          ocname = oc.getAsString(PdfName.NAME);
          if (ocname != null && ocgs.contains(ocname.toString())) {
            xobj.add(name);
          }
View Full Code Here

      if (xobjects == null) {
        xobjects = new PdfDictionary();
        resources.put(PdfName.XOBJECT, xobjects);
      }
      // parsing the content stream of the page
    PRStream stream = (PRStream)page.getAsStream(PdfName.CONTENTS);
    byte[] contentBytes = PdfReader.getStreamBytes(stream);
        PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(RASFACTORY.createSource(contentBytes)));
        PdfContentParser ps = new PdfContentParser(tokeniser);
        ArrayList<PdfObject> operands = new ArrayList<PdfObject>();
        while (ps.parse(operands).size() > 0){
            PdfLiteral operator = (PdfLiteral)operands.get(operands.size() - 1);
            processOperator(operator, operands);
        }
        // dealing with orphans
        while (items.size() > 0 && items.get(0).getPageref() == pageref.getNumber()) {
          StructureItem item = items.get(0);
          if (item instanceof StructureObject) {
            convertToXObject((StructureObject)item);
            items.remove(0);
          }
        }
        if (annots.size() == 0) {
          page.remove(PdfName.ANNOTS);
        }
        else {
          PdfDictionary annot;
          for (int i = 0; i < annots.size(); i++) {
            annot = annots.getAsDict(i);
            if (annot.getAsNumber(PdfName.STRUCTPARENT) == null)
              throw new DocumentException(MessageLocalization.getComposedMessage("could.not.flatten.file.untagged.annotations.found"));
          }
        }
        // replacing the content stream
        baos.flush();
        baos.close();
        stream.setData(baos.toByteArray());
        // showing how many items are left
        LOGGER.info(String.format("There are %d items left for processing", items.size()));
    }
View Full Code Here

    public void parse(PRStream stream, PdfDictionary resources) throws IOException {
      baos = new ByteArrayOutputStream();
      properties = resources.getAsDict(PdfName.PROPERTIES);
      xobj = new HashSet<PdfName>();
      PdfDictionary xobjects = resources.getAsDict(PdfName.XOBJECT);
      PRStream xobject;
      PdfDictionary oc;
      PdfString ocname;
    if (xobjects != null) {
      // remove XObject (form or image) that belong to an OCG that needs to be removed
      for (PdfName name : xobjects.getKeys()) {
        xobject = (PRStream)xobjects.getAsStream(name);
        oc = xobject.getAsDict(PdfName.OC);
        if (oc != null) {
          ocname = oc.getAsString(PdfName.NAME);
          if (ocname != null && ocgs.contains(ocname.toString())) {
            xobj.add(name);
          }
View Full Code Here

   * @param parser  the OCGParser
   * @param page    the page dictionary of the page that needs to be parsed.
   * @throws IOException
   */
  private void parse(OCGParser parser, PdfDictionary page) throws IOException {
    PRStream stream = (PRStream)page.getAsStream(PdfName.CONTENTS);
    PdfDictionary resources = page.getAsDict(PdfName.RESOURCES);
    parser.parse(stream, resources);
  }
View Full Code Here

        final PRIndirectReference ref = (PRIndirectReference) contentObject;
        final PdfObject directObject = PdfReader.getPdfObject(ref);
        result = readContentBytes(directObject);
        break;
      case PdfObject.STREAM:
        final PRStream stream = (PRStream) PdfReader.getPdfObject(contentObject);
        result = PdfReader.getStreamBytes(stream);
        break;
      case PdfObject.ARRAY:
        // Stitch together all content before calling processContent(), because
        // processContent() resets state.
View Full Code Here

                final PRIndirectReference ref = (PRIndirectReference) contentObject;
                final PdfObject directObject = PdfReader.getPdfObject(ref);
                result = getContentBytesFromContentObject(directObject);
                break;
            case PdfObject.STREAM:
                final PRStream stream = (PRStream) PdfReader.getPdfObject(contentObject);
                result = PdfReader.getStreamBytes(stream);
                break;
            case PdfObject.ARRAY:
                // Stitch together all content before calling processContent(), because
                // processContent() resets state.
View Full Code Here

                    stride = (width * bpc * 3 + 7) / 8;
                    pngColorType = 2;
                }
            }
            else if (PdfName.ICCBASED.equals(tyca)) {
                PRStream pr = (PRStream)ca.getDirectObject(1);
                int n = pr.getAsNumber(PdfName.N).intValue();
                if (n == 1) {
                    stride = (width * bpc + 7) / 8;
                    pngColorType = 0;
                    icc = PdfReader.getStreamBytes(pr);
                }
View Full Code Here

            else if (colorspace instanceof PdfArray) {
                PdfArray ca = (PdfArray)colorspace;
                PdfObject tyca = ca.getDirectObject(0);
                if (!PdfName.ICCBASED.equals(tyca))
                    throw new UnsupportedPdfException(MessageLocalization.getComposedMessage("the.color.space.1.is.not.supported", colorspace));
                PRStream pr = (PRStream)ca.getDirectObject(1);
                int n = pr.getAsNumber(PdfName.N).intValue();
                if (n != 4) {
                    throw new UnsupportedPdfException(MessageLocalization.getComposedMessage("N.value.1.is.not.supported", n));
                }
                icc = PdfReader.getStreamBytes(pr);
            }
View Full Code Here

    private void prepareImageObject() throws IOException{
        if (imageObject != null)
            return;
       
        if (ref != null){
            PRStream stream = (PRStream)PdfReader.getPdfObject(ref);
            imageObject = new PdfImageObject(stream, colorSpaceDictionary);
        } else if (inlineImageInfo != null){
            imageObject = new PdfImageObject(inlineImageInfo.getImageDictionary(), inlineImageInfo.getSamples(), colorSpaceDictionary);
        }
    }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.PRStream

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.