PDF 파일의 페이지 크기 변경

Implementation details

PdfPageEditor 클래스는 Aspose.Pdf.Facades namespace 내에 있으며, PageSize 속성을 통해 개별 페이지 또는 여러 페이지의 페이지 크기를 한 번에 변경할 수 있습니다. Pages 속성을 사용하여 새 페이지 크기를 적용할 페이지 번호를 지정할 수 있습니다. PageSize 클래스는 다양한 페이지 크기의 목록을 멤버로 포함하고 있습니다. 이 클래스의 멤버 중 어느 것이든 PdfPageEditor 클래스의 PageSize 속성에 할당할 수 있습니다. 또한 GetPageSize 메서드를 호출하고 페이지 번호를 전달하여 페이지의 크기를 얻을 수도 있습니다.

 // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ChangePdfPageSize()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf();

    // Create PdfPageEditor object
    using (var pdfPageEditor = new Aspose.Pdf.Facades.PdfPageEditor())
    {
        // Bind PDF document
        pdfPageEditor.BindPdf(dataDir + "FilledForm.pdf");

        // Change page size of the selected pages
        pdfPageEditor.ProcessPages = new[] { 1 };

        // Select a predefined page size (LETTER) and assign it
        pdfPageEditor.PageSize = Aspose.Pdf.PageSize.PageLetter;

        // Save the file with the updated page size
        pdfPageEditor.Save(dataDir + "ChangePageSizes_out.pdf");

        // Get and display the page size assigned
        pdfPageEditor.BindPdf(dataDir + "FilledForm.pdf");

        var pageSize = pdfPageEditor.GetPageSize(1);
        Console.WriteLine($"Width: {pageSize.Width}, Height: {pageSize.Height}");
    }
}