PdfImportedLink(PdfDictionary annotation) { parameters.putAll(annotation.hashMap); try { destination = (PdfArray) parameters.remove(PdfName.DEST); } catch (ClassCastException ex) { throw new IllegalArgumentException("You have to consolidate the named destinations of your reader."); } if (destination != null) { destination = new PdfArray(destination); } PdfArray rc = (PdfArray) parameters.remove(PdfName.RECT); llx = rc.getAsNumber(0).floatValue(); lly = rc.getAsNumber(1).floatValue(); urx = rc.getAsNumber(2).floatValue(); ury = rc.getAsNumber(3).floatValue(); }
PdfImportedLink(PdfDictionary annotation) { parameters.putAll(annotation.hashMap); try { destination = (PdfArray) parameters.remove(PdfName.DEST); } catch (ClassCastException ex) { throw new IllegalArgumentException(MessageLocalization.getComposedMessage("you.have.to.consolidate.the.named.destinations.of.your.reader")); } if (destination != null) { destination = new PdfArray(destination); } PdfArray rc = (PdfArray) parameters.remove(PdfName.RECT); llx = rc.getAsNumber(0).floatValue(); lly = rc.getAsNumber(1).floatValue(); urx = rc.getAsNumber(2).floatValue(); ury = rc.getAsNumber(3).floatValue(); }
PdfImportedLink(PdfDictionary annotation) { parameters.putAll(annotation.hashMap); try { destination = (PdfArray) parameters.remove(PdfName.DEST); } catch (ClassCastException ex) { throw new IllegalArgumentException( MessageLocalization.getComposedMessage("you.have.to.consolidate.the.named.destinations.of.your.reader")); } if (destination != null) { destination = new PdfArray(destination); } PdfArray rc = (PdfArray) parameters.remove(PdfName.RECT); llx = rc.getAsNumber(0).floatValue(); lly = rc.getAsNumber(1).floatValue(); urx = rc.getAsNumber(2).floatValue(); ury = rc.getAsNumber(3).floatValue(); }
Color getMKColor(PdfArray ar) { if (ar == null) return null; switch (ar.size()) { case 1: return new GrayColor(ar.getAsNumber(0).floatValue()); case 3: return new Color(ExtendedColor.normalize(ar.getAsNumber(0).floatValue()), ExtendedColor.normalize(ar.getAsNumber(1).floatValue()), ExtendedColor.normalize(ar.getAsNumber(2).floatValue())); case 4: return new CMYKColor(ar.getAsNumber(0).floatValue(), ar.getAsNumber(1).floatValue(), ar.getAsNumber(2).floatValue(), ar.getAsNumber(3).floatValue()); default: return null; } }
Color getMKColor(PdfArray ar) { if (ar == null) return null; switch (ar.size()) { case 1: return new GrayColor(ar.getAsNumber(0).floatValue()); case 3: return new Color(ExtendedColor.normalize(ar.getAsNumber(0).floatValue()), ExtendedColor.normalize(ar.getAsNumber(1).floatValue()), ExtendedColor.normalize(ar.getAsNumber(2).floatValue())); case 4: return new CMYKColor(ar.getAsNumber(0).floatValue(), ar.getAsNumber(1).floatValue(), ar.getAsNumber(2).floatValue(), ar.getAsNumber(3).floatValue()); default: return null; } }
Color getMKColor(PdfArray ar) { if (ar == null) { return null; } switch (ar.size()) { case 1: return new GrayColor(ar.getAsNumber(0).floatValue()); case 3: return new Color(ExtendedColor.normalize(ar.getAsNumber(0).floatValue()), ExtendedColor.normalize(ar.getAsNumber(1).floatValue()), ExtendedColor.normalize(ar.getAsNumber(2).floatValue())); case 4: return new CMYKColor(ar.getAsNumber(0).floatValue(), ar.getAsNumber(1).floatValue(), ar.getAsNumber(2).floatValue(), ar.getAsNumber(3).floatValue()); default: return null; } }
if (rangeSize < 2) continue; int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue(); sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
if (rangeSize < 2) continue; int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue(); sorter.add(new Object[]{entry.getKey(), new int[]{length, 0}});
public void transformDestination(float a, float b, float c, float d, float e, float f) { if (!isInternal()) throw new IllegalArgumentException("Cannot change destination of external link"); if (destination.getAsName(1).equals(PdfName.XYZ)) { float x = destination.getAsNumber(2).floatValue(); float y = destination.getAsNumber(3).floatValue(); float xx = x * a + y * c + e; float yy = x * b + y * d + f; destination.set(2, new PdfNumber(xx)); destination.set(3, new PdfNumber(yy)); } }
public void transformDestination(float a, float b, float c, float d, float e, float f) { if (!isInternal()) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("cannot.change.destination.of.external.link")); if (destination.getAsName(1).equals(PdfName.XYZ)) { float x = destination.getAsNumber(2).floatValue(); float y = destination.getAsNumber(3).floatValue(); float xx = x * a + y * c + e; float yy = x * b + y * d + f; destination.set(2, new PdfNumber(xx)); destination.set(3, new PdfNumber(yy)); } }
public void transformDestination(float a, float b, float c, float d, float e, float f) { if (!isInternal()) { throw new IllegalArgumentException(MessageLocalization.getComposedMessage("cannot.change.destination.of.external.link")); } if (destination.getAsName(1).equals(PdfName.XYZ)) { float x = destination.getAsNumber(2).floatValue(); float y = destination.getAsNumber(3).floatValue(); float xx = x * a + y * c + e; float yy = x * b + y * d + f; destination.set(2, new PdfNumber(xx)); destination.set(3, new PdfNumber(yy)); } }
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList 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 = new CMapAwareDocumentFont((PRIndirectReference)fontParameter.getPdfObject(0)); float size = fontParameter.getAsNumber(1).floatValue(); processor.gs().font = font; processor.gs().fontSize = size; } } }
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList operands) { PdfName dictionaryName = (PdfName)operands.get(0); PdfDictionary extGState = processor.resources.getAsDict(PdfName.EXTGSTATE); if (extGState == null) throw new IllegalArgumentException("Resources do not contain ExtGState entry. Unable to process operator " + operator); PdfDictionary gsDic = extGState.getAsDict(dictionaryName); if (gsDic == null) throw new IllegalArgumentException(dictionaryName + " is an unknown graphics state dictionary"); // 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 = new CMapAwareDocumentFont((PRIndirectReference)fontParameter.getPdfObject(0)); float size = fontParameter.getAsNumber(1).floatValue(); processor.gs().font = font; processor.gs().fontSize = size; } } }
PdfArray bbox = fontDesc.getAsArray(PdfName.FONTBBOX); if (bbox != null) { llx = bbox.getAsNumber(0).floatValue(); lly = bbox.getAsNumber(1).floatValue(); urx = bbox.getAsNumber(2).floatValue(); ury = bbox.getAsNumber(3).floatValue(); if (llx > urx) { float t = llx;
PdfArray bbox = fontDesc.getAsArray(PdfName.FONTBBOX); if (bbox != null) { llx = bbox.getAsNumber(0).floatValue(); lly = bbox.getAsNumber(1).floatValue(); urx = bbox.getAsNumber(2).floatValue(); ury = bbox.getAsNumber(3).floatValue(); if (llx > urx) { float t = llx;
llx = bbox.getAsNumber(0).floatValue(); lly = bbox.getAsNumber(1).floatValue(); urx = bbox.getAsNumber(2).floatValue(); ury = bbox.getAsNumber(3).floatValue(); if (llx > urx) { float t = llx;
private void updateByteRange(PdfPKCS7 pkcs7, PdfDictionary v) { PdfArray b = v.getAsArray(PdfName.BYTERANGE); RandomAccessFileOrArray rf = reader.getSafeFile(); try { rf.reOpen(); byte buf[] = new byte[8192]; for (int k = 0; k < b.size(); ++k) { int start = b.getAsNumber(k).intValue(); int length = b.getAsNumber(++k).intValue(); rf.seek(start); while (length > 0) { int rd = rf.read(buf, 0, Math.min(length, buf.length)); if (rd <= 0) break; length -= rd; pkcs7.update(buf, 0, rd); } } } catch (Exception e) { throw new ExceptionConverter(e); } finally { try{rf.close();}catch(Exception e){} } }
private void updateByteRange(PdfPKCS7 pkcs7, PdfDictionary v) { PdfArray b = v.getAsArray(PdfName.BYTERANGE); RandomAccessFileOrArray rf = reader.getSafeFile(); try { rf.reOpen(); byte[] buf = new byte[8192]; for (int k = 0; k < b.size(); ++k) { int start = b.getAsNumber(k).intValue(); int length = b.getAsNumber(++k).intValue(); rf.seek(start); while (length > 0) { int rd = rf.read(buf, 0, Math.min(length, buf.length)); if (rd <= 0) { break; } length -= rd; pkcs7.update(buf, 0, rd); } } } catch (Exception e) { throw new ExceptionConverter(e); } finally { try { rf.close(); } catch (Exception e) { } } }
private void updateByteRange(PdfPKCS7 pkcs7, PdfDictionary v) { PdfArray b = v.getAsArray(PdfName.BYTERANGE); RandomAccessFileOrArray rf = reader.getSafeFile(); try { rf.reOpen(); byte buf[] = new byte[8192]; for (int k = 0; k < b.size(); ++k) { int start = b.getAsNumber(k).intValue(); int length = b.getAsNumber(++k).intValue(); rf.seek(start); while (length > 0) { int rd = rf.read(buf, 0, Math.min(length, buf.length)); if (rd <= 0) break; length -= rd; pkcs7.update(buf, 0, rd); } } } catch (Exception e) { throw new ExceptionConverter(e); } finally { try{rf.close();}catch(Exception e){} } }
CMapAwareDocumentFont font = new CMapAwareDocumentFont( (PRIndirectReference) fontParameter.getPdfObject(0)); float size = fontParameter.getAsNumber(1).floatValue();