We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How do I update the size of a word document so each page is A4

How do I set the size of each page to match A4 dimensions? Here is the code I have at the moment. Can you test it and see if you can get the size to change. I have tried and have not noticed any change

       private static string DecodeMemorialImages(int memId, string path, out List<string> images)
    {
        try
        {
            var newFile = "";
            images = new List<string>();
            bool success = false;

            string tempDir = GetTempWorkingDirectory();

            var memorial = path + "\\" + PrintDataManager.GetMemorial(memId);

            Aspose.Pdf.Document document;
            byte[] pdfBytes = File.ReadAllBytes(memorial);
            var localDocument = "";
            using (var stream = new MemoryStream(pdfBytes))
            {
                document = new Aspose.Pdf.Document(stream, false);
              

                newFile = Path.ChangeExtension(memorial, "docx");
                localDocument = CommonUtils.AddPath(tempDir, Path.GetFileName(newFile));

          
                newFile = localDocument;


                document.Save(localDocument, Aspose.Pdf.SaveFormat.DocX);

            }



            return newFile;
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }

    }

ROD_COPY_RETURN22383318.zip (575.5 KB)

@smooney1234

You can use PdfPageEditor.PageSize property to set the page size to PageSize.A4. For more detail, please read the following article.
Changing page sizes in PDF file

How do I account for landscape pages? at the minute it is trimming the page, it need to resize the actual image as well
Here is the pdf that needs resized, the actual image inside needs resized as well not just the document

pdf.zip (31.4 KB)

@smooney1234

We are investigating this issue and will get back to you soon.

@smooney1234

Please use the following code example to achieve your requirement.

var output = new Aspose.Pdf.Document(dataDir + "1990200001.pdf");
Aspose.Pdf.Facades.PdfFileEditor fileEditor = new Aspose.Pdf.Facades.PdfFileEditor();

for (int i = 0; i < output.Pages.Count; i++)
{
    fileEditor.ResizeContents(output, new int[] { i + 1 },
                        Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A4.Width,
                            PageSize.A4.Height));
}
output.Save(dataDir + "output.pdf");

thanks works perfectly