Пример #1
0
        private static void DisplayGeneratorExamples()
        {
            bool exitToProducts = false;

            while (!exitToProducts)
            {
                Console.WriteLine("Select a DynamicPDF Generator for .NET example to run:");
                Console.WriteLine(" A : Hello World");
                Console.WriteLine(" B : All Page Elements");
                Console.WriteLine(" C : Calender");
                Console.WriteLine(" D : Charting");
                Console.WriteLine(" E : Contact List");
                Console.WriteLine(" F : AES 256 Bit Encryption");
                Console.WriteLine(" G : RC4 128 Bit Encryption");
                Console.WriteLine(" H : Hello World Languages");
                Console.WriteLine(" I : Tagged Pdf");
                Console.WriteLine(" J : HTML Tags");
                Console.WriteLine(" K : HTML Tags With Styles");
                Console.WriteLine(" L : HTML Layout");
                Console.WriteLine(" M : Image With Alternate Text");
                Console.WriteLine(" N : Mailing Labels");
                Console.WriteLine(" O : Package PDF");
                Console.WriteLine(" P : Simple Report");
                Console.WriteLine(" Q : Simple XML Report");
                Console.WriteLine(" R : Table Report");
                Console.WriteLine(" S : Tagged PDF With Structure Elements");
                Console.WriteLine(" T : Tiff To PDF");
                Console.WriteLine(" U : Time Machine");
                Console.WriteLine(" V : Time Machine Tagged PDF");
                Console.WriteLine(" W : Watermark");
                Console.WriteLine(" X : Invoice");
                Console.WriteLine(" Y : USEnvelope");
                Console.WriteLine();
                Console.WriteLine("Press 'Backspace' for the main products menu");
                Console.WriteLine("Press 'Esc' to exit application");
                Console.WriteLine();
                ConsoleKeyInfo runKey = Console.ReadKey();
                Console.WriteLine();

                string exampleName = string.Empty;
                string fileName    = string.Empty;
                switch (runKey.Key)
                {
                case ConsoleKey.A:
                    exampleName = "Hello World";
                    fileName    = "HelloWorld.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    HelloWorld.Run(fileName);
                    break;

                case ConsoleKey.B:
                    exampleName = "All Page Elements";
                    fileName    = "AllPageElements.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    AllPageElements.Run(fileName);
                    break;

                case ConsoleKey.C:
                    exampleName = "Calender";
                    fileName    = "Calender.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    Calender.Run(fileName);
                    break;

                case ConsoleKey.D:
                    exampleName = "Charting";
                    fileName    = "Charting.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    Charting.Run(fileName);
                    break;

                case ConsoleKey.E:
                    exampleName = "Contact List";
                    fileName    = "ContactList.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    ContactList.Run(fileName);
                    break;

                case ConsoleKey.F:
                    Console.Clear();
                    exampleName = "AES 256 Bit Encryption";
                    fileName    = "Aes256BitEncryption.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    Aes256BitEncryption.Run(fileName);
                    break;

                case ConsoleKey.G:
                    exampleName = "RC4 128 Bit Encryption";
                    fileName    = "RC4128BitEncryption.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    RC4128BitEncryption.Run(fileName);
                    break;

                case ConsoleKey.H:
                    exampleName = "Hello World Languages";
                    fileName    = "HelloWorldLanguages.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    HelloWorldLanguages.Run(fileName);
                    break;

                case ConsoleKey.I:
                    exampleName = "Tagged PDF";
                    fileName    = "TaggedPdf.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    TaggedPdf.Run(fileName);
                    break;

                case ConsoleKey.J:
                    exampleName = "HTML Tags";
                    fileName    = "HtmlTags.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    HtmlAreaPDF.Run_WithHtmlTags(fileName);
                    break;

                case ConsoleKey.K:
                    exampleName = "HTML Tags With Styles";
                    fileName    = "HtmlTagsWithStyles.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    HtmlAreaPDF.Run_WithHtmlTagsAndStyles(fileName);
                    break;

                case ConsoleKey.L:
                    exampleName = "HTML Layout";
                    fileName    = "HtmlLayout.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    HtmlLayoutPDF.Run(fileName);
                    break;

                case ConsoleKey.M:
                    exampleName = "Image With Alternate Text";
                    fileName    = "ImageWithAltText.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    AltTextImage.Run(fileName);
                    break;

                case ConsoleKey.N:
                    exampleName = "Mailing Labels";
                    fileName    = "MailingLabels.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    MailingLabels.Run(fileName);
                    break;

                case ConsoleKey.O:
                    exampleName = "Package PDF";
                    fileName    = "PackagePdf.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    PackagePdf.Run(fileName);
                    break;

                case ConsoleKey.P:
                    exampleName = "Simple Report";
                    fileName    = "SimpleReport.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    SimpleReport.Run(fileName);
                    break;

                case ConsoleKey.Q:
                    exampleName = "Simple XML Report";
                    fileName    = "SimpleXmlReport.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    SimpleXMLReport.Run(fileName);
                    break;

                case ConsoleKey.R:
                    exampleName = "Table Report";
                    fileName    = "TableReport.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    TableReport.Run(fileName);
                    break;

                case ConsoleKey.S:
                    exampleName = "Tagged PDF With Structure Elements";
                    fileName    = "TaggedPdfWithStructureElements.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    TaggedPdfWithStructureElements.Run(fileName);
                    break;

                case ConsoleKey.T:
                    exampleName = "Tiff To PDF";
                    fileName    = "TiffToPdf.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    TiffToPdf.Run(fileName);
                    break;

                case ConsoleKey.U:
                    exampleName = "Time Machine";
                    fileName    = "TimeMachine.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    TimeMachine.Run(fileName);
                    break;

                case ConsoleKey.V:
                    exampleName = "Time Machine Tagged PDF";
                    fileName    = "TimeMachineTaggedPdf.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    TimeMachineTaggedPdf.Run(fileName);
                    break;

                case ConsoleKey.W:
                    exampleName = "Watermark";
                    fileName    = "Watermark.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    Watermark.Run(fileName);
                    break;

                case ConsoleKey.X:
                    exampleName = "Invoice";
                    fileName    = "Invoice.pdf";
                    Console.WriteLine("Please enter the invoice number(s) to include. Use a comma ',' to seperate multiple entries (Ex: 10248,10249,10250):");
                    Console.WriteLine();
                    Console.WriteLine("10248");
                    Console.WriteLine("10249");
                    Console.WriteLine("10250");
                    Console.WriteLine("10251");
                    Console.WriteLine("10252");
                    Console.WriteLine("10360");
                    Console.WriteLine("10979");
                    Console.WriteLine("11077");
                    Console.WriteLine();
                    string invoiceNumbers = Console.ReadLine();
                    Console.WriteLine(exampleName + " example is running...");
                    byte[] pdf = GeneratorInvoice.Run(invoiceNumbers.Split(','));
                    File.WriteAllBytes(fileName, pdf);
                    break;

                case ConsoleKey.Y:
                    exampleName = "USEnvelope";
                    fileName    = "USEnvelope.pdf";
                    Console.WriteLine(exampleName + " example is running...");
                    USEnvelope.Run(fileName);
                    break;

                case ConsoleKey.Escape:
                    System.Environment.Exit(0);
                    break;

                case ConsoleKey.Backspace:
                    exitToProducts = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("Key not recognized.");
                    break;
                }
                if (fileName != string.Empty)
                {
                    DisplayOutputPathWithOptionToOpen(fileName);
                }
            }
        }