PS、EPS、XPS を変換
当社の多用途 API ソリューションで C++ アプリケーションの可能性を最大限に引き出します。 C++ 用の多用途 API ソリューションを使用して、PS、EPS、XPS ファイルを高品質の PDF と美しい画像にシームレスに変換します。
当社の多用途ネイティブ API ソリューションで、C++ アプリケーションの可能性を最大限に引き出してください。 PS、EPS、XPS ファイルを高品質の PDF と美しい画像にすばやく簡単に変換します。正確なドキュメント変換が必要な場合でも、完璧なビジュアル コンテンツが必要な場合でも、当社の API はプロセスを簡素化し、プロジェクトを簡単に強化するためのツールを提供します。ドキュメント管理を改善し、ビジュアルに新しい命を吹き込みます。 PostScript (PS) と Encapsulated PostScript (EPS) の魔法だけでなく、XPS ドキュメントから PDF への変換や、C++ API を使用した画像変換を体験してください。ドキュメントを変換する準備はできていますか?無料トライアルを試すか、今すぐ購入して、今すぐコンテンツを強化してください。
プログラマはこれを簡単に PostScript や XPS ドキュメントのバッチ処理に使用したり、キャンバス、パス、グリフ要素を操作したり、ベクトル グラフィックス形状やテキスト文字列を処理したりすることができます。
ここでの C++ 用の API ソリューションでは、PS、EPS、XPS などの PDL 形式のファイルをプログラムで変換できますが、これらのネイティブ API で開発されたクロスプラットフォームを確認して試すと役立つ場合があります。 EPS から画像、EPS から PDF、PostScript から PDF、PostScript から画像、XPS から画像、XPS から PDF などの変換シナリオをいくつか紹介します。
C++ 経由で PostScript (PS、EPS) を画像に変換します。
C++ ライブラリを使用すると、Windows、Linux、macOS プラットフォームで PostScript (PS) および Encapsulated PostScript (EPS) ファイルをイメージに変換できます。プロセスは次のとおりです。
- PsDocument クラス constructor を使用してドキュメントをロードします パラメータとして入力ファイル ストリームまたはファイル名を持ちます。
- ImageSaveOptions Class オブジェクトを作成し、必要な設定で初期化します。 set_ImageFormat を呼び出して、画像形式を ImageFormat の値として設定します。
- SaveAsImage を使用して、各入力ファイル ページを画像の配列バイトに保存します。
EPS から画像への変換のための C++ コード
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentConversion(); | |
// Initialize PsDocument with the name of PostScript file. | |
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(dataDir + u"inputForImage.ps"); | |
// If you want to convert Postscript file despite of minor errors set this flag | |
bool suppressErrors = true; | |
//Initialize options object with necessary parameters. | |
System::SharedPtr<ImageSaveOptions> options = System::MakeObject<ImageSaveOptions>(); | |
//Set output image format. | |
options->set_ImageFormat(Aspose::Page::Drawing::Imaging::ImageFormat::Png); | |
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included. | |
options->set_AdditionalFontsFolders(System::MakeArray<System::String>({u"{FONT_FOLDER}"})); | |
// Save PS document as array of image bytes, one bytes array for one page. | |
System::ArrayPtr<System::ArrayPtr<uint8_t>> imagesBytes = document->SaveAsImage(options); | |
//Save images bytes arrays as image files. | |
int32_t i = 0; | |
for (System::ArrayPtr<uint8_t> imageBytes : imagesBytes) | |
{ | |
System::String imagePath = System::IO::Path::GetFullPath(dataDir + u"out_image" + System::Convert::ToString(i) + u"." + System::ObjectExt::ToString(options->get_ImageFormat()).ToLower()); | |
{ | |
System::SharedPtr<System::IO::FileStream> fs = System::MakeObject<System::IO::FileStream>(imagePath, System::IO::FileMode::Create, System::IO::FileAccess::Write); | |
// Clearing resources under 'using' statement | |
System::Details::DisposeGuard<1> __dispose_guard_0({ fs}); | |
// ------------------------------------------ | |
try | |
{ | |
fs->Write(imageBytes, 0, imageBytes->get_Length()); | |
} | |
catch(...) | |
{ | |
__dispose_guard_0.SetCurrentException(std::current_exception()); | |
} | |
} | |
i++; | |
} | |
//Review errors | |
if (suppressErrors) | |
{ | |
for (auto&& ex : System::IterateOver(options->get_Exceptions())) | |
{ | |
System::Console::WriteLine(ex->get_Message()); | |
} | |
} |
C++ を介した PostScript から PDF への変換。
PostScript を PDF に変換するプロセスは、PostScript を画像に変換するのと同じくらい簡単です。
- PsDocument クラス constructor を使用してドキュメントをロードします パラメータとして入力ファイル ストリームまたはファイル名を持ちます。
- PdfSaveOptions Class のオブジェクトを作成して、AdditionalFontsFolder や SuppressError 値などの追加設定を定義します。
- SaveAsPdf メソッドを呼び出して PDF ファイルに変換します。
PostScript から PDF への変換のための C++ コード
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentConversion(); | |
// Initialize PsDocument with the name of PostScript file. | |
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(dataDir + u"input.ps"); | |
// If you want to convert Postscript file despite of minor errors set this flag | |
bool suppressErrors = true; | |
//Initialize options object with necessary parameters. | |
System::SharedPtr<PdfSaveOptions> options = System::MakeObject<PdfSaveOptions>(suppressErrors); | |
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included. | |
options->set_AdditionalFontsFolders(System::MakeArray<System::String>({u"{FONT_FOLDER}"})); | |
// Default page size is 595x842 and it is not mandatory to set it in PdfSaveOptions | |
// But if you need to specify sizeuse following line | |
//PdfSaveOptions options = new PdfSaveOptions(suppressErrorsnew, Aspose.Page.Drawing.Size(595x842)); | |
// or | |
//saveOptions.Size = new Aspose.Page.Drawing.Size(595x842); | |
// Save document as PDF | |
document->SaveAsPdf(dataDir + u"outputPDF_out.pdf", options); | |
//Review errors | |
if (suppressErrors) | |
{ | |
for (auto&& ex : System::IterateOver(options->get_Exceptions())) | |
{ | |
System::Console::WriteLine(ex->get_Message()); | |
} | |
} |
C++ 経由で XPS を画像に変換します。
C++ XPS 処理 API は、XPS から BMP、JPG、TIFF、PNG などの画像への変換、および Windows および Linux ベースのシステムでの XPS から PDF への変換を処理します。 XPS を画像に変換するプロセスは次のとおりです。
- 入力ファイル名と XpsLoadOptions のインスタンスを入力ファイル名で作成します。 をコンストラクター パラメーターとして使用します。
- Aspose::Page::XPS::Presentation::Image 。
- XPS ドキュメントの SaveAsImage メソッドを呼び出して、各ドキュメント ページを画像の配列バイトに保存します。
XPS から画像への変換のための C++ コード
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentConversion(); | |
//Outut file | |
System::String outputFileName = dataDir + u"XPStoImage_out.bmp"; | |
// Load XPS document form the XPS file | |
System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(dataDir + u"input.xps", System::MakeObject<XpsLoadOptions>()); | |
// Initialize options object with necessary parameters. | |
System::SharedPtr<BmpSaveOptions> options = System::MakeObject<BmpSaveOptions>(); | |
options->set_SmoothingMode(System::Drawing::Drawing2D::SmoothingMode::HighQuality); | |
options->set_Resolution(300); | |
options->set_PageNumbers(System::MakeArray<int32_t>({1, 2, 6})); | |
// Save XPS document to the images byte arrays. The first dimension is for inner documents | |
// and the second one is for pages within inner documents. | |
System::ArrayPtr<System::ArrayPtr<System::ArrayPtr<uint8_t>>> imagesBytes = document->SaveAsImage(options); | |
// Iterate through document partitions (fixed documents, in XPS terms) | |
for (int32_t i = 0; i < imagesBytes->get_Length(); i++) | |
{ | |
// Iterate through partition pages | |
for (int32_t j = 0; j < imagesBytes[i]->get_Length(); j++) | |
{ | |
// Initialize image output stream | |
{ | |
System::SharedPtr<System::IO::Stream> imageStream = System::IO::File::Open(System::IO::Path::GetDirectoryName(outputFileName) + System::IO::Path::DirectorySeparatorChar + System::IO::Path::GetFileNameWithoutExtension(outputFileName) + u"_" + (i + 1) + u"_" + (j + 1) + System::IO::Path::GetExtension(outputFileName), System::IO::FileMode::Create, System::IO::FileAccess::Write); | |
// Clearing resources under 'using' statement | |
System::Details::DisposeGuard<1> __dispose_guard_0({ imageStream}); | |
// ------------------------------------------ | |
try | |
{ | |
imageStream->Write(imagesBytes[i][j], 0, imagesBytes[i][j]->get_Length()); | |
} | |
catch(...) | |
{ | |
__dispose_guard_0.SetCurrentException(std::current_exception()); | |
} | |
} | |
} | |
} | |
C++ 経由で XPS を PDF に変換します。
C++ XPS 処理 API は、XPS から BMP、JPG、TIFF、PNG などの画像への変換、および Windows および Linux ベースのシステムでの XPS から PDF への変換を処理します。 XPS を PDF に変換するプロセスは次のとおりです。
- PDF 出力への出力ストリームを定義します。
- 入力ファイル名と XpsLoadOptions のインスタンスを入力ファイル名で作成します。 をコンストラクター パラメーターとして使用します。
- PdfSaveOptions を使用して、TextCompression、ImageCompression、JpegQualityLevel などの PDF 固有の保存オプションを指定します。
- 最後に、 SaveAsPdf メソッドのいずれかを使用して、XPS ドキュメントを PDF に変換します。
XPS から PDF への変換のための C++ コード
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithDocumentConversion(); | |
// Initialize PDF output stream | |
{ | |
System::SharedPtr<System::IO::Stream> pdfStream = System::IO::File::Open(dataDir + u"XPStoPDF_out.pdf", System::IO::FileMode::OpenOrCreate, System::IO::FileAccess::Write); | |
// Clearing resources under 'using' statement | |
System::Details::DisposeGuard<1> __dispose_guard_0({ pdfStream}); | |
// ------------------------------------------ | |
try | |
{ | |
// Load XPS document form the XPS file | |
System::SharedPtr<XpsDocument> document = System::MakeObject<XpsDocument>(dataDir + u"input.xps", System::MakeObject<XpsLoadOptions>()); | |
// Initialize options object with necessary parameters. | |
System::SharedPtr<Aspose::Page::XPS::Presentation::Pdf::PdfSaveOptions> options = System::MakeObject<Aspose::Page::XPS::Presentation::Pdf::PdfSaveOptions>(); | |
options->set_JpegQualityLevel(100); | |
options->set_ImageCompression(Aspose::Page::XPS::Presentation::Pdf::PdfImageCompression::Jpeg); | |
options->set_TextCompression(Aspose::Page::XPS::Presentation::Pdf::PdfTextCompression::Flate); | |
options->set_PageNumbers(System::MakeArray<int32_t>({1, 2, 6})); | |
document->SaveAsPdf(pdfStream, options); | |
} | |
catch(...) | |
{ | |
__dispose_guard_0.SetCurrentException(std::current_exception()); | |
} | |
} |
FAQ
1. この API ソリューションで Postscript を変換できますか?
Aspose.Page には、PS、XPS、および EPS ファイルをオンラインまたはプログラムで他の形式に変換できる機能があります。ファイルをオンラインで即座に変換する必要がある場合は、 ページ記述言語形式のファイル コンバーター クロスプラットフォーム アプリケーションを使用できます。
2. コンバーターでサポートされているページ記述言語は何ですか?
この変換機能は、拡張子が .ps、.eps、および .xps のファイルをサポートします。 PDF や SVG などの有名な PDL は、Aspose.products では個別のソリューションとして表されます。
3. 機能は無料ですか?
クロスプラットフォーム コンバーター は無料です。API ソリューションの場合、無料の試用版を取得してから、必要に応じて製品を購入できます。