public void Execute(PdfOperation op) { // see Adobe PDF specs for additional operations switch (op.Name) { case "TJ": PrintText(op); break; case "Tm": SetMatrix(op); break; case "Tf": SetFont(op); break; case "S": PrintSection(op); break; case "G": case "g": case "rg": SetColor(op); break; } }
private void PrintText(PdfOperation op) { if (newSection) { newSection = false; StringBuilder header = new StringBuilder(); PrintText(op, header); } PrintText(op, text); }
private static string PrintCommand(PdfOperation op) { StringBuilder text = new StringBuilder(); foreach (PdfToken t in op.Arguments) { text.AppendFormat("{0} ", t.Value); } text.Append(op.Name); return(text.ToString()); }
private void SetFont(PdfOperation op) { var args = op.Arguments.ToList(); string font = args[0].Value; string size = args[1].Value; //if (font != lastFont || size != lastFontSize) // text.AppendLine(); lastFont = font; lastFontSize = size; }
private static void PrintText(PdfOperation op, StringBuilder text) { foreach (PdfToken t in op.Arguments) { switch (t.Type) { case PRTokeniser.TK_STRING: text.Append(t.Value); break; case PRTokeniser.TK_NUMBER: text.Append(" "); break; } } }
private void SetMatrix(PdfOperation op) { var args = op.Arguments.ToList(); string x = args[4].Value; string y = args[5].Value; if (lastY != y) { text.AppendLine(); } else if (lastX != x) { text.Append(" "); } lastX = x; lastY = y; }
private void PrintSection(PdfOperation op) { text.AppendLine("------------------------------------------------------------"); newSection = true; }
private void SetColor(PdfOperation op) { lastColor = PrintCommand(op).Replace(" ", "_"); }
private void PrintNewline(PdfOperation op) { text.AppendLine(); }