.NET에서 PDF 페이지를 회전하고 재배하는 방법

.NET에서 PDF 페이지를 회전하고 재배하는 방법

올바른 페이지 지향 및 타이비 마진은 전문 PDF에 필수적입니다 - 인쇄, 디자인 또는 전자 탐색을 위해. Aspose.PDF.Plugin Optimizer for .NET, 당신은 자동화 할 수 있습니다 회전 및 모든 문서에 페이지를 쌓고, 목표 단일 페이지, 사용자 지정 범위, 또는 전체 배치.

회전 시나리오 : 페이지 방향 조정

  • Landscape to Portrait (또는 그 반대): 혼합 콘텐츠 문서 또는 디지털 / 인쇄 일치에 대 한
  • 선택 회전: 특정 페이지만 회전에 (예를 들어, 차트, 테이블, 법률 전시)
using Aspose.Pdf.Plugins;

string input = @"C:\Docs\mixed.pdf";
string output = @"C:\Docs\rotated.pdf";

var optimizer = new Optimizer();
var rotateOptions = new RotateOptions
{
    Rotation = Rotation.on90, // Rotate 90 degrees clockwise
    Pages = new[] { 2, 4, 6 } // Rotate only even-numbered pages
};
rotateOptions.AddInput(new FileDataSource(input));
rotateOptions.AddOutput(new FileDataSource(output));

optimizer.Process(rotateOptions);

크로핑 마진 : 콘텐츠에 초점을 맞추기

  • 화이트 공간, 국경, 또는 스캔 유물
  • 인쇄 또는 디자인 레이아웃을위한 정확한 크기까지 식물
var cropOptions = new CropOptions
{
    CropBox = new Rectangle(50, 50, 500, 700), // x, y, width, height
    Pages = new[] { 1, 2 } // Crop only specific pages
};
cropOptions.AddInput(new FileDataSource(input));
cropOptions.AddOutput(new FileDataSource(@"C:\Docs\cropped.pdf"));

optimizer.Process(cropOptions);

조합 예제 : 배치 회전 및 크로핑

여러 PDF를 처리하거나 두 작업을 연속적으로 실행하십시오 :

string[] pdfFiles = Directory.GetFiles(@"C:\Docs\ToProcess", "*.pdf");
foreach (var file in pdfFiles)
{
    // 1. Rotate selected pages
    var rotate = new RotateOptions { Rotation = Rotation.on90, Pages = new[] { 1 } };
    rotate.AddInput(new FileDataSource(file));
    rotate.AddOutput(new FileDataSource(file.Replace(".pdf", "_rotated.pdf")));
    optimizer.Process(rotate);

    // 2. Crop first page in rotated output
    var crop = new CropOptions { CropBox = new Rectangle(30, 30, 400, 600), Pages = new[] { 1 } };
    crop.AddInput(new FileDataSource(file.Replace(".pdf", "_rotated.pdf")));
    crop.AddOutput(new FileDataSource(file.Replace(".pdf", "_final.pdf")));
    optimizer.Process(crop);
}

사용 사례

  • 인쇄 생산: 서류가 묶기/결합을 위해 적절하게 조정되어 있는지 확인합니다.
  • 그래픽 디자인 : 레이아웃 스펙트를위한 식물 이미지 / 차트
  • 문서 청소 : 대량 수입에서 마진 또는 회전 스캔을 제거

자주 묻는 질문들

**Q : 문서의 특정 페이지만 회전하는 방법은 무엇입니까?**A : 사용하기 Pages Array 에 대 한 RotateOptions 목표 페이지를 지정합니다.

**Q: 정확한 차원으로 재배할 수 있습니까, 아니면 단지 몇 페이지만 목표로 하는가?**A : 예 - 세트 CropBox 그리고 페이지 번호를 지정합니다. CropOptions 위에서 보여준 것처럼.

Q : 작업을 결합 할 수 있습니까?A: 예 - 필요한 경우 수열 및 회전 또는 배치 프로세스 여러 PDF를 실행합니다.

프로 팁: 항상 배치 변경 전에 원본을 백업하고 결과를 예보합니다. PDF에 대하여 시청자는 생산 인쇄 또는 배달 전에 배치 / 회전을 확인합니다.

 한국어