Free Support Forum -

Aspose PdfDocument.Save DocSaveOptions

I am trying to save my pdf as a word document and no matter what i do, i cannot change the margins on the resulting word document. It appears they they are ‘hardcoded’ by the DocSaveOptions.Mode property. Does anyone know how to set the margins on the resulting word document to 1"?


The margins cannot be specified during conversion. However, you can set them in PDF document and then convert it to DOC/DOCX. OR are you saying that output word document is being generated with fixed margins regardless what value margins have in source PDF? Please share your sample PDF along with an expected output word document. We will test the scenario in our environment and address it accordingly.

Thank you for the response. I have attached 2 files (pdf and the docx that i created from the Save()). It seems as though no matter how or what i change the margins to in the PDF file, it has no effect when calling Save() and converting it to word. The Bottom margin is always 0" and the right margin is always 0.07", so when i try to print to a physical printer…it says the margins are outside the page boundaries.

Below is a sample code snippet, please let me know if i am doing something incorrect:

                    using (var pdfDocument =
                        new Document(new MemoryStream(content)))
                        using (var ms = new MemoryStream())
                            pdfDocument.Pages.First().PageInfo.Margin = new MarginInfo(1.0, 1.0, 1.0, 1.0);
                            pdfDocument.Pages.First().PageInfo.AnyMargin = new MarginInfo(1.0, 1.0, 1.0, 1.0);
                            pdfDocument.Save(ms, new DocSaveOptions
                                Format = renderContainer.RenderingFormat == Enums.RenderingType.WordDocx ? DocSaveOptions.DocFormat.DocX : DocSaveOptions.DocFormat.Doc,
                                Mode = DocSaveOptions.RecognitionMode.Flow
                    } (2.1 MB)


We have logged an enhancement request as PDFNET-49073 in our issue tracking system to specify margins during PDF to DOCX conversion. We will further investigate the feasibility of this feature and let you know once it is implemented. Please be patient and spare us some time. We are sorry for the inconvenience.

As a workaround, you can use Aspose.Words to adjust the margins of output .docx using following code snippet:

Document doc = new Document(@“source.docx”);
foreach (Section sec in doc.Sections)
 PageSetup ps = sec.PageSetup;
 // 1 inch equals 72 points
 ps.TopMargin = 1.4 * 72;
 ps.RightMargin = 2.5 * 72;
 ps.BottomMargin = 1.3 * 72;
 ps.LeftMargin = 3.3 * 72;

Thank you for the work around…my only question about it is licensing. I only have Aspose.PDF, would i need to buy a separate license for Aspose.Word?


Yes, you need to have Aspose.Words license in order to use it. You can use it however without license as well but trial version limitations would apply in this case.