I'm using the Aspose.Page.Cpp 23.12 library for PostScript to PDF conversion. However, when I run the code, the generated PDF file has a size of 0. On the other hand, when I use Aspose's online conversion tool, the conversion is successful. I would like to inquire about the usage of the Aspose library: 1. Do I need to purchase a commercial license before using the Aspose.Page.Cpp component? 2. Could there be an issue with my conversion code?
code:
BOOL PdfConvert::GeneratePdfFromPostScript(const std::wstring& post_script_path, const std::wstring& pdf_path)
{
System::String pdf_path_string((const char16_t*)pdf_path.c_str(), pdf_path.length());
System::String ps_path_string((const char16_t*)post_script_path.c_str(),post_script_path.length());
System::SharedPtr<System::IO::FileStream> pdfStream = System::MakeObject<System::IO::FileStream>(pdf_path_string, System::IO::FileMode::Create, System::IO::FileAccess::Write);
System::SharedPtr<System::IO::FileStream> psStream = System::MakeObject<System::IO::FileStream>(ps_path_string, System::IO::FileMode::Open, System::IO::FileAccess::Read);
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(psStream);
// 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);
// Default page size is 595x842 and it is not mandatory to set it in PdfDevice
System::SharedPtr<Aspose::Page::EPS::Device::PdfDevice> device = System::MakeObject<Aspose::Page::EPS::Device::PdfDevice>(pdfStream);
// But if you need to specify size and image format use following line
//Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream, new System.Drawing.Size(595, 842));
BOOL success = TRUE;
auto __finally_guard_0 = ::System::MakeScopeGuard([&psStream, &pdfStream]()
{
psStream->Close();
pdfStream->Close();
});
try{
document->Save(device, options);
}
catch (...)
{
success = FALSE;
}
return TRUE;
}