class PdfContentStreamProcessor.IgnoreOperatorContentOperator {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands){
// ignore the operator
}
}
class PdfContentStreamProcessor.ShowTextArray {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfArray array = (PdfArray)operands.get(0);
float tj = 0;
for (Iterator<PdfObject> i = array.listIterator(); i.hasNext(); ) {
PdfObject entryObj = i.next();
if (entryObj instanceof PdfString){
processor.displayPdfString((PdfString)entryObj);
tj = 0;
} else {
tj = ((PdfNumber)entryObj).floatValue();
processor.applyTextAdjust(tj);
}
}
}
}
class PdfContentStreamProcessor.MoveNextLineAndShowTextWithSpacing {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber aw = (PdfNumber)operands.get(0);
PdfNumber ac = (PdfNumber)operands.get(1);
PdfString string = (PdfString)operands.get(2);
ArrayList<PdfObject> twOperands = new ArrayList<PdfObject>(1);
twOperands.add(0, aw);
setTextWordSpacing.invoke(processor, null, twOperands);
ArrayList<PdfObject> tcOperands = new ArrayList<PdfObject>(1);
tcOperands.add(0, ac);
setTextCharacterSpacing.invoke(processor, null, tcOperands);
ArrayList<PdfObject> tickOperands = new ArrayList<PdfObject>(1);
tickOperands.add(0, string);
moveNextLineAndShowText.invoke(processor, null, tickOperands);
}
}
class PdfContentStreamProcessor.MoveNextLineAndShowText {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
textMoveNextLine.invoke(processor, null, new ArrayList<PdfObject>(0));
showText.invoke(processor, null, operands);
}
}
class PdfContentStreamProcessor.ShowText {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfString string = (PdfString)operands.get(0);
processor.displayPdfString(string);
}
}
class PdfContentStreamProcessor.TextMoveNextLine {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
ArrayList<PdfObject> tdoperands = new ArrayList<PdfObject>(2);
tdoperands.add(0, new PdfNumber(0));
tdoperands.add(1, new PdfNumber(-processor.gs().leading));
moveStartNextLine.invoke(processor, null, tdoperands);
}
}
class PdfContentStreamProcessor.TextSetTextMatrix {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
float a = ((PdfNumber)operands.get(0)).floatValue();
float b = ((PdfNumber)operands.get(1)).floatValue();
float c = ((PdfNumber)operands.get(2)).floatValue();
float d = ((PdfNumber)operands.get(3)).floatValue();
float e = ((PdfNumber)operands.get(4)).floatValue();
float f = ((PdfNumber)operands.get(5)).floatValue();
processor.textLineMatrix = new Matrix(a, b, c, d, e, f);
processor.textMatrix = processor.textLineMatrix;
}
}
class PdfContentStreamProcessor.TextMoveStartNextLineWithLeading {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
float ty = ((PdfNumber)operands.get(1)).floatValue();
ArrayList<PdfObject> tlOperands = new ArrayList<PdfObject>(1);
tlOperands.add(0, new PdfNumber(-ty));
setTextLeading.invoke(processor, null, tlOperands);
moveStartNextLine.invoke(processor, null, operands);
}
}
class PdfContentStreamProcessor.TextMoveStartNextLine {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
float tx = ((PdfNumber)operands.get(0)).floatValue();
float ty = ((PdfNumber)operands.get(1)).floatValue();
Matrix translationMatrix = new Matrix(tx, ty);
processor.textMatrix = translationMatrix.multiply(processor.textLineMatrix);
processor.textLineMatrix = processor.textMatrix;
}
}
class PdfContentStreamProcessor.SetTextFont {
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;
PdfObject fontObject = fontsDictionary.get(fontResourceName);
if (fontObject instanceof PdfDictionary)
font = processor.getFont((PdfDictionary)fontObject);
else
font = processor.getFont((PRIndirectReference)fontObject);
processor.gs().font = font;
processor.gs().fontSize = size;
}
}
class PdfContentStreamProcessor.SetTextRenderMode {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber render = (PdfNumber)operands.get(0);
processor.gs().renderMode = render.intValue();
}
}
class PdfContentStreamProcessor.SetTextRise {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber rise = (PdfNumber)operands.get(0);
processor.gs().rise = rise.floatValue();
}
}
class PdfContentStreamProcessor.SetTextLeading {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber leading = (PdfNumber)operands.get(0);
processor.gs().leading = leading.floatValue();
}
}
class PdfContentStreamProcessor.SetTextHorizontalScaling {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber scale = (PdfNumber)operands.get(0);
processor.gs().horizontalScaling = scale.floatValue()/100f;
}
}
class PdfContentStreamProcessor.SetTextCharacterSpacing {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber charSpace = (PdfNumber)operands.get(0);
processor.gs().characterSpacing = charSpace.floatValue();
}
}
class PdfContentStreamProcessor.SetTextWordSpacing {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
PdfNumber wordSpace = (PdfNumber)operands.get(0);
processor.gs().wordSpacing = wordSpace.floatValue();
}
}
class PdfContentStreamProcessor.ProcessGraphicsStateResource {
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;
processor.gs().fontSize = size;
}
}
}
class PdfContentStreamProcessor.PushGraphicsState {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
GraphicsState gs = processor.gsStack.peek();
GraphicsState copy = new GraphicsState(gs);
processor.gsStack.push(copy);
}
}
class PdfContentStreamProcessor.ModifyCurrentTransformationMatrix {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
float a = ((PdfNumber)operands.get(0)).floatValue();
float b = ((PdfNumber)operands.get(1)).floatValue();
float c = ((PdfNumber)operands.get(2)).floatValue();
float d = ((PdfNumber)operands.get(3)).floatValue();
float e = ((PdfNumber)operands.get(4)).floatValue();
float f = ((PdfNumber)operands.get(5)).floatValue();
Matrix matrix = new Matrix(a, b, c, d, e, f);
GraphicsState gs = processor.gsStack.peek();
gs.ctm = matrix.multiply(gs.ctm);
}
}
class PdfContentStreamProcessor.PopGraphicsState {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
processor.gsStack.pop();
}
}
class PdfContentStreamProcessor.BeginText {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
processor.textMatrix = new Matrix();
processor.textLineMatrix = processor.textMatrix;
processor.beginText();
}
}
class PdfContentStreamProcessor.EndText {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
processor.textMatrix = null;
processor.textLineMatrix = null;
processor.endText();
}
}
class PdfContentStreamProcessor.BeginMarkedContent {
public void invoke(PdfContentStreamProcessor processor,
PdfLiteral operator, ArrayList<PdfObject> operands)
throws Exception {
processor.beginMarkedContent((PdfName)operands.get(0), new PdfDictionary());
}
}
class PdfContentStreamProcessor.BeginMarkedContentDictionary {
public void invoke(PdfContentStreamProcessor processor,
PdfLiteral operator, ArrayList<PdfObject> operands)
throws Exception {
PdfObject properties = operands.get(1);
processor.beginMarkedContent((PdfName)operands.get(0), getPropertiesDictionary(properties, processor.resources));
}
}
class PdfContentStreamProcessor.EndMarkedContent {
public void invoke(PdfContentStreamProcessor processor,
PdfLiteral operator, ArrayList<PdfObject> operands)
throws Exception {
processor.endMarkedContent();
}
}
class PdfContentStreamProcessor.Do {
public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) throws IOException {
PdfName xobjectName = (PdfName)operands.get(0);
processor.displayXObject(xobjectName);
}
}
|