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
        }
        public static void Run()
        {
            // ExStart:CreateCustomTeXFormatFile
            // Create TeX engine options for no format on ObjectTeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectIniTeX);

            // 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);

            // Run format creation.
            TeXJob.CreateFormat("customtex", options);

            // For further output to look write.
            options.TerminalOut.Writer.WriteLine();
            // ExEnd:CreateCustomTeXFormatFile
        }
示例#3
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
        }
示例#4
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
        }
示例#5
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
        }