PS 파일에 페이지 삽입

PS 파일에 페이지를 추가하는 C++ API 솔루션

 

Aspose.Page API를 사용하여 PostScript(PS) 문서의 페이지 수를 제어하는 ​​방법에는 두 가지가 있습니다. 정확한 페이지 수를 미리 지정하거나 단일 페이지 또는 다중 페이지 문서를 생성하도록 선택할 수 있습니다. 그러나 페이지를 하나씩 추가하려면 OpenPage() 및 ClosePage() 메서드를 사용해야 합니다. PS 문서는 다양한 크기의 페이지를 가질 수 있으므로 OpenPage()를 사용하여 원하는 크기를 설정할 수 있습니다. 기본적으로 페이지 크기는 A4입니다. 기존 PS 문서가 아닌 새로 생성된 PS 문서의 페이지만 관리할 수 있다는 점을 기억하는 것이 중요합니다.

이 페이지에서는 C++용 Aspose.Page를 사용하여 PS 파일에 페이지를 추가하는 두 가지 옵션을 보여줍니다. 하지만 먼저 다음을 수행해야 합니다.

  • 기능이 풍부하고 강력하며 사용하기 쉬운 문서 조작 및 변환 C++ API인 C++ API용 Aspose.Page를 받으세요.

  • NuGet 패키지 관리자를 열고 Aspose.Page.Cpp를 검색하여 설치합니다. 패키지 관리자 콘솔에서 다음 명령을 사용할 수도 있습니다.

Package Manager Console Command

    PM> Install-Package Aspose.Page.Cpp

PS 파일에 페이지를 추가하는 C++ 코드입니다. 변종 1.

PS 파일에 페이지를 추가하는 단계입니다. 변종 1.

  1. 문서 디렉터리에 대한 경로를 구성합니다.
  2. 결과 PS 파일에 대한 출력 스트림을 만듭니다.
  3. A4 크기로 저장 옵션 만들기
  4. PsDocument 클래스 , 출력 스트림 및 페이지 수를 사용하여 PS 파일을 만듭니다.
  5. OpenPage() 메서드를 사용하여 빈 페이지를 만듭니다.
  6. 이 페이지에 콘텐츠를 적용하고 ClosePage() 메서드를 사용하여 닫습니다.
  7. 다른 크기의 페이지를 추가해야 하는 경우 새 항목과 동일한 OpenPage() 메서드를 사용하세요. 크기.
  8. ClosePage() 메서드를 사용하여 페이지를 닫습니다.
  9. Save() 메서드를 사용하여 PS 문서를 저장합니다.
PS에 이미지 추가
// The path to the documents directory.
System::String dataDir = RunExamples::GetDataDir_WorkingWithPages();
//Create output stream for PostScript document
{
System::SharedPtr<System::IO::Stream> outPsStream = System::MakeObject<System::IO::FileStream>(dataDir + u"document1.ps", System::IO::FileMode::Create);
// Clearing resources under 'using' statement
System::Details::DisposeGuard<1> __dispose_guard_0({ outPsStream});
// ------------------------------------------
try
{
//Create save options with A4 size
System::SharedPtr<PsSaveOptions> options = System::MakeObject<PsSaveOptions>();
// Create new 2-paged PS Document
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(outPsStream, options, 2);
//Add the first page
document->OpenPage();
//Add content
//Close the first page
document->ClosePage();
//Add the second page with different size
document->OpenPage(400.0f, 700.0f);
//Add content
//Close the second page
document->ClosePage();
//Save the document
document->Save();
}
catch(...)
{
__dispose_guard_0.SetCurrentException(std::current_exception());
}
}

PS 파일에 페이지를 추가하는 C++ 코드입니다. 변형 2.

PS 파일에 페이지를 추가하는 단계입니다. 변형 2.

  1. 문서 디렉터리에 대한 경로를 구성합니다.
  2. 결과 PS 파일에 대한 출력 스트림을 만듭니다.
  3. A4 크기로 저장 옵션 만들기
  4. PsDocument 클래스 를 사용하여 새 PS 파일을 만듭니다.
  5. 다른 크기의 페이지를 추가해야 하는 경우 새 크기의 OpenPage() 메서드를 사용하세요.
  6. 페이지에 콘텐츠를 추가한 후 ClosePage() 메서드를 사용하여 페이지를 닫습니다.
  7. Save() 메서드를 사용하여 PS 문서를 저장합니다.
PS에 이미지 추가
// The path to the documents directory.
System::String dataDir = RunExamples::GetDataDir_WorkingWithPages();
//Create output stream for PostScript document
{
System::SharedPtr<System::IO::Stream> outPsStream = System::MakeObject<System::IO::FileStream>(dataDir + u"document2.ps", System::IO::FileMode::Create);
// Clearing resources under 'using' statement
System::Details::DisposeGuard<1> __dispose_guard_0({ outPsStream});
// ------------------------------------------
try
{
//Create save options with A4 size
System::SharedPtr<PsSaveOptions> options = System::MakeObject<PsSaveOptions>();
//Set variable that indicates if resulting PostScript document will be multipaged
bool multiPaged = true;
// Create new multipaged PS Document with one page opened
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(outPsStream, options, multiPaged);
//Add content
//Close the first page
document->ClosePage();
//Add the second page with different size
document->OpenPage(500.0f, 300.0f);
//Add content
//Close the second page
document->ClosePage();
//Save the document
document->Save();
}
catch(...)
{
__dispose_guard_0.SetCurrentException(std::current_exception());
}
}

PS PS 파일 형식이란 무엇입니까?

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