Konversi PS, EPS, dan XPS

Buka potensi penuh aplikasi C++ Anda dengan solusi API serbaguna kami! Konversi file PS, EPS, dan XPS dengan mulus menjadi PDF berkualitas tinggi dan gambar yang memukau dengan solusi API serbaguna untuk C++ kami!

 

Temukan potensi penuh aplikasi C++ Anda dengan solusi API asli kami yang serbaguna! Konversi file PS, EPS, dan XPS menjadi PDF berkualitas tinggi dan gambar yang memukau dengan cepat dan mudah. Baik Anda membutuhkan transformasi dokumen yang tepat atau konten visual yang sempurna, API kami menyederhanakan proses tersebut, memberi Anda alat untuk meningkatkan proyek Anda dengan mudah. Tingkatkan manajemen dokumen Anda dan berikan kehidupan baru pada visual Anda. Rasakan keajaiban konversi dokumen PostScript (PS) dan Encapsulated PostScript (EPS) serta dokumen XPS ke PDF dan gambar dengan API C++ kami. Siap untuk mengubah dokumen Anda? Coba uji coba gratis kami atau beli sekarang dan tingkatkan konten Anda hari ini!

Pemrogram dapat dengan mudah menggunakannya untuk pemrosesan batch dokumen PostScript dan XPS, bahkan memanipulasi elemen kanvas (canvases), lintasan (paths) dan glyph, serta menangani bentuk grafis vektor dan string teks.

Solusi API untuk C++ di sini memungkinkan Anda mengonversi file format PDL seperti PS, EPS, dan XPS secara terprogram, namun Anda mungkin merasa terbantu untuk melihat dan mencoba solusi lintas platform yang dikembangkan pada API asli ini. Berikut adalah beberapa skenario konversi seperti EPS ke Gambar, EPS ke PDF, PostScript ke PDF, PostScript ke Gambar, XPS ke Gambar, dan XPS ke PDF.

Konversi PostScript (PS, EPS) ke Gambar melalui C++.

Perpustakaan C++ memungkinkan konversi file PostScript (PS) dan Encapsulated PostScript (EPS) ke gambar pada platform Windows, Linux, dan macOS. Prosesnya adalah:

  1. Muat dokumen menggunakan constructor kelas PsDocument yang memiliki stream file input atau nama file sebagai parameter.
  2. Buat objek ImageSaveOptions Class dan inisialisasi dengan pengaturan yang diperlukan. Hubungi set_ImageFormat untuk mengatur format gambar sebagai nilai dari ImageFormat .
  3. Simpan setiap halaman file input ke dalam array byte gambar dengan SaveAsImage .
Kode C++ untuk Konversi EPS ke Gambar
    // 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());
        }
    }
 

Konversi PostScript ke PDF melalui C++.

Proses mengonversi PostScript ke PDF semudah PostScript ke Gambar:

  1. Muat dokumen menggunakan constructor kelas PsDocument yang memiliki stream file input atau nama file sebagai parameter.
  2. Buat objek dari PdfSaveOptions Class untuk menentukan pengaturan tambahan seperti AdditionalFontsFolder dan nilai SuppressError dll.
  3. Hubungi metode SaveAsPdf untuk konversi file PDF.
Kode C++ untuk Konversi PostScript ke 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());
        }
    }
 

Konversi XPS ke Gambar melalui C++.

C++ XPS Processing API menangani konversi XPS ke Gambar termasuk BMP, JPG, TIFF, PNG, dan lainnya, serta konversi XPS ke PDF pada sistem berbasis Windows dan Linux. Proses mengonversi XPS ke gambar adalah:

  1. Buat instans XpsDocument Class dengan nama file input dan XpsLoadOptions sebagai parameter konstruktor.
  2. Buat opsi penyimpanan sebagai instans dari satu kelas dari Aspose::Page::XPS::Presentation::Image .
  3. Hubungi metode SaveAsImage dari dokumen XPS untuk menyimpan setiap halaman dokumen ke dalam array byte gambar.
Kode C++ untuk Konversi XPS ke Gambar
    // 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());
                }
            }
        }
    }

 

Konversi XPS ke PDF melalui C++.

C++ XPS Processing API menangani konversi XPS ke Gambar termasuk BMP, JPG, TIFF, PNG, dan lainnya, serta konversi XPS ke PDF pada sistem berbasis Windows dan Linux. Proses mengonversi XPS ke PDF adalah:

  1. Tentukan stream output ke output PDF.
  2. Buat instans XpsDocument Class dengan nama file input dan XpsLoadOptions sebagai parameter konstruktor.
  3. Tentukan opsi penyimpanan khusus PDF seperti TextCompression, ImageCompression, dan JpegQualityLevel menggunakan PdfSaveOptions .
  4. Terakhir, konversi dokumen XPS ke PDF menggunakan salah satu metode SaveAsPdf .
Kode C++ untuk Konversi XPS ke 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. Bisakah saya mengonversi Postscript dengan solusi API ini?

Aspose.Page memiliki fungsionalitas yang memungkinkan Anda mengonversi file PS, XPS, dan EPS ke format lain secara online atau terprogram. Jika Anda perlu mengubah file Anda secara instan secara online, Anda mungkin ingin menggunakan Halaman Deskripsi Bahasa format file Converter aplikasi lintas platform.

2. Apa deskripsi Halaman Bahasa yang didukung oleh konverter?

Fungsionalitas konversi ini mendukung file dengan ekstensi .ps, .eps, dan .xps. PDL terkenal seperti PDF dan SVG direpresentasikan sebagai solusi terpisah di Aspose.products

3. Apakah fungsionalitasnya gratis?

Pengonversi lintas platform gratis, sedangkan untuk solusi API Anda bisa mendapatkan Uji Coba gratis dan kemudian membeli produk jika diperlukan.

  

Support and Learning Resources