PS 문서를 PDF로 병합

여러 PostScript 파일을 결합하는 C++ API 솔루션

 

PostScript 파일 형식은 여러 페이지를 포함할 수 있지만 XPS 형식과 같이 여러 파일을 단일 문서로 결합하는 기능은 없습니다. C++용 Aspose.Page API 솔루션은 여러 PS 또는 EPS 파일을 하나의 PDF 문서로 병합하는 기능을 제공합니다.

다음 코드 예제는 C++를 사용하여 PostScript 파일을 병합하는 방법을 보여줍니다. 이 기능을 웹 솔루션에 통합하거나 온라인에서 파일을 병합하는 방법을 배워야 하는 경우 크로스 플랫폼 PS Merger 도구를 사용해 볼 수 있습니다. .

PS 및 EPS 파일을 병합하려면 다음이 필요합니다.

  • Aspose.Page for C++ API는 기능이 풍부하고 강력하며 사용하기 쉬운 C++ 플랫폼용 문서 조작 및 변환 API입니다.

  • 최신 버전을 직접 다운로드하고 NuGet 패키지 관리자를 열고 Aspose.Page.Cpp를 검색하여 설치할 수 있습니다. 패키지 관리자 콘솔에서 다음 명령을 사용할 수도 있습니다.

Package Manager Console Command


    PM> Install-Package Aspose.Page

PostScript 파일을 C++와 병합하는 단계

  1. PDF 출력 및 PostScript 입력 스트림을 초기화합니다.
  2. 병합할 PS 파일의 배열을 만듭니다.
  3. PdfSaveOptions 클래스를 사용하여 필요한 매개변수를 지정합니다. 이 클래스를 사용하면 병합하는 동안 추가 매개변수를 설정할 수 있습니다.
  4. 생성된 이전 출력 스트림에서 PdfDevice 의 인스턴스를 생성하고 크기 및 이미지 형식을 지정합니다.
  5. 파일을 병합합니다. 이 기능에 대해 자세히 알아보려면 Aspose.Page 문서 로 이동하십시오.

PS를 PDF로 병합하는 C++ 코드

    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 문서 로 이동하세요.

EPS를 PDF로 병합하는 C++ 코드

    // 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(페이지 설명 언어) 형식 중 하나입니다. 페이지에 그래픽 및 텍스트 정보를 포함할 수 있습니다. 그렇기 때문에 대부분의 이미지 편집 프로그램에서 이 형식을 지원했습니다. 포스트스크립트 파일 자체는 일종의 프린터 지침입니다. 여기에는 해당 페이지에서 인쇄할 내용과 방법에 대한 정보가 포함되어 있습니다.