Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
每个 PDF 文件中的页面都有多个属性,例如宽度、高度、出血框、裁剪框和修整框。Aspose.PDF 允许您访问这些属性。
以下代码片段也适用于 Aspose.PDF.Drawing 库。
下面的代码片段演示了如何裁剪页面:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CropPage()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Pages();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "CropPageInput.pdf"))
{
Console.WriteLine(document.Pages[1].CropBox);
Console.WriteLine(document.Pages[1].TrimBox);
Console.WriteLine(document.Pages[1].ArtBox);
Console.WriteLine(document.Pages[1].BleedBox);
Console.WriteLine(document.Pages[1].MediaBox);
// Create new Box rectangle
var newBox = new Rectangle(200, 220, 2170, 1520);
document.Pages[1].CropBox = newBox;
document.Pages[1].TrimBox = newBox;
document.Pages[1].ArtBox = newBox;
document.Pages[1].BleedBox = newBox;
// Save PDF document
document.Save(dataDir + "CropPage_out.pdf");
}
}
在此示例中,我们使用了一个示例文件 这里。最初我们的页面看起来如图 1 所示。
更改后,页面将看起来像图 2。
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.