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.