メインのTEX入力ファイルを提供する代替方法| .NET経由でPython用のAspose.TeX

ストリームを使用してメイン入力ファイルをTexエンジンに提供する

これまでのところ、 メイン入力ファイルをTEXエンジンにファイル名として提供する方法を学びました。ただし、最初の引数としてストリームを受け入れる Texjobクラスで利用可能な 別のコンストラクターがあります。これは、何らかの理由で、メインの入力ファイルがディスクファイルシステム上のファイルの形式でない場合に役立ちます。これがどのように実装できるかの例です。

 1from aspose.tex import *
 2from aspose.tex.io import *
 3from aspose.tex.presentation.xps import *
 4from io import BytesIO
 5###############################################
 6###### Class and Method declaration here ######
 7###############################################
 8
 9# Create conversion options instance.
10...
11# Create some device.
12...
13# Run LaTeX to XPS conversion.
14TeXJob(BytesIO(r"\documentclass{article} \begin{document} Hello, World! \end{document}".encode("ascii")),
15      XpsDevice(), options).run()

すべての出力ファイルには「Texput」という名前が付けられていることに注意してください。これは、エンジンが他の名前にアクセスできないためです。 「Texput」はデフォルトのジョブ名です。ジョブ名 Tex Outputおよび ジョブ名の設定方法の段落に関する詳細情報を見つけることができます。

端末からメインのTEX入力ファイルを入力します

Texjobクラスで利用可能な もう1つのコンストラクターがあり、入力をまったく指定できません。あなたはそのようなTexの仕事が何を処理するのか疑問に思っているかもしれません。この場合、入力端子を使用する必要があります。 TEXエンジンは、端末からファイル名を入力するように促します。

これがコードです:

 1from aspose.tex import *
 2from aspose.tex.io import *
 3from aspose.tex.presentation.xps import *
 4###############################################
 5###### Class and Method declaration here ######
 6###############################################
 7
 8# Create conversion options instance.
 9...
10# Run LaTeX to XPS conversion. When prompted, enter the /-separated path to the LaTeX file.
11TeXJob(XpsDevice(), options).run()

実行されるとすぐに、エンジンは一時停止し、ファイル名を入力するのを待ちます(パスの有無にかかわらず、延長の有無にかかわらず):

端子ウィンドウ

そして、これが出力端子(コンソール)にどのように表示されるかを次に示します。

 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.

Have any questions about Aspose.TeX?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.