Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF for .NET te permite cambiar el tamaño de página PDF con líneas de código simples en tus aplicaciones .NET. Este tema explica cómo actualizar/cambiar las dimensiones (tamaño) de un archivo PDF existente.
El siguiente fragmento de código también funciona con la biblioteca Aspose.PDF.Drawing.
La clase Page contiene el método SetPageSize(…) que te permite establecer el tamaño de la página. El siguiente fragmento de código actualiza las dimensiones de la página en unos pocos pasos sencillos:
El siguiente fragmento de código muestra cómo cambiar las dimensiones de la página PDF al tamaño 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");
}
}
Puedes leer el tamaño de página PDF de un archivo PDF existente utilizando Aspose.PDF for .NET. El siguiente ejemplo de código muestra cómo leer las dimensiones de la página PDF usando 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.