HTML
JPG
PDF
XML
DOCX
PDF
Redimensionar PDF no .NET SDK
API para trabalhar com redimensionamento de documentos PDF usando .NET.
Get StartedComo redimensionar PDF via Cloud .NET SDK
Para redimensionar documentos PDF, usaremos Aspose.PDF Cloud .NET SDK Este SDK da Cloud permite que você crie facilmente aplicativos de criação, edição e conversão de PDF baseados na nuvem em C#, ASP.NET ou outras linguagens .NET para diversas plataformas de nuvem. Abra NuGet gerenciador de pacotes, procure por Aspose.PDF Cloud e instale. Você também pode usar o seguinte comando no Console do Gerenciador de Pacotes.
Comando do Console do Gerenciador de Pacotes
PM> Install-Package Aspose.Pdf-Cloud
Passos para redimensionar PDF usando .NET SDK
Os desenvolvedores do Aspose.PDF Cloud podem facilmente carregar e redimensionar PDF com apenas algumas linhas de código.
- Carregue o PDF.
- Converta-o para HTML (mantendo a estrutura/conteúdo).
- Converta o HTML de volta para um novo PDF com as dimensões especificadas.
- Baixe o documento redimensionado.
Redimensionar PDF usando .NET Cloud SDK
using Aspose.Pdf.Cloud.Sdk.Model;
namespace ChangeLayout
{
public class ResizeDocumentAllPages
{
private ChangeLayoutHelper _helper;
public ResizeDocumentAllPages(ChangeLayoutHelper helper)
{
_helper = helper;
}
public async Task MakeResizeDocumentAllPages(string document, string htmlTempDoc, int pageWidth, int pageHeight)
{
await _helper.UploadFile(document);
string htmlTempPath = Path.Combine(_helper.config.REMOTE_TEMP_FOLDER, htmlTempDoc);
AsposeResponse response = await _helper.pdfApi.PutPdfInStorageToHtmlAsync(
document, htmlTempPath,
documentType: HtmlDocumentType.Xhtml.ToString(),
outputFormat: OutputFormat.Folder.ToString(),
folder: _helper.config.REMOTE_TEMP_FOLDER
);
if (response == null)
Console.WriteLine("MakeResizeDocumentAllPages(): Unexpected error - no response in Pdf to Html convert!");
else if (response.Code != 200)
Console.WriteLine("MakeResizeDocumentAllPages(): Error -> Code {0} -> Status '{1}'", [response.Code, response.Status]);
else
{
Console.WriteLine("MakeResizeDocumentAllPages(): temporary file '{0}' successfully created.", htmlTempDoc);
string outputDocument = "resized_" + document;
await _helper.pdfApi.PutHtmlInStorageToPdfAsync(
outputDocument, htmlTempPath,
dstFolder: _helper.config.REMOTE_TEMP_FOLDER,
htmlFileName: htmlTempDoc,
height: pageHeight,
width: pageWidth
);
if (response == null)
Console.WriteLine("MakeResizeDocumentAllPages(): Unexpected error - no response in html to Pdf convert!");
else if (response.Code != 200)
Console.WriteLine("MakeResizeDocumentAllPages(): Error -> Code {0} -> Status '{1}'", [response.Code, response.Status]);
else
{
Console.WriteLine("resizePages(): Pages successfully resized.");
await _helper.DownloadFile(outputDocument, "resized_doc_");
}
}
}
}
}