병합 결합 PS C#

PS 파일은 디지털 페이지 레이아웃을 텍스트와 그래픽의 올바른 조합을 나타내는 인쇄된 사본으로 변환합니다. 경우에 따라 다른 PostScript PS 파일을 단일 파일로 병합해야 할 수도 있습니다. 이러한 요구 사항에 따라 이 문서에서는 C#에서 프로그래밍 방식으로 PS 파일을 병합하거나 결합하는 방법을 다룹니다.

PS 파일 결합 또는 병합 – C# API 설치

Aspose.Page for .NET API는 PS, EPS, XPS와 같은 Page Description Language 형식과 함께 작동하도록 설계되었습니다. New Releases 섹션에서 DLL 파일을 다운로드하거나 다음 NuGet 설치 명령을 사용하여 API에 액세스하기만 하면 됩니다.

PM> Install-Package Aspose.Page

C#에서 프로그래밍 방식으로 PS 파일 병합

다른 PS 파일을 하나로 병합하려면 아래 단계를 따라야 합니다.

  1. 소스 PostScript PS 문서를 로드하여 다른 파일과 함께 추가합니다.
  2. PdfSaveOptions 클래스 인스턴스를 만듭니다.
  3. 병합할 소스 파일을 가져옵니다.
  4. PostScript PS 파일을 병합합니다.

다음 샘플 코드는 C#에서 프로그래밍 방식으로 PS 파일을 병합하는 방법을 보여줍니다.

// PDF 출력 스트림 초기화
System.IO.FileStream pdfStream = new System.IO.FileStream("outputPDF_out.pdf", System.IO.FileMode.Create, System.IO.FileAccess.Write);

// 첫 번째 PostScript 파일 입력 스트림 초기화
System.IO.FileStream psStream = new System.IO.FileStream("input.ps", System.IO.FileMode.Open, System.IO.FileAccess.Read);

Aspose.Page.EPS.PsDocument document = new Aspose.Page.EPS.PsDocument(psStream);

// 첫 번째 파일과 병합될 PostScript 파일의 배열을 만듭니다.
String[] filesForMerge = new String[] { "input2.ps", "input3.ps" };

// 필요한 매개변수를 사용하여 옵션 개체를 초기화합니다.
Aspose.Page.EPS.Device.PdfSaveOptions options = new Aspose.Page.EPS.Device.PdfSaveOptions(true);

// PdfDevice 클래스 개체 초기화
Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream);

try
{
    document.Merge(filesForMerge, device, options);
}
finally
{
    psStream.Close();
    pdfStream.Close();
}

C#에서 고급 속성을 사용하여 PS 파일 병합

.NET API용 Aspose.Page는 PS 병합 프로세스를 향상시키기 위해 많은 고급 속성을 제공합니다. 출력 문서의 다른 속성을 설정하려면 아래 단계를 따르십시오.

  1. PostScript 파일 병합을 위한 입력 PS 파일을 로드합니다.
  2. PdfSaveOptions 클래스의 속성을 지정합니다.
  3. PostScript 파일을 하나의 파일로 병합합니다.

다음 코드 조각은 PS 파일을 C#의 고급 옵션과 병합하는 방법을 보여줍니다.

// PDF 출력 스트림 초기화
System.IO.FileStream pdfStream = new System.IO.FileStream("outputPDF_out.pdf", System.IO.FileMode.Create, System.IO.FileAccess.Write);

// 첫 번째 PostScript 파일 입력 스트림 초기화
System.IO.FileStream psStream = new System.IO.FileStream("input.ps", System.IO.FileMode.Open, System.IO.FileAccess.Read);

Aspose.Page.EPS.PsDocument document = new Aspose.Page.EPS.PsDocument(psStream);

// 첫 번째 파일과 병합될 PostScript 파일의 배열을 만듭니다.
String[] filesForMerge = new String[] { "input2.ps", "input3.ps" };

// 필요한 매개변수를 사용하여 옵션 개체를 초기화합니다.
Aspose.Page.EPS.Device.PdfSaveOptions options = new Aspose.Page.EPS.Device.PdfSaveOptions(true);
options.JpegQualityLevel = 100;
options.SupressErrors = true;
options.Debug = false;


// // 다음 줄을 사용하여 PdfDevice 클래스 개체를 초기화합니다.
Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream, new System.Drawing.Size(595, 842));
try
{
    document.Merge(filesForMerge, device, options);
}
finally
{
    psStream.Close();
    pdfStream.Close();
}

무료 임시 라이센스 받기

임시 무료 라이선스를 요청하면 제한 없이 API를 평가할 수 있습니다.

결론

이 기사에서는 C#에서 프로그래밍 방식으로 PostScript PS 파일을 병합하는 방법을 배웠습니다. 기본 사용 사례와 요구 사항을 충족하는 고급 기능을 다룹니다. 또한 문서 공간을 방문하여 API의 다른 기능을 탐색할 수 있습니다. 문의 사항이나 우려 사항이 있는 경우 포럼으로 문의해 주십시오.

또한보십시오

C#에서 XPS 또는 OXPS를 Word DOCX/DOC로 변환