protected static Object[] splitDAelements(String da) { PdfTokenizer tk = new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(PdfEncodings.convertToBytes(da, null)))); List<String> stack = new ArrayList<>(); Object[] ret = new Object[3];
/** * Utility method that checks the provided byte source to see if it has junk bytes at the beginning. If junk bytes * are found, construct a tokeniser that ignores the junk. Otherwise, construct a tokeniser for the byte source as it is * * @param byteSource the source to check * @return a tokeniser that is guaranteed to start at the PDF header * @throws IOException if there is a problem reading the byte source */ private static PdfTokenizer getOffsetTokeniser(IRandomAccessSource byteSource) throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(byteSource)); int offset = tok.getHeaderOffset(); if (offset != 0) { IRandomAccessSource offsetSource = new WindowRandomAccessSource(byteSource, offset); tok = new PdfTokenizer(new RandomAccessFileOrArray(offsetSource)); } return tok; }
protected static Object[] splitDAelements(String da) { PdfTokenizer tk = new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(PdfEncodings.convertToBytes(da, null)))); List<String> stack = new ArrayList<>(); Object[] ret = new Object[3];
/** * Processes PDF syntax. * <b>Note:</b> If you re-use a given {@link PdfCanvasProcessor}, you must call {@link PdfCanvasProcessor#reset()} * * @param contentBytes the bytes of a content stream * @param resources the resources of the content stream. Must not be null. */ public void processContent(byte[] contentBytes, PdfResources resources) { if (resources == null) { throw new PdfException(PdfException.ResourcesCannotBeNull); } this.resourcesStack.push(resources); PdfTokenizer tokeniser = new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(contentBytes))); PdfCanvasParser ps = new PdfCanvasParser(tokeniser, resources); List<PdfObject> operands = new ArrayList<>(); try { while (ps.parse(operands).size() > 0) { PdfLiteral operator = (PdfLiteral) operands.get(operands.size() - 1); invokeOperator(operator, operands); } } catch (IOException e) { throw new PdfException(PdfException.CannotParseContentStream, e); } this.resourcesStack.pop(); }
byte[] bytesToParse = s.getBytes(); RandomAccessSourceFactory factory = new RandomAccessSourceFactory(); PdfTokenizer tokenizer = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(bytesToParse))); UnderlineParser parser = new UnderlineParser(tokenizer); PdfObject result;
public PdfTokenizer getLocation(String location) throws java.io.IOException { return new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(data))); } }
public PdfTokenizer getLocation(String location) throws java.io.IOException { return new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(data))); } }
@Override public PdfTokenizer getLocation(String location) throws java.io.IOException { String fullName = FontResources.CMAPS + location; InputStream inp = ResourceUtil.getResourceStream(fullName); if (inp == null) { throw new IOException(IOException.Cmap1WasNotFound).setMessageParams(fullName); } return new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(inp))); } }
@Override public PdfTokenizer getLocation(String location) throws java.io.IOException { String fullName = FontResources.CMAPS + location; InputStream inp = ResourceUtil.getResourceStream(fullName); if (inp == null) { throw new IOException(IOException.Cmap1WasNotFound).setMessageParams(fullName); } return new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(inp))); } }
bb = stream.getBytes(); PdfTokenizer tokeniser = new PdfTokenizer(new RandomAccessFileOrArray(RASF.createSource(bb)));
protected void fixXref() throws IOException { fixedXref = true; PdfXrefTable xref = pdfDocument.getXref(); tokens.seek(0); ByteBuffer buffer = new ByteBuffer(24); PdfTokenizer lineTokeniser = new PdfTokenizer(new RandomAccessFileOrArray(new ReusableRandomAccessSource(buffer))); for (; ; ) { long pos = tokens.getPosition(); buffer.reset(); if (!tokens.readLineSegment(buffer, true)) // added boolean because of mailing list issue (17 Feb. 2014) break; if (buffer.get(0) >= '0' && buffer.get(0) <= '9') { int[] obj = PdfTokenizer.checkObjectStart(lineTokeniser); if (obj == null) continue; int num = obj[0]; int gen = obj[1]; PdfIndirectReference reference = xref.get(num); if (reference != null && reference.getGenNumber() == gen) { reference.fixOffset(pos); } } } }
trailer = null; ByteBuffer buffer = new ByteBuffer(24); PdfTokenizer lineTokeniser = new PdfTokenizer(new RandomAccessFileOrArray(new ReusableRandomAccessSource(buffer))); for (; ; ) { long pos = tokens.getPosition();
PdfTokenizer saveTokens = tokens; try { tokens = new PdfTokenizer(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(bytes))); int[] address = new int[n]; int[] objNumber = new int[n];