HTML JPG PDF XML DOCX
  Product Family
PDF

Redimensionar PDF en .NET SDK

API para trabajar con el redimensionado de documentos PDF utilizando .NET.

Get Started

Cómo redimensionar PDF a través de Cloud .NET SDK

Para redimensionar documentos PDF, utilizaremos Aspose.PDF Cloud .NET SDK Este Cloud SDK te permite crear fácilmente aplicaciones en la nube para crear, editar y convertir PDF en C#, ASP.NET u otros lenguajes .NET para varias plataformas en la nube. Abre NuGet el gestor de paquetes, busca Aspose.PDF Cloud e instala. También puedes usar el siguiente comando desde la Consola del Administrador de Paquetes.

Comando de la Consola del Administrador de Paquetes


    PM> Install-Package Aspose.Pdf-Cloud
     

Pasos para redimensionar PDF usando .NET SDK

Los desarrolladores de Aspose.PDF Cloud pueden cargar y redimensionar fácilmente PDF con solo unas pocas líneas de código.

  1. Sube el PDF.
  2. Lo convierte a HTML (manteniendo la estructura/contenido).
  3. Convierte el HTML de nuevo a un nuevo PDF con las dimensiones especificadas.
  4. Descarga el 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_");
                    }
                }

            }
        }
    }