public void Execute(PsContext context, IList <PdfObject> args) { if (args.Count < 1) { throw new ArgumentOutOfRangeException(nameof(args)); } if (!(args[0] is PdfArray arr)) { throw new ArgumentException("PsShowTextArray. Argument must be an array"); } foreach (var el in arr) { switch (el) { case PdfHexString hexString: var str = context.Decode(hexString.Value); context.DisplayString(str); break; case IPdfNumber pdfNumber: var num = pdfNumber.NumberValue; context.ApplyTextAdjust(num); break; default: throw new ArgumentException($"PsShowTextArray. Invalid element type {el.GetType()}"); } } }
public void Execute(PsContext context, IList <PdfObject> args) { var fontName = args[0] as PdfName; var fontSizeArg = args[1]; Double fontSize = 1; if (fontSizeArg is IPdfNumber fsNumber) { fontSize = fsNumber.NumberValue; } var fontsArg = context.Resources.Get <PdfObject>("Font"); if (fontsArg is PdfDictionary fontArgDict) { var fontRes = fontArgDict.Get <PdfName>(fontName.Name); var font = context.File.GetObject(fontRes) as PdfFont; font.Init(); context.SetFont(font, fontSize); } else { throw new ArgumentOutOfRangeException("PsSetTextFont. fontArgs"); } }
public void Execute(PsContext context, IList <PdfObject> args) { if (args[0] is IPdfNumber pdfNum) { context.GraphicState.SetWordSpacing(pdfNum.NumberValue); } }
public void Execute(PsContext context, IList <PdfObject> args) { PdfName resName = args[0] as PdfName; var gsState = context.Resources.ExtGState(); PdfName res = gsState.Get <PdfName>(resName.Name); var resObj = context.File.GetObject(res); }
public void ParseContent() { IList <PdfObject> args = new List <PdfObject>(); var context = new PsContext(_file, _page); while (_lexer.NextToken()) { switch (_lexer.Token) { case Token.Ider: ExecuteCommand(context, _lexer.StringValue, args); args.Clear(); break; case Token.StartArray: var arr = _lexer.ReadArray(null); args.Add(arr); break; default: args.Add(_lexer.PlainPdfObject()); break; } } }
public void Execute(PsContext context, IList <PdfObject> args) { if (args[0] is PdfHexString hexString) { var str = context.Decode(hexString.Value); context.DisplayString(str); } }
public void Execute(PsContext context, IList <PdfObject> args) { Double x = (args[0] as IPdfNumber).NumberValue; Double y = (args[1] as IPdfNumber).NumberValue; Double w = (args[2] as IPdfNumber).NumberValue; Double h = (args[3] as IPdfNumber).NumberValue; context.DrawRectangle(new Rectangle(x, y, w, h)); }
public void Execute(PsContext context, IList <PdfObject> args) { Double tx = (args[0] as IPdfNumber).NumberValue; Double ty = (args[1] as IPdfNumber).NumberValue; var translate = new Matrix(tx, ty); var newMx = translate * context.TextLineMatrix; context.SetTextMatrix(newMx); }
public void Execute(PsContext context, IList <PdfObject> args) { Double[] mx = new Double[6]; for (int i = 0; i < 6; i++) { if (args[i] is IPdfNumber pdfNumber) { mx[i] = pdfNumber.NumberValue; } } context.SetTextMatrix(new Matrix(mx)); }
void ExecuteCommand(PsContext context, String command, IList <PdfObject> args) { if (_commands.TryGetValue(command, out IPsCommand cmd)) { cmd.Execute(context, args); } else { /* g - set grey level (nonstroking) * cs = set color space (nonstroking) * scn = set color (nonstroking ICCBased) */ int z = 55; } }
public void Execute(PsContext context, IList <PdfObject> args) { context.SetTextMatrix(new Matrix()); context.BeginText(); }
public void Execute(PsContext context, IList <PdfObject> args) { context.SetTextMatrix(null); context.EndText(); }
public void Execute(PsContext context, IList <PdfObject> args) { context.RestoreState(); }