static int Main(string[] args) { MonoMac.AppKit.NSApplication.Init(); var showHelp = false; var renderer = new PdfRenderer(); var options = new OptionSet { { "o|output=", "Set the output PDF file (must be specified first)", v => renderer.Open(v) }, { "t|template=", "Draw the first page of a template PDF (must be the first draw command)", v => renderer.DrawTemplatePage(v) }, { "rect", "Draw a rectangle", v => renderer.DrawRect() }, { "text=", "Draw some text", v => renderer.DrawText(v) }, { "bounds=", "Set the current bounding box (X,Y,W,H)", v => renderer.SetBounds(v) }, { "font=", "Set the current context font ('<Name> <Size>')", v => renderer.SetFont(v) }, { "color=", "Set the current color (name, #rgb, #rgba, #rrggbb, #rrggbbaa)", v => renderer.SetColor(v) }, { "halign=", "Set the current horizontal alignment (left, center ,right)", v => renderer.SetHAlign(v) }, { "valign=", "Set the current vertical alignment (top, middle, bottom)", v => renderer.SetVAlign(v) }, { "help", "Show this help", v => showHelp = v != null } }; try { if (args.Length > 0) { options.Parse(args); } else { showHelp = true; } } catch (Exception e) { Console.WriteLine("Invalid option: {0}", e.Message); Console.WriteLine(e); return(1); } if (showHelp) { Console.WriteLine("Usage: pdf-overlay [OPTIONS]+"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return(1); } renderer.Dispose(); return(0); }
static int Main(string[] args) { MonoMac.AppKit.NSApplication.Init (); var showHelp = false; var renderer = new PdfRenderer (); var options = new OptionSet { { "o|output=", "Set the output PDF file (must be specified first)", v => renderer.Open (v) }, { "t|template=", "Draw the first page of a template PDF (must be the first draw command)", v => renderer.DrawTemplatePage (v) }, { "rect", "Draw a rectangle", v => renderer.DrawRect () }, { "text=", "Draw some text", v => renderer.DrawText (v) }, { "bounds=", "Set the current bounding box (X,Y,W,H)", v => renderer.SetBounds (v) }, { "font=", "Set the current context font ('<Name> <Size>')", v => renderer.SetFont (v) }, { "color=", "Set the current color (name, #rgb, #rgba, #rrggbb, #rrggbbaa)", v => renderer.SetColor (v) }, { "halign=", "Set the current horizontal alignment (left, center ,right)", v => renderer.SetHAlign (v) }, { "valign=", "Set the current vertical alignment (top, middle, bottom)", v => renderer.SetVAlign (v) }, { "help", "Show this help", v => showHelp = v != null } }; try { if (args.Length > 0) { options.Parse (args); } else { showHelp = true; } } catch (Exception e) { Console.WriteLine ("Invalid option: {0}", e.Message); Console.WriteLine (e); return 1; } if (showHelp) { Console.WriteLine ("Usage: pdf-overlay [OPTIONS]+"); Console.WriteLine (); Console.WriteLine ("Options:"); options.WriteOptionDescriptions (Console.Out); return 1; } renderer.Dispose (); return 0; }