Aspose.TeX の入力インターフェイス | .NET

Aspose.TeX for .NETAPI reference を参照してください。

The concept of the input directory

TeX 言語の I/O プリミティブはファイル名しか扱えないため、Aspose.TeX for .NET ではディレクトリを名前とデータのバルクのマッピングとして定義しています。データのバルクはファイル、ストリーム、配列、またはその他何でも構いません。API は入力作業ディレクトリと出力作業ディレクトリを個別に指定できるようにしています。一般的な IInputWorkingDirectory インターフェイスが提供されており、ユーザーは独自に実装できます。また、以下で説明する独自実装も用意されています。このインターフェイスは GetFile() メソッドを定義しており、データストリームを返し、最初の引数として仮想的に異なる名前(実際にはマッピングキー)を受け取ってファイルの完全名を決定します。

Getting file input from the disk file system

以下のように実装します。

1// Getting file input from the disk file system
2
3// Create conversion options instance.
4TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
5// ...
6// Specify a file system working directory for the input.
7options.InputWorkingDirectory = new InputFileSystemDirectory(DataDir);

この使用例は非常にシンプルなため、これ以上詳しく説明する必要はありません。

Getting file input from a ZIP archive

入力ファイルを ZIP アーカイブに格納し、入力ディレクトリとして扱うこともできます。その場合は次の手順で実装します。

 1// Getting file input from a ZIP archive
 2
 3// Open the stream for the ZIP archive that will serve as the input working directory.
 4using (Stream inZipStream = File.Open(Path.Combine(DataDir, "zip-in.zip"), FileMode.Open))
 5{
 6    // Create conversion options instance.
 7    TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
 8    // ...
 9    // Specify a ZIP archive working directory for the input. You can also specify a path inside the archive.
10    options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in");

まず、ZIP ファイルを含むストリームを作成します。その後、変換オプションを作成し、 InputWorkingDirectory オプションに InputZipDirectory クラスのインスタンスを設定します。コンストラクタの第 2 引数はアーカイブ内のベースパスです。アーカイブ全体を入力ディレクトリとして使用したい場合は空文字列を渡します。

The concept of the input terminal

次に、端末入力についても説明します。Aspose.TeX for .NET は、 IInputTerminal インターフェイスを定義しており、これは TextReader 実装インスタンスを返す唯一のプロパティを持ちます。提供されている実装については以下で紹介します。

Getting terminal input from the console

これを行うには、 TerminalIn オプションに InputConsoleTerminal クラスのインスタンスを設定します。

1// Getting terminal input from the console
2
3// Create conversion options instance.
4TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
5// ...
6// Specify the console as the input terminal.
7options.TerminalIn = new InputConsoleTerminal(); // Default. Arbitrary assignment.

しかし実際には、このオプションのデフォルト値が同クラスのインスタンスであるため、明示的に指定する必要はほとんどありません。この事実と、他の実装が存在しないことから、この節はデモンストレーション目的に留めておきます。

理論的には、予測可能な動作を持つインタラクティブな TeX ファイル(またはスクリプト)を扱う場合、TeX エンジンのリクエストに応答する補助スクリプトを含む入力端末の実装を作成したくなるでしょう。時間があるときにぜひお試しください!

Have any questions about Aspose.TeX?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.