Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
A Aspose.PDF for .NET permite que você altere o tamanho da página PDF com linhas simples de código em suas aplicações .NET. Este tópico explica como atualizar/alterar as dimensões (tamanho) da página de um arquivo PDF existente.
O seguinte trecho de código também funciona com a biblioteca Aspose.PDF.Drawing.
A classe Page contém o método SetPageSize(…) que permite definir o tamanho da página. O trecho de código abaixo atualiza as dimensões da página em alguns passos fáceis:
O seguinte trecho de código mostra como alterar as dimensões da página PDF para o tamanho 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");
}
}
Você pode ler o tamanho da página PDF de um arquivo PDF existente usando a Aspose.PDF for .NET. O seguinte exemplo de código mostra como ler as dimensões da 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.