Converti PS, EPS e XPS
Sblocca tutto il potenziale delle tue applicazioni C++ con la nostra versatile soluzione API! Converti senza problemi file PS, EPS e XPS in PDF di alta qualità e immagini straordinarie con la nostra versatile soluzione API per C++!
Scopri tutto il potenziale delle tue applicazioni C++ con la nostra versatile soluzione API nativa! Converti file PS, EPS e XPS in PDF di alta qualità e immagini straordinarie in modo rapido e semplice. Che tu abbia bisogno di una trasformazione precisa dei documenti o di contenuti visivi perfetti, la nostra API semplifica il processo, fornendoti gli strumenti per migliorare senza sforzo i tuoi progetti. Migliora la gestione dei tuoi documenti e dai nuova vita alle tue immagini. Sperimenta la magia di PostScript (PS) ed Encapsulated PostScript (EPS), nonché la conversione di documenti XPS in PDF e immagini con la nostra API C++. Pronto a trasformare i tuoi documenti? Prova la nostra prova gratuita o acquista adesso e migliora i tuoi contenuti oggi stesso!
I programmatori possono usarlo facilmente per l'elaborazione batch di documenti PostScript e XPS, persino manipolare tele, tracciati ed elementi glifi e gestire forme grafiche vettoriali e stringhe di testo.
La soluzione API per C++ qui ti consente di convertire file di formati PDL come PS, EPS e XPS a livello di codice, ma potresti trovare utile vedere e provare il multipiattaforma sviluppato su queste API native. Ecco alcuni scenari di conversione come EPS in immagini, EPS in PDF, PostScript in PDF, PostScript in immagini, XPS in immagini e XPS in PDF
Converti PostScript (PS,EPS) in immagini tramite C++.
La libreria C++ consente di convertire file PostScript (PS) ed Encapsulated PostScript (EPS) in immagini su piattaforme Windows, Linux e macOS. Il processo è:
- Caricare il documento utilizzando PsDocument classe constructor con il flusso di file di input o il nome file come parametro.
- Crea un oggetto ImageSaveOptions Class e inizializzalo con le impostazioni richieste. Chiamare set_ImageFormat per impostare il formato immagine come valore di ImageFormat .
- Salva ogni pagina del file di input in un array di byte di immagine con SaveAsImage .
Codice C++ per la conversione da EPS a immagini
// 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()); | |
} | |
} |
Conversione da PostScript a PDF tramite C++.
Il processo di conversione da PostScript a PDF è semplice come da PostScript a immagini:
- Caricare il documento utilizzando PsDocument classe constructor con il flusso di file di input o il nome file come parametro.
- Crea un oggetto di PdfSaveOptions Class per definire impostazioni aggiuntive come AdditionalFontsFolder e il valore SuppressError ecc.
- Chiama il metodo SaveAsPdf per la conversione del file PDF.
Codice C++ per la conversione da PostScript a PDF
// 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()); | |
} | |
} |
Converti XPS in immagini tramite C++.
L'API di elaborazione XPS C++ si occupa della conversione di XPS in immagini tra cui BMP, JPG, TIFF, PNG e altro, nonché della conversione da XPS a PDF su sistemi basati su Windows e Linux. Il processo di conversione di XPS in immagine è:
- Crea un’istanza di XpsDocument Class con il nome del file di input e XpsLoadOptions come parametri del costruttore.
- Crea un’opzione di salvataggio come istanza di una classe da Aspose::Page::XPS::Presentation::Image .
- Chiama il metodo SaveAsImage del documento XPS per salvare ogni pagina del documento in un array di byte di immagine.
Codice C++ per la conversione da XPS a immagini
// 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()); | |
} | |
} | |
} | |
} | |
Converti XPS in PDF tramite C++.
L'API di elaborazione XPS C++ si occupa della conversione di XPS in immagini tra cui BMP, JPG, TIFF, PNG e altro, nonché della conversione da XPS a PDF su sistemi basati su Windows e Linux. Il processo di conversione da XPS a PDF è:
- Definire il flusso di output nell’output PDF.
- Crea un’istanza di XpsDocument Class con il nome del file di input e XpsLoadOptions come parametri del costruttore.
- Specificare le opzioni di salvataggio specifiche del PDF come TextCompression, ImageCompression e JpegQualityLevel utilizzando PdfSaveOptions .
- Infine converti il documento XPS in PDF utilizzando uno qualsiasi dei metodi SaveAsPdf .
Codice C++ per la conversione da XPS a PDF
// 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. Posso convertire Postscript con questa soluzione API?
Aspose.Page ha funzionalità che ti consentono di convertire file PS, XPS ed EPS in altri formati online o a livello di codice. Se hai bisogno di trasformare i tuoi file istantaneamente online, potresti utilizzare l’applicazione multipiattaforma Page Description Language format files Converter .
2. Quali lingue di descrizione della pagina sono supportate dal convertitore?
Questa funzionalità di conversione supporta file con estensione .ps, .eps e .xps. PDL famosi come PDF e SVG sono rappresentati come soluzioni separate in Aspose.products
3. La funzionalità è gratuita?
I convertitori multipiattaforma sono gratuiti, mentre per la soluzione API puoi ottenere una prova gratuita e quindi acquistare il prodotto se necessario.
Support and Learning Resources
- Risorse di apprendimento
- Documentazione
- Codice sorgente
- Riferimenti API
- Supporto al prodotto
- Supporto gratuito
- Supporto a pagamento
- Blog
- Release Notes
- Perché Aspose.Page per C++?
- Elenco clienti
- Storie di successo