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

Free Support Forum - aspose.com

How to set margin and orientation for PDF

I try to convert one *.doc file in to PDF. How can i set margin and orientation to that.

Aspose.Words.Document doc = new Aspose.Words.Document("c:\test\test.doc");
doc.Save("c:\test\test.pdf");

Hi Varun,

Thanks for your inquiry. Please use the following code example to achieve your requirements. I suggest you please read the members of PageSetup class from here:
https://reference.aspose.com/words/net/aspose.words/pagesetup/

Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.doc");
foreach (Section section in doc.Sections)
{
    section.PageSetup.Orientation = Aspose.Words.Orientation.Landscape;
    section.PageSetup.LeftMargin = 10;
    section.PageSetup.RightMargin = 10;
}
doc.Save(MyDir + "Out.pdf");

Thanks .

I try to set Zoom on that document by

((Aspose.Words.Document)section.Document).ViewOptions.ZoomPercent = 150;

But it is effected to the out out pdf file. How can i set that?
And can we set Quality (in DPI) to this pdf document?

Hi Varun,

Thanks for your inquiry.

*varunkumar:

I try to set Zoom on that document by
((Aspose.Words.Document)section.Document).ViewOptions.ZoomPercent = 150;
But it is effected to the out out pdf file. How can i set that?*

For PDF document, please use PdfSaveOptions.ZoomBehavior as PdfZoomBehavior.ZoomFactor. See the following code example for your kind reference.

Document doc = new Document(MyDir + "in.docx");
doc.ViewOptions.ZoomPercent = 150;
doc.Save(MyDir + "Out.docx");
doc.Save(MyDir + "Out.doc");
PdfSaveOptions option = new PdfSaveOptions();
option.ZoomBehavior = PdfZoomBehavior.ZoomFactor;
option.ZoomFactor = 150;
option.JpegQuality = 100;
option.TextCompression = PdfTextCompression.None;
doc.Save(MyDir + "Out.pdf", option);

*varunkumar:

And can we set Quality (in DPI) to this pdf document?*

Please note that Aspose.Words mimics the same behavior as MS Word does. If you convert your document to Pdf using MS Word, you will get the same output. Aspose.Words converts the document to PDF with high quality. You can set the image quality while rendering the Word to PDF. See the PdfSaveOptions.JpegQuality.

Hope this answers your query. Please let us know if you have any more queries.