コード例 #1
0
        public static void Run()
        {
            // ExStart:TypesetWithCustomTeXFormat
            // Create the file system input working directory.
            IInputWorkingDirectory wd = new InputFileSystemDirectory(RunExamples.OutputDirectory);

            // Create the format provider.
            using (FormatProvider formatProvider = new FormatProvider(wd, "customtex"))
            {
                // Create conversion options for a custom format on ObjectTeX engine extension.
                TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX(formatProvider));
                options.JobName = "typeset-with-custom-format";
                // Specify the input working directory.
                options.InputWorkingDirectory = wd;
                // Specify a file system working directory for the output.
                options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);

                // Run the job.
                new TeXJob(new MemoryStream(Encoding.ASCII.GetBytes(
                                                "Congratulations! You have successfully typeset this text with your own TeX format!\\end")),
                           new XpsDevice(), options).Run();

                // For further output to look write.
                options.TerminalOut.Writer.WriteLine();
            }
            // ExEnd:TypesetWithCustomTeXFormat
        }
        public static void Run()
        {
            // ExStart:WriteTerminalOutputToZip
            // Open a stream on a ZIP archive that will serve as the input working directory.
            using (Stream inZipStream = File.Open(Path.Combine(RunExamples.InputDirectory, "zip-in.zip"), FileMode.Open))
                // Open a stream on a ZIP archive that will serve as the output working directory.
                using (Stream outZipStream = File.Open(Path.Combine(RunExamples.OutputDirectory, "terminal-out-to-zip.zip"), FileMode.Create))
                {
                    // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
                    TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
                    // Specify the job name.
                    options.JobName = "terminal-output-to-zip";
                    // Specify a ZIP archive working directory for the input.
                    options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in");
                    // Specify a ZIP archive working directory for the output.
                    options.OutputWorkingDirectory = new OutputZipDirectory(outZipStream);
                    // Specify that the terminal output must be written to a file in the output working directory.
                    // The file name is <job_name>.trm.
                    options.TerminalOut = new OutputFileTerminal(options.OutputWorkingDirectory);

                    // Define the saving options.
                    options.SaveOptions = new PdfSaveOptions();
                    // Run the job.
                    new TeXJob("hello-world", new PdfDevice(), options).Run();

                    // Finalize output ZIP archive.
                    ((OutputZipDirectory)options.OutputWorkingDirectory).Finish();
                }
            // ExEnd:WriteTerminalOutputToZip
        }
コード例 #3
0
        public static void Run()
        {
            // ExStart:TakeInputFromZip-WriteOutputToZip
            // Open the stream on the ZIP archive that will serve as the input working directory.
            using (Stream inZipStream = File.Open(Path.Combine(RunExamples.InputDirectory, "zip-in.zip"), FileMode.Open))
                // Open the stream on the ZIP archive that will serve as the output working directory.
                using (Stream outZipStream = File.Open(Path.Combine(RunExamples.OutputDirectory, "zip-pdf-out.zip"), FileMode.Create))
                {
                    // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
                    TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
                    // Specify a ZIP archive working directory for the input.
                    options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in");
                    // Specify a ZIP archive working directory for the output.
                    options.OutputWorkingDirectory = new OutputZipDirectory(outZipStream);
                    // Specify the console as the output terminal.
                    options.TerminalOut = new OutputConsoleTerminal(); // Default. Not necessary to specify.

                    // Define the saving options.
                    options.SaveOptions = new PdfSaveOptions();
                    // Run the job.
                    TeXJob job = new TeXJob("hello-world", new PdfDevice(), options);
                    job.Run();

                    // For consequent output to look write.
                    options.TerminalOut.Writer.WriteLine();

                    // Finalize output ZIP archive.
                    ((OutputZipDirectory)options.OutputWorkingDirectory).Finish();
                }
            // ExEnd:TakeInputFromZip-WriteOutputToZip
        }
コード例 #4
0
        public static void Run()
        {
            // ExStart:WriteOutputPdfToExternalStream
            // Open a stream on a ZIP archive that will serve as the input working directory.
            using (Stream inZipStream = File.Open(Path.Combine(RunExamples.InputDirectory, "zip-in.zip"), FileMode.Open))
                // Open a stream on a ZIP archive that will serve as the output working directory.
                using (Stream outZipStream = File.Open(Path.Combine(RunExamples.OutputDirectory, "typeset-pdf-to-external-stream.zip"), FileMode.Create))
                {
                    // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
                    TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
                    // Specify the job name.
                    options.JobName = "typeset-pdf-to-external-stream"; // does NOT define the name of the output PDF.
                    // Specify a ZIP archive working directory for the input.
                    options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in");
                    // Specify a ZIP archive working directory for the output.
                    options.OutputWorkingDirectory = new OutputZipDirectory(outZipStream);
                    // Specify that the terminal output must be written to a file in the output working directory.
                    // The file name is <job_name>.trm.
                    options.TerminalOut = new OutputFileTerminal(options.OutputWorkingDirectory);

                    // Define the saving options.
                    options.SaveOptions = new PdfSaveOptions();
                    // Open a stream to write the output PDF to.
                    // 1) A file somewhere on a local file system.
                    using (Stream stream = File.Open(Path.Combine(RunExamples.OutputDirectory, "file-name.pdf"), FileMode.Create)) // writing PDF somewhere else
                        // 2) A file in the output ZIP. A wierd feature that extends flexibilty :)
                        //using (Stream stream = options.OutputWorkingDirectory.GetFile("file-name.pdf", out string fullName)) // writing PDF to the same ZIP
                        new TeXJob("hello-world", new PdfDevice(stream), options).Run();

                    // Finalize output ZIP archive.
                    ((OutputZipDirectory)options.OutputWorkingDirectory).Finish();
                }
            // ExEnd:WriteOutputPdfToExternalStream
        }
コード例 #5
0
        public static void Run()
        {
            // ExStart:TakeMainInputFromStream-AuxFromFileSystem-TakeTerminalInputFromConsole-AlternativeImagesStorage
            // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());

            // Specify the job name.
            options.JobName = "stream-in-image-out";
            // Specify a file system working directory for the input.
            options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
            // Specify a file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Specify the console as the input terminal.
            options.TerminalIn = new InputConsoleTerminal();   // Default. No need to specify.
            // Specify the console as the output terminal.
            options.TerminalOut = new OutputConsoleTerminal(); // Default. No need to specify.

            // Define the saving options.
            options.SaveOptions = new PngSaveOptions()
            {
                Resolution = 300
            };
            // Create the image device.
            ImageDevice device = new ImageDevice();
            // Run the job.
            TeXJob job = new TeXJob(new MemoryStream(Encoding.ASCII.GetBytes(
                                                         "\\hrule height 10pt width 95pt\\vskip10pt\\hrule height 5pt")),
                                    device, options);

            job.Run();

            // When the console prompts the input, type "ABC", press Enter, then type "\end" and press Enter again.

            // For further output to look write.
            options.TerminalOut.Writer.WriteLine();

            // You can alternatively get images in form of array of byte arrays.
            // The first index for the page number (0-based, of course).
            byte[][] result = device.Result;
            // ExEnd:TakeMainInputFromStream-AuxFromFileSystem-TakeTerminalInputFromConsole-AlternativeImagesStorage
        }
コード例 #6
0
        public static void Run()
        {
            // ExStart:OverrideJobName-WriteTerminalOutputToFileSystem
            // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());

            // Specify the job name. Otherwise, TeX.Typeset()'s method first argument will be taken as a job name.
            options.JobName = "overriden-job-name";
            // Specify a file system working directory for the input.
            options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
            // Specify a file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Specify that the terminal output must be written to a file in the output working directory.
            // The file name is <job_name>.trm.
            options.TerminalOut = new OutputFileTerminal(options.OutputWorkingDirectory);

            // Run the job.
            TeXJob job = new TeXJob("hello-world", new XpsDevice(), options);

            job.Run();
            // ExEnd:OverrideJobName-WriteTerminalOutputToFileSystem
        }
        public static void Run()
        {
            // ExStart:WriteOutputXpsToExternalStream
            // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());

            // Specify a job name.
            options.JobName = "external-file-stream";
            // Specify a file system working directory the for input.
            options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
            // Specify a file system working directory the for output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Specify that the terminal output must be written to a file in the output working directory.
            // The file name is <job_name>.trm.
            options.TerminalOut = new OutputFileTerminal(options.OutputWorkingDirectory);

            // Open the stream to write typeset XPS document. The file name is not necessarily the same as the job name.
            using (Stream stream = File.Open(Path.Combine(RunExamples.OutputDirectory, options.JobName + ".xps"), FileMode.Create))
                // Run the job.
                new TeXJob("hello-world", new XpsDevice(stream), options).Run();
            // ExEnd:WriteOutputXpsToExternalStream
        }
コード例 #8
0
        public static void Run()
        {
            // ExStart:TakeInputFromFileSystem-WriteOutputToFileSystem-WriteTerminalOutputToConsole
            // Create conversion options for default ObjectTeX format on ObjectTeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());

            // Specify a file system working directory for the input.
            options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
            // Specify a file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Specify console as output terminal.
            options.TerminalOut = new OutputConsoleTerminal(); // Default. No need to specify.
            // Specify a memory stream as output terminal, if you don't want the terminal output to be written to the console.
            //options.TerminalOut = new OutputMemoryTerminal();
            // Run the job.
            TeXJob job = new TeXJob("hello-world", new XpsDevice(), options);

            job.Run();

            // For further output to look write.
            options.TerminalOut.Writer.WriteLine(); // The same as Console.Out.WriteLine();
            // ExEnd:TakeInputFromFileSystem-WriteOutputToFileSystem-WriteTerminalOutputToConsole
        }