Examples of RandomAccessFileOrArray


Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

   * @throws DocumentException
   */
  public PdfFile(File file) throws IOException, DocumentException {
    if (file == null)
      throw new IOException("No file selected.");
    RandomAccessFileOrArray pdf = new RandomAccessFileOrArray(file.getAbsolutePath());
    directory = file.getParentFile();
    filename = file.getName();
    readFile(pdf);
  }
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

   * @param  file  the byte[] to read
   * @throws IOException
   * @throws DocumentException
   */
  public PdfFile(byte[] file) throws IOException, DocumentException {
    RandomAccessFileOrArray pdf = new RandomAccessFileOrArray(file);
    readFile(pdf);
  }
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

        out.println("- - - - - XObject Summary - - - - - -");
        out.println(getXObjectDetail(pageDictionary.getAsDict(PdfName.RESOURCES)));
       
        out.println("- - - - - Content Stream - - - - - -");
        RandomAccessFileOrArray f = reader.getSafeFile();

        byte[] contentBytes = reader.getPageContent(pageNum, f);
        f.close();

        out.flush();

        InputStream is = new ByteArrayInputStream(contentBytes);
        int ch;
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

      if (c1 == 'B' && c2 == 'M') {
        return  BmpImage.getImage(url);
      }
      if (c1 == 'M' && c2 == 'M' && c3 == 0 && c4 == 42
          || c1 == 'I' && c2 == 'I' && c3 == 42 && c4 == 0) {
        RandomAccessFileOrArray ra = null;
        try {
          if (url.getProtocol().equals("file")) {
            String file = url.getFile();
                        file = Utilities.unEscapeURL(file);
            ra = new RandomAccessFileOrArray(randomAccessSourceFactory.createBestSource(file));
          } else
            ra = new RandomAccessFileOrArray(randomAccessSourceFactory.createSource(url));
          Image img = TiffImage.getTiffImage(ra, 1);
          img.url = url;
          return img;
        } catch (RuntimeException e ) {
                    if ( recoverFromImageError ) {
                        // reruns the getTiffImage() with several error recovering workarounds in place
                        // not guaranteed to work with every TIFF
                        Image img = TiffImage.getTiffImage(ra, recoverFromImageError, 1);
                        img.url = url;
                        return img;
                    }
                    throw e;
                } finally {
          if (ra != null)
            ra.close();
        }

      }
      if ( c1 == 0x97 && c2 == 'J' && c3 == 'B' && c4 == '2' &&
          c5 == '\r' && c6 == '\n' && c7 == 0x1a && c8 == '\n' ) {
        RandomAccessFileOrArray ra = null;
        try {
          if (url.getProtocol().equals("file")) {
            String file = url.getFile();
            file = Utilities.unEscapeURL(file);
                  ra = new RandomAccessFileOrArray(randomAccessSourceFactory.createBestSource(file));
          } else
            ra = new RandomAccessFileOrArray(randomAccessSourceFactory.createSource(url));
          Image img = JBIG2Image.getJbig2Image(ra, 1);
          img.url = url;
          return img;
        } finally {
            if (ra != null)
              ra.close();
        }
      }
      throw new IOException(MessageLocalization.getComposedMessage("unknown.image.format", url.toString()));
    } finally {
      if (is != null) {
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

      if (c1 == 'B' && c2 == 'M') {
        return BmpImage.getImage(imgb);
      }
      if (c1 == 'M' && c2 == 'M' && c3 == 0 && c4 == 42
          || c1 == 'I' && c2 == 'I' && c3 == 42 && c4 == 0) {
        RandomAccessFileOrArray ra = null;
        try {
          ra = new RandomAccessFileOrArray(randomAccessSourceFactory.createSource(imgb));
          Image img = TiffImage.getTiffImage(ra, 1);
                    if (img.getOriginalData() == null)
                        img.setOriginalData(imgb);
          return img;
        } catch ( RuntimeException e ) {
                    if ( recoverFromImageError ) {
                        // reruns the getTiffImage() with several error recovering workarounds in place
                        // not guaranteed to work with every TIFF
                        Image img = TiffImage.getTiffImage(ra, recoverFromImageError, 1);
                        if (img.getOriginalData() == null)
                            img.setOriginalData(imgb);
                        return img;
                    }
                    throw e;
                } finally {
          if (ra != null)
            ra.close();
        }

      }
      if ( c1 == 0x97 && c2 == 'J' && c3 == 'B' && c4 == '2' ) {
        is = new java.io.ByteArrayInputStream(imgb);
        is.skip(4);
        int c5 = is.read();
        int c6 = is.read();
        int c7 = is.read();
        int c8 = is.read();
                is.close();
        if ( c5 == '\r' && c6 == '\n' && c7 == 0x1a && c8 == '\n' ) {
          // a jbig2 file with a file header.  the header is the only way we know here.
          // embedded jbig2s don't have a header, have to create them by explicit use of Jbig2Image?
          // nkerr, 2008-12-05  see also the getInstance(URL)
          RandomAccessFileOrArray ra = null;
          try {
            ra = new RandomAccessFileOrArray(randomAccessSourceFactory.createSource(imgb));
            Image img = JBIG2Image.getJbig2Image(ra, 1);
            if (img.getOriginalData() == null)
              img.setOriginalData(imgb);
            return img;
          } finally {
            if (ra != null)
              ra.close();
          }
        }
      }
      throw new IOException(MessageLocalization.getComposedMessage("the.byte.array.is.not.a.recognized.imageformat"));
    } finally {
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

     * @param resources    the resources that come with the content stream
     */
    public void processContent(byte[] contentBytes, PdfDictionary resources){
        this.resources.push(resources);
        try {
            PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().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);
                if ("BI".equals(operator.toString())){
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

        out.println("- - - - - XObject Summary - - - - - -");
        out.println(getXObjectDetail(pageDictionary.getAsDict(PdfName.RESOURCES)));
       
        out.println("- - - - - Content Stream - - - - - -");
        RandomAccessFileOrArray f = reader.getSafeFile();

        byte[] contentBytes = reader.getPageContent(pageNum, f);
        f.close();

        out.flush();

        InputStream is = new ByteArrayInputStream(contentBytes);
        int ch;
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

 
  private List<String> supportedLanguages;

  public OpenTypeFontTableReader(String fontFilePath, int tableLocation)
      throws IOException {
    this.rf = new RandomAccessFileOrArray(
        new RandomAccessSourceFactory().createBestSource(fontFilePath));
    this.tableLocation = tableLocation;
  }
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

    public CidLocationFromByte(byte[] data) {
        this.data = data;
    }
   
    public PRTokeniser getLocation(String location) throws IOException {
        return new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(data)));
    }
View Full Code Here

Examples of com.itextpdf.text.pdf.RandomAccessFileOrArray

    public PRTokeniser getLocation(String location) throws IOException {
        String fullName = BaseFont.RESOURCE_PATH + "cmaps/" + location;
        InputStream inp = StreamUtil.getResourceStream(fullName);
        if (inp == null)
            throw new IOException(MessageLocalization.getComposedMessage("the.cmap.1.was.not.found", fullName));
        return new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(inp)));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.