Exemplo n.º 1
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
        }
        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
        }
Exemplo n.º 3
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: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
        }
Exemplo n.º 5
0
        public static void Run()
        {
            // ExStart:Conversion-LaTeXToPng-Simplest
            // Create conversion options for Object LaTeX format on Object TeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);

            // Specify the file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Initialize the options for saving in PNG format.
            options.SaveOptions = new PngSaveOptions();

            // ExStart:Aspose.TeX.Examples-Conversion-LaTeXToJpeg
            // Initialize the options for saving in JPEG format.
            //options.SaveOptions = new JpegSaveOptions();
            // ExEnd:Aspose.TeX.Examples-Conversion-LaTeXToJpeg

            // ExStart:Aspose.TeX.Examples-Conversion-LaTeXToTiff
            // Initialize the options for saving in TIFF format.
            //options.SaveOptions = new TiffSaveOptions();
            // ExEnd:Aspose.TeX.Examples-Conversion-LaTeXToTiff

            // ExStart:Aspose.TeX.Examples-Conversion-LaTeXToBmp
            // Initialize the options for saving in BMP format.
            //options.SaveOptions = new BmpSaveOptions();
            // ExEnd:Aspose.TeX.Examples-Conversion-LaTeXToBmp

            // Run LaTeX to PNG conversion.
            new TeXJob(Path.Combine(RunExamples.InputDirectory, "hello-world.ltx"), new ImageDevice(), options).Run();
            // ExEnd:Conversion-LaTeXToPng-Simplest
        }
        public static void Run()
        {
            // ExStart:Conversion-LaTeXToPdf-Simplest
            // Create conversion options for Object LaTeX format on Object TeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);

            // Specify the file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Initialize the options for saving in PDF format.
            options.SaveOptions = new PdfSaveOptions();
            // Run LaTeX to PDF conversion.
            new TeXJob(Path.Combine(RunExamples.InputDirectory, "hello-world.ltx"), new PdfDevice(), options).Run();
            // ExEnd:Conversion-LaTeXToPdf-Simplest
        }
 public static void Run()
 {
     // ExStart:Conversion-LaTeXToXps-Alternative
     // Create the stream to write the XPS file to.
     using (Stream xpsStream = File.Open(Path.Combine(RunExamples.OutputDirectory, "any-name.xps"), FileMode.Create))
     {
         // Create conversion options for Object LaTeX format on Object TeX engine extension.
         TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);
         // Specify the file system working directory for the output.
         options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
         // Initialize the options for saving in XPS format.
         options.SaveOptions = new XpsSaveOptions(); // Default value.
         // Run LaTeX to XPS conversion.
         new TeXJob(Path.Combine(RunExamples.InputDirectory, "hello-world.ltx"), new XpsDevice(xpsStream), options).Run();
     }
     // ExEnd:Conversion-LaTeXToXps-Alternative
 }
        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
        }
        public static void Run()
        {
            // ExStart:Conversion-LaTeXToXps-Simplest
            // Create conversion options for Object LaTeX format on Object TeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);

            // ExStart:Aspose.TeX.Examples-Conversion-InteractionMode
            // Set interaction mode.
            //options.Interaction = Interaction.NonstopMode;
            // ExEnd:Aspose.TeX.Examples-Conversion-InteractionMode

            // ExStart:Aspose.TeX.Examples-Conversion-JobName
            // Set the job name.
            //options.JobName = "my-job-name";
            // ExEnd:Aspose.TeX.Examples-Conversion-JobName

            // Specify the file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);

            // ExStart:Aspose.TeX.Examples-Conversion-Repeat
            // Ask the engine to repeat the job.
            //options.Repeat = true;
            // Exend:Aspose.TeX.Examples-Conversion-Repeat

            // Initialize the options for saving in XPS format.
            options.SaveOptions = new XpsSaveOptions(); // Default value.
            // Run LaTeX to XPS conversion.
            new TeXJob(Path.Combine(RunExamples.InputDirectory, "hello-world.ltx"), new XpsDevice(), options).Run();

            // ExStart:Aspose.TeX.Examples-Conversion-InputStream
            // Run LaTeX to XPS conversion.
            //new TeXJob(new MemoryStream(Encoding.ASCII.GetBytes(@"\documentclass{article} \begin{document} Hello, World! \end{document}")),
            //    new XpsDevice(), options).Run();
            // ExEnd:Aspose.TeX.Examples-Conversion-InputStream

            // ExStart:Aspose.TeX.Examples-Conversion-MainInputTerminal
            // Run LaTeX to XPS conversion.
            //new TeXJob(new XpsDevice(), options).Run();
            // ExEnd:Aspose.TeX.Examples-Conversion-MainInputTerminal

            // ExEnd:Conversion-LaTeXToXps-Simplest
        }
Exemplo n.º 10
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
        }
Exemplo n.º 11
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
        }
        public static void Run()
        {
            // ExStart:Conversion-LaTeXToPng-Alternative
            // Create conversion options for Object LaTeX format on Object TeX engine extension.
            TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);

            // Specify the file system working directory for the output.
            options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
            // Initialize the options for saving in PNG format.
            options.SaveOptions = new PngSaveOptions();
            // Run LaTeX to PNG conversion.
            ImageDevice device = new ImageDevice();

            new TeXJob(Path.Combine(RunExamples.InputDirectory, "hello-world.ltx"), device, options).Run();

            // Save pages file by file.
            for (int i = 0; i < device.Result.Length; i++)
            {
                using (Stream fs = File.Open(Path.Combine(RunExamples.OutputDirectory, "page-" + (i + 1) + ".png"), FileMode.Create))
                    fs.Write(device.Result[i], 0, device.Result[i].Length);
            }
            // ExEnd:Conversion-LaTeXToPng-Alternative
        }
Exemplo n.º 14
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
        }