メインのTex入力ファイルを提供する他の方法| .NET
Contents
[
Hide
Show
]メイン入力ファイルをTexエンジンにストリームとして提供する
この時点まで、 メイン入力ファイルをファイル名としてTEXエンジンに渡す方法、完全に指定されているか短い形式で、拡張機能であろうとそれなしで渡す方法を知っていました。しかし、「Texjob`クラスの別の コンストラクターがあります。これは、最初の引数としてストリームを採用しています。これは、何らかの理由でディスクファイルシステム上のファイル以外のフォームにメインの入力ファイルがある場合に便利です。これがどのように実装されているかは次のとおりです。
1// Stream input with LaTeX document and XPS output
2
3// Create conversion options for Object LaTeX format upon Object TeX engine extension.
4TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);
5
6// Specify a file system working directory for the output.
7options.OutputWorkingDirectory = new OutputFileSystemDirectory(OutputDir);
8
9// Specify the console as the output terminal.
10options.TerminalOut = new OutputConsoleTerminal();
11
12// Define the saving options.
13options.SaveOptions = new XpsSaveOptions();
14
15// Create the XPS device.
16XpsDevice device = new XpsDevice();
17
18// Run the job with LaTeX document from memory stream.
19TeXJob job = new TeXJob(new MemoryStream(Encoding.ASCII.GetBytes(
20 @"\documentclass{article} \begin{document} Hello, World! \end{document}")),
21 device, options);
22job.Run();
23
24// For further output to look fine.
25options.TerminalOut.Writer.WriteLine();すべての出力ファイルには texputという名前が付いていることに注意してください。これは、エンジンが他の名前をどこにでも入手できないためです。 texput はデフォルトのジョブ名です。 ここおよび ここは、ジョブ名の詳細です。
ターミナルからメインTEX入力ファイルを入力します
「Texjob」クラスにはさらに別の コンストラクターがありますが、入力をまったく指定できません。それで、そのようなTexの仕事は何を処理しようとしているのでしょうか?今回は入力端子が必要です。 Texエンジンは、端末からファイル名を入力するように依頼します。
これがコードです:
1// Enter main TeX input file from the terminal (interactive)
2
3// Create conversion options for default ObjectTeX format upon ObjectTeX engine extension.
4TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
5
6// Specify a file system working directory for the input.
7options.InputWorkingDirectory = new InputFileSystemDirectory(DataDir);
8
9// Specify a file system working directory for the output.
10options.OutputWorkingDirectory = new OutputFileSystemDirectory(OutputDir);
11
12// Specify the console as the output terminal.
13options.TerminalOut = new OutputConsoleTerminal();
14
15// Define the saving options.
16options.SaveOptions = new XpsSaveOptions();
17
18// Run the job. The TeX engine will ask to enter the file name from the terminal.
19// Note: This is an interactive example. In production, you would typically
20// provide input via TerminalIn property or use one of the other input methods.
21TeXJob job = new TeXJob(new XpsDevice(), options);
22job.Run();
23
24// For further output to look fine.
25options.TerminalOut.Writer.WriteLine();実行されるとすぐに、エンジンが固執し、ファイル名を入力するのを待っています(パスの有無にかかわらず、拡張機能の有無にかかわらず):

そして、これはコンソールである出力端末をどのように見えるかです:
1This is ObjectTeX, Version 3.1415926-1.0 (Aspose.TeX 21.8)
2entering extended mode
3**<path_to_the_file>/hello-world.ltx
4(<path_to_the_file>/hello-world.ltx
5LaTeX2e <2011/06/27>
6(article.cls
7Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
8(size10.clo))
9No file hello-world.aux.
10[1]
11(<output_directory>\hello-world.aux) )
12Output written on hello-world.xps (1 page).
13Transcript written on hello-world.log.