高度な機能
ブラウザにPDFをダウンロードするために送信する
ASP.NETアプリケーションを開発しているとき、物理的に保存せずにウェブブラウザにPDFファイルをダウンロードするために送信する必要があります。これを実現するために、PDFドキュメントを生成した後にMemoryStreamオブジェクトに保存し、そのMemoryStreamからバイトをResponseオブジェクトに渡すことができます。これを行うと、ブラウザが生成されたPDFドキュメントをダウンロードします。
以下のコードスニペットは上記の機能を示しています:
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET | |
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(); | |
doc.Pages.Add().Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Hello World")); | |
MemoryStream ms = new MemoryStream(); | |
doc.Save(ms); | |
Response.Clear(); | |
Response.ClearHeaders(); | |
Response.ClearContent(); | |
Response.Charset = "UTF-8"; | |
Response.AddHeader("content-length", ms.Length.ToString()); | |
Response.AddHeader("content-disposition", String.Format("attachment;filename=TestDocument.pdf", "FileName")); | |
Response.ContentType = "application/pdf"; Response.BinaryWrite(ms.ToArray()); | |
Response.Flush(); | |
Response.End(); |
PDFファイルから埋め込まれたファイルを抽出する
PDF形式のファイルを扱う際に、Aspose.PDFは高度な機能で際立っています。他のツールがこの機能を提供するよりもはるかに優れた方法で埋め込まれたファイルを抽出します。
Aspose.PDF for .NETを使用すると、埋め込まれたフォント、画像、ビデオ、またはオーディオなど、任意の埋め込まれたファイルを効率的に抽出できます。 Aspose.PDF for .NETを使用すると、埋め込まれたフォント、画像、ビデオ、またはオーディオである可能性のある任意の埋め込みファイルを効率的に抽出できます。
次のコードスニペットは、PDFファイルからすべての埋め込みファイルを抽出します:
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); | |
// Load source PDF file | |
Document doc = new Document(dataDir + "input.pdf"); | |
// Save output in XML format | |
doc.Save(dataDir + "PDFToXML_out.xml", SaveFormat.MobiXml); |
数学表現を追加するためのLatexスクリプトの使用
Aspose.PDFを使用すると、latexスクリプトを使用してPDFドキュメント内に数学表現/式を追加できます。次の例は、この機能がテーブルセル内に数学式を追加するために2つの異なる方法でどのように使用できるかを示しています:
前文およびドキュメント環境なし
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); | |
// Create a new Document Object | |
Document doc = new Document(); | |
// Add Page in Pages Collection | |
Page page = doc.Pages.Add(); | |
// Create a Table | |
Table table = new Table(); | |
// Add a row into Table | |
Row row = table.Rows.Add(); | |
// Add Cell with Latex Script to add methematical expressions/formulae | |
string latexText1 = "$123456789+\\sqrt{1}+\\int_a^b f(x)dx$"; | |
Cell cell = row.Cells.Add(); | |
cell.Margin = new MarginInfo { Left = 20, Right = 20, Top = 20, Bottom = 20 }; | |
// Second LatexFragment constructor bool parameter provides LaTeX paragraph indents elimination. | |
LatexFragment ltext1 = new LatexFragment(latexText1, true); | |
cell.Paragraphs.Add(ltext1); | |
// Add table inside page | |
page.Paragraphs.Add(table); | |
// Save the document | |
doc.Save(dataDir + "LatextScriptInPdf_out.pdf"); |
前文およびドキュメント環境あり
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); | |
// Create a new Document Object | |
Document doc = new Document(); | |
// Add Page in Pages Collection | |
Page page = doc.Pages.Add(); | |
// Create a Table | |
Table table = new Table(); | |
// Add a row into Table | |
Row row = table.Rows.Add(); | |
// Add Cell with Latex Script to add methematical expressions/formulae | |
string latexText2 = @"\documentclass{article} | |
\begin{document} | |
Latex and the document class will normally take care of page layout issues for you. For submission to an academic publication, this entire topic will be out | |
\end{document}"; | |
Cell cell = row.Cells.Add(); | |
cell.Margin = new MarginInfo { Left = 20, Right = 20, Top = 20, Bottom = 20 }; | |
HtmlFragment text2 = new HtmlFragment(latexText2); | |
cell.Paragraphs.Add(text2); | |
// Add table inside page | |
page.Paragraphs.Add(table); | |
// Save the document | |
doc.Save(dataDir + "LatextScriptInPdf2_out.pdf"); |
Latexタグのサポート
changefreq: “monthly” type: docs
Latexタグのサポート
align環境はamsmathパッケージで定義されており、proof環境はamsthmパッケージで定義されています。したがって、ドキュメントのプリアンブルでこれらのパッケージを\usepackageコマンドを使用して指定する必要があります。そして、これは以下のコードサンプルに示されているように、LaTeXテキストをdocument環境に入れる必要があることを意味します。
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET | |
var dataDir = RunExamples.GetDataDir_AsposePdf_Text(); | |
var s = @" | |
\usepackage{amsmath,amsthm} | |
\begin{document} | |
\begin{proof} The proof is a follows: | |
\begin{align} | |
(x+y)^3&=(x+y)(x+y)^2 | |
(x+y)(x^2+2xy+y^2)\\ | |
&=x^3+3x^2y+3xy^3+x^3.\qedhere | |
\end{align} | |
\end{proof} | |
\end{document}"; | |
var doc = new Document(); | |
var page = doc.Pages.Add(); | |
var latex = new LatexFragment(s); | |
page.Paragraphs.Add(latex); | |
doc.Save(dataDir + "Script_out.pdf"); |