PS, EPS 및 XPS 변환
당사의 다재다능한 API 솔루션으로 C++ 애플리케이션의 잠재력을 최대한 활용하십시오! C++용 다재다능한 API 솔루션을 통해 PS, EPS 및 XPS 파일을 고품질 PDF 및 멋진 이미지로 원활하게 변환하십시오!
당사의 다재다능한 네이티브 API 솔루션으로 C++ 애플리케이션의 잠재력을 최대한 활용하십시오! PS, EPS 및 XPS 파일을 고품질 PDF 및 멋진 이미지로 빠르고 쉽게 변환하십시오. 정밀한 문서 변환이 필요하든 완벽한 시각적 콘텐츠가 필요하든, 당사의 API는 프로세스를 단순화하여 프로젝트를 손쉽게 향상시킬 수 있는 도구를 제공합니다. 문서 관리를 개선하고 비주얼에 새로운 생명을 불어넣으십시오. C++ API를 통해 PostScript(PS) 및 Encapsulated PostScript(EPS)는 물론 XPS 문서를 PDF 및 이미지로 변환하는 마법을 경험하십시오. 문서를 변환할 준비가 되셨습니까? 지금 무료 평가판을 사용해 보거나 구매하여 콘텐츠의 품격을 높이십시오!
프로그래머는 PostScript 및 XPS 문서의 일괄 처리에 쉽게 사용할 수 있으며, 캔버스(canvases), 경로(paths) 및 글리프(glyphs) 요소를 조작하고 벡터 그래픽 모양과 텍스트 문자열을 처리할 수도 있습니다.
여기 제공되는 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 클래스 생성자 를 사용하여 문서를 로드합니다.
- 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 클래스 생성자 를 사용하여 문서를 로드합니다.
- AdditionalFontsFolder 및 SuppressError 값 등과 같은 추가 설정을 정의하기 위해 PdfSaveOptions Class 의 개체를 생성합니다.
- PDF 파일 변환을 위해 SaveAsPdf 메서드를 호출합니다.
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는 Windows 및 Linux 기반 시스템에서 BMP, JPG, TIFF, PNG 등을 포함한 XPS에서 이미지로의 변환과 XPS에서 PDF로의 변환을 처리합니다. XPS를 이미지로 변환하는 프로세스는 다음과 같습니다.
- 입력 파일 이름과 XpsLoadOptions 를 생성자 인수로 사용하여 XpsDocument Class 의 인스턴스를 생성합니다.
- 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는 Windows 및 Linux 기반 시스템에서 BMP, JPG, TIFF, PNG 등을 포함한 XPS에서 이미지로의 변환과 XPS에서 PDF로의 변환을 처리합니다. XPS를 PDF로 변환하는 프로세스는 다음과 같습니다.
- PDF 출력을 위한 출력 스트림을 정의합니다.
- 입력 파일 이름과 XpsLoadOptions 를 생성자 인수로 사용하여 XpsDocument Class 의 인스턴스를 생성합니다.
- 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 솔루션의 경우 무료 평가판을 받은 다음 필요한 경우 제품을 구매할 수 있습니다.