รวมเอกสาร PS เป็น PDF

โซลูชัน C++ API เพื่อรวมไฟล์ PostScript หลายไฟล์

 

รูปแบบไฟล์ PostScript สามารถมีหลายหน้า แต่ไม่มีความสามารถในการรวมไฟล์หลายไฟล์เป็นเอกสารเดียวเช่นรูปแบบ XPS โซลูชัน Aspose.Page API สำหรับ C++ มอบฟังก์ชันในการรวมไฟล์ PS หรือ EPS หลายไฟล์ไว้ในเอกสาร PDF เดียว

ตัวอย่างโค้ดต่อไปนี้สาธิตวิธีการรวมไฟล์ PostScript โดยใช้ C++ หากต้องการเรียนรู้วิธีรวมฟังก์ชันนี้เข้ากับโซลูชันเว็บหรือผสานไฟล์ออนไลน์ ให้ลองใช้เครื่องมือ PS Merger ข้ามแพลตฟอร์ม .

ในการรวมไฟล์ PS และ EPS เราต้องการ:

  • Aspose.Page สำหรับ C++ API ซึ่งเป็น API การจัดการและการแปลงเอกสารที่มีคุณลักษณะหลากหลาย ทรงพลัง และใช้งานง่ายสำหรับแพลตฟอร์ม C++

  • คุณสามารถดาวน์โหลดเวอร์ชันล่าสุดได้โดยตรง เพียงแค่เปิด NuGet package manager แล้วค้นหา Aspose.Page.Cpp และติดตั้ง คุณสามารถใช้คำสั่งต่อไปนี้จาก Package Manager Console

Package Manager Console Command


    PM> Install-Package Aspose.Page

ขั้นตอนในการผสานไฟล์ PostScript กับ C++

  1. เริ่มต้นเอาต์พุต PDF และสตรีมอินพุต PostScript
  2. สร้างอาร์เรย์ของไฟล์ PS เพื่อผสาน
  3. ใช้คลาส PdfSaveOptions เพื่อระบุพารามิเตอร์ที่จำเป็น คลาสนี้ให้คุณตั้งค่าพารามิเตอร์เพิ่มเติมในขณะผสาน
  4. สร้างอินสแตนซ์ของ PdfDevice จากเอาต์พุตสตรีมที่สร้างไว้ก่อนหน้านี้ และระบุขนาดและรูปแบบรูปภาพ
  5. รวมไฟล์ หากต้องการเรียนรู้เพิ่มเติมเกี่ยวกับฟังก์ชันนี้ ให้ไปที่ Aspose.Page เอกสารประกอบ

รหัส C ++ เพื่อรวม PS เป็น PDF

    using Aspose::Page::IO;
    using Aspose::Page::Presentation::Pdf;
    // Initialize PDF output stream
    System::SharedPtr<System::IO::FileStream> pdfStream = System::MakeObject<System::IO::FileStream>(outDir() + u"outputPDF_out.pdf", System::IO::FileMode::Create, System::IO::FileAccess::Write);
    
    // Initialize PostScript input stream
    System::SharedPtr<System::IO::FileStream> psStream = System::MakeObject<System::IO::FileStream>(dataDir() + u"input.ps", System::IO::FileMode::Open, System::IO::FileAccess::Read);
    System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(psStream);

    // Create an array of PostScript files that will be merged with the first one
    System::ArrayPtr<System::String> filesForMerge = System::MakeArray<System::String>({dataDir() + u"input2.ps", dataDir() + u"input3.ps"});
 
    //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 PdfDevice
    System::SharedPtr<Aspose::Page::EPS::Device::PdfDevice> device = System::MakeObject<Aspose::Page::EPS::Device::PdfDevice>(pdfStream);


    {
	    auto __finally_guard_0 = ::System::MakeScopeGuard([&psStream, &pdfStream]()
	    {
		    psStream->Close();
		    pdfStream->Close();
	    });

	    try
	    {
		    document->Merge(filesForMerge, device, options);
	    }
	    catch (...)
	    {
		    throw;
	    }
    }

รวมไฟล์ PostScript ที่ห่อหุ้มด้วย C ++

ในการรวม EPS เป็น PDF คุณจะต้องทำตามขั้นตอนเดียวกับการรวม PS เป็น PDF หากต้องการเรียนรู้ตัวอย่างโค้ดโดยละเอียดเพิ่มเติม ให้ไปที่ Aspose.Page เอกสารประกอบ

รหัส C ++ เพื่อรวม EPS เป็น PDF

    // Initialize PDF output stream
    System::SharedPtr<System::IO::FileStream> pdfStream = System::MakeObject<System::IO::FileStream>(outDir() + u"outputPDF_out.pdf", System::IO::FileMode::Create, System::IO::FileAccess::Write);
    
    // Initialize EPS input stream
    System::SharedPtr<System::IO::FileStream> psStream = System::MakeObject<System::IO::FileStream>(dataDir() + u"input.eps", System::IO::FileMode::Open, System::IO::FileAccess::Read);
    System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(psStream);

    // Create an array of EPS files that will be merged with the first one
    System::ArrayPtr<System::String> filesForMerge = System::MakeArray<System::String>({dataDir() + u"input2.eps", dataDir() + u"input3.eps"});
 
    //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 PdfDevice
    System::SharedPtr<Aspose::Page::EPS::Device::PdfDevice> device = System::MakeObject<Aspose::Page::EPS::Device::PdfDevice>(pdfStream);


    {
	    auto __finally_guard_0 = ::System::MakeScopeGuard([&psStream, &pdfStream]()
	    {
		    psStream->Close();
		    pdfStream->Close();
	    });

	    try
	    {
		    document->Merge(filesForMerge, device, options);
	    }
	    catch (...)
	    {
		    throw;
	    }
    }

PS PS รูปแบบไฟล์คืออะไร

รูปแบบ PS เป็นหนึ่งในรูปแบบภาษาคำอธิบายหน้า (PDL) สามารถใส่ข้อมูลกราฟิกและข้อความบนหน้าได้ นั่นคือเหตุผลที่รูปแบบได้รับการสนับสนุนโดยโปรแกรมส่วนใหญ่สำหรับการแก้ไขภาพ ไฟล์ postscript เป็นคำสั่งชนิดหนึ่งสำหรับเครื่องพิมพ์ มันมีข้อมูลเกี่ยวกับสิ่งที่และวิธีการพิมพ์จากหน้า