인쇄 티켓 추가 및 조작

C#을 통해 XPS 파일의 인쇄 티켓 생성, 편집, 연결 및 가져오기

 

모든 페이지 설명 언어 형식은 인쇄를 지원합니다. PDF와 같은 일부는 다양한 색상 공간과 해상도에 독립적인 환경에서 고품질 인쇄를 지원합니다. XPS는 일반 사무용 프린터에서 인쇄하도록 설계되었으므로 더 적은 수의 색 공간과 2가지 유형의 글꼴만 지원합니다. 다른 기능 중 Aspose.Page API 솔루션을 사용하면 인쇄 티켓 작업이 가능합니다. 여기에서 생성, 편집, 가져오기 및 연결 방법을 설명하는 정보를 찾을 수 있습니다.

XPS 파일의 인쇄 티켓을 조작하려면 다음이 필요합니다.

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

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

Package Manager Console Command


    PM> Install-Package Aspose.Page

사용자 지정 인쇄 티켓을 만드는 단계 C# .NET.

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. XpsDocument Class 를 사용하여 XPS 파일을 만듭니다.
  3. JobPrintTicket 생성자를 사용하여 사용자 지정 작업 인쇄 티켓을 추가합니다.
  4. 티켓에 사용자 지정 페이지 매개변수 이니셜라이저 및 사용자 지정 페이지 해결 옵션을 추가합니다.
  5. XPsDocument.Save() 메서드를 사용하여 변경된 XPS 문서를 저장합니다.

XPS 파일에서 인쇄 티켓을 만드는 C# 코드

    using Aspose.Page.XPS;
    using Aspose.Page.XPS.XpsMetadata;
    using Aspose.Page.XPS.XpsModel;
    using System.Drawing;
    using System;
    // The path to the documents directory.
    string dir = RunExamples.GetDataDir_WorkingWithPrintTickets();

    // Create a new XPS document
    XpsDocument xDocs = new XpsDocument();

    // Add a custom job print ticket
    xDocs.JobPrintTicket = new JobPrintTicket(
        new PageDevModeSnaphot("SABlAGwAbABvACEAAAA="),             // Custom page parameter initializer
        new DocumentCollate(Collate.CollateOption.Collated),
        new JobCopiesAllDocuments(1),
        new PageICMRenderingIntent(PageICMRenderingIntent.PageICMRenderingIntentOption.Photographs),
        new PageColorManagement(PageColorManagement.PageColorManagementOption.None),
        new JobNUpAllDocumentsContiguously(
            new NUp.PresentationDirection(NUp.PresentationDirection.PresentationDirectionOption.RightBottom),
            new Borders(Borders.BordersOption.On) /* Custom nested feature */).AddPagesPerSheetOption(1),
        new PageMediaSize(PageMediaSize.PageMediaSizeOption.NorthAmericaLetter),
        new JobInputBin(InputBin.InputBinOption.AutoSelect),
        new JobDuplexAllDocumentsContiguously(Duplex.DuplexOption.OneSided),
        new PageOrientation(PageOrientation.PageOrientationOption.Portrait),
        new PageResolution(
            new PageResolution.PageResolutionOption("ns0000:ESDL300x300")             // Custom page resolution option
                .SetResolutionX(300).SetResolutionY(300)),
        new PageMediaType(PageMediaType.PageMediaTypeOption.Plain),
        new PageOutputColor(PageOutputColor.PageOutputColorOption.Color.Clone().SetDeviceBitsPerPixel(0).SetDriverBitsPerPixel(24)));


    // Save the document with the custom job print ticket.
    xDocs.Save(dir + "output1.xps");

C# .NET을 통해 XPS 인쇄 티켓을 편집하는 단계.

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. XpsDocument 클래스를 사용하여 인쇄 티켓으로 XPS 문서를 엽니다.
  3. 티켓에서 필요하지 않은 매개변수를 제거하려면 Remove() 메서드를 사용하세요.
  4. XPsDocument.Save() 메서드를 사용하여 변경된 작업 인쇄 티켓으로 문서를 저장합니다.

XPS 파일에서 인쇄 티켓을 편집하는 C# 코드

    // The path to the documents directory.
    string dir = RunExamples.GetDataDir_WorkingWithPrintTickets();

    // Open the XPS Document with print tickets
    XpsDocument xDocs = new XpsDocument(dir + "input3.xps");

    JobPrintTicket pt = xDocs.JobPrintTicket;

    // Remove some parameters from the job print ticket
    pt.Remove(
        "ns0000:PageDevmodeSnapshot",
        "ns0000:JobInterleaving",
        "ns0000:JobImageType");

    // Add some parameters to the job print ticket
    pt.Add(
        new JobCopiesAllDocuments(2),
        new PageMediaSize(PageMediaSize.PageMediaSizeOption.ISOA4));

    // Save the document with the changed job print ticket.
    xDocs.Save(dir + "output3.xps");

C# .NET을 통해 인쇄 티켓을 얻는 단계.

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. XpsDocument 클래스를 사용하여 인쇄 티켓으로 XPS 문서를 엽니다.
  3. JobPrintTicket 생성자를 사용하여 작업 인쇄 티켓을 만듭니다.
  4. GetDocumentPrintTicket() 메서드를 사용하여 문서 인쇄 티켓을 만듭니다.
  5. GetPagePrintTicket() 메서드를 사용하여 페이지 인쇄 티켓을 가져옵니다.
  6. XPsDocument.Save() 메서드를 사용하여 변경된 작업 인쇄 티켓으로 문서를 저장합니다.

XPS 파일에서 인쇄 티켓을 가져오는 C# 코드

    // The path to the documents directory.
    string dir = RunExamples.GetDataDir_WorkingWithPrintTickets();

    // Open the XPS Document without print tickets
    XpsDocument xDocs = new XpsDocument(dir + "input1.xps");

    // Get the job print ticket
    JobPrintTicket jobPrintTicket = xDocs.JobPrintTicket; // must be null for this document

    // Get the document print ticket
    DocumentPrintTicket docPrintTicket = xDocs.GetDocumentPrintTicket(1); // must be null for this document

    // Get the page print ticket
    PagePrintTicket pagePrintTicket = xDocs.GetPagePrintTicket(1, 1); // must be null for this document


    // Save the document. Default print tickets are automatically added to document while saving.
    xDocs.Save(dir + "output1.xps");

    // Open the saved earlier XPS Document with print tickets
    XpsDocument xDocs2 = new XpsDocument(dir + "output1.xps");

    // Print tickets must not be null

    Console.WriteLine(xDocs2.JobPrintTicket);

    Console.WriteLine(xDocs2.GetDocumentPrintTicket(1));

    Console.WriteLine(xDocs2.GetPagePrintTicket(1, 1));

C# .NET을 통해 XPS 파일의 인쇄 티켓을 연결하는 단계입니다.

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. XpsDocument 클래스를 사용하여 새 XPS 파일을 만들고 인쇄 티켓으로 XPS 문서를 엽니다.
  3. XpsDocument 클래스를 사용하여 인쇄 티켓으로 XPS 문서 열기
  4. JobPrintTicket 생성자와 작업 인쇄 티켓을 연결합니다.
  5. GetDocumentPrintTicket()SetDocumentPrintTicket() 메서드를 사용하여 문서 인쇄 티켓을 연결합니다.
  6. GetPagePrintTicket()SetPagePrintTicket() 메서드를 사용하여 페이지 인쇄 티켓을 연결합니다.
  7. XPsDocument.Save() 메서드를 사용하여 변경된 작업 인쇄 티켓으로 문서를 저장합니다.

XPS 파일에서 인쇄 티켓을 연결하는 C# 코드

    // The path to the documents directory.
    string dir = RunExamples.GetDataDir_WorkingWithPrintTickets();

    // Create a new XPS document
    XpsDocument xDocs1 = new XpsDocument();

    // Open the XPS Document with print tickets
    XpsDocument xDocs2 = new XpsDocument(dir + "input2.xps");

    // Link the job print ticket
    xDocs1.JobPrintTicket = xDocs2.JobPrintTicket;

    // Link the document print ticket
    xDocs1.SetDocumentPrintTicket(1, xDocs2.GetDocumentPrintTicket(2));

    // Link the page print ticket
    xDocs1.SetPagePrintTicket(1, 1, xDocs2.GetPagePrintTicket(3, 2));


    // Save the document with linked print tickets.
    xDocs1.Save(dir + "output1.xps");



자주하는 질문

1. XPS 파일에 대한 인쇄 티켓을 어떻게 만들 수 있나요?

문서를 프린터로 보내기 전에 문서에 대한 인쇄 티켓(또는 인쇄 정보)을 만들려면 JobPrintTicket 클래스.

2. Aspose.Page API 솔루션에서는 인쇄 티켓에 어떤 작업을 사용할 수 있나요?

이 .NET 솔루션을 사용하면 인쇄 정보를 생성, 편집, 가져오고 연결할 수 있습니다.

3. XPS 파일의 인쇄 정보를 편집하려면 어떻게 해야 합니까?

경로를 설정하고 인쇄 티켓이 포함된 XPS 문서를 엽니다. PrintTicket 클래스의 메서드를 사용하세요.

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

XPS 형식은 PDF 형식과 유사합니다. 둘 다 PDL(페이지 설명 언어) 형식입니다. EPS는 PostScript 언어가 아닌 HTML을 기반으로 합니다. .eps 파일은 문서가 어떻게 생겼는지에 대한 정보와 함께 문서 구조의 마크업을 포함할 수 있습니다. 문서를 인쇄하고 렌더링하는 방법에 대한 지침도 추가되었습니다. 형식의 특징은 문서의 설명을 수정한다는 것입니다. 즉, 누가, 어떤 운영 체제에서 문서를 열더라도 동일하게 보일 것입니다.