Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF for .NET позволяет вам изменять размер страниц PDF с помощью простых строк кода в ваших приложениях .NET. Эта тема объясняет, как обновить/изменить размеры страниц (размер) существующего PDF-файла.
Следующий фрагмент кода также работает с библиотекой Aspose.PDF.Drawing.
Класс Page содержит метод SetPageSize(…), который позволяет установить размер страницы. Ниже приведен фрагмент кода, который обновляет размеры страниц за несколько простых шагов:
Следующий фрагмент кода показывает, как изменить размеры страниц PDF на размер A4.
// 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_Pages();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "UpdateDimensions.pdf"))
{
// Get page collection
var pageCollection = document.Pages;
// Get particular page
var pdfPage = pageCollection[1];
// Set the page size as A4 (11.7 x 8.3 in) and in Aspose.Pdf, 1 inch = 72 points
// So A4 dimensions in points will be (842.4, 597.6)
pdfPage.SetPageSize(597.6, 842.4);
// Save PDF document
document.Save(dataDir + "UpdateDimensions_out.pdf");
}
}
Вы можете прочитать размер страницы PDF существующего PDF-файла с помощью Aspose.PDF for .NET. Следующий пример кода показывает, как прочитать размеры страниц PDF с помощью C#.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetPdfPageSize()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Pages();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "UpdateDimensions.pdf"))
{
// Adds a blank page to pdf document
Page page = document.Pages.Count > 0 ? document.Pages[1] : document.Pages.Add();
// Get page height and width information
Console.WriteLine(page.GetPageRect(true).Width.ToString() + ":" + page.GetPageRect(true).Height);
// Rotate page at 90 degree angle
page.Rotate = Rotation.on90;
// Get page height and width information
Console.WriteLine(page.GetPageRect(true).Width.ToString() + ":" + page.GetPageRect(true).Height);
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.