I am using 17.9 version in my MVC .net project. I’m trying to convert html to pdf file.
Is there a way to reduce/ modify the default page margins. Right now when I print the pdf file, there is lot of extra white space. I tried the following code but the default page margins remained to be the same.
The code I tried (that did not work) is below-
var basePath = HttpContext.Current.Request.Url.Scheme + “://” + HttpContext.Current.Request.Url.Authority;
var htmlOptions = new HtmlLoadOptions(basePath);
htmlOptions.PageInfo.IsLandscape = true;
htmlOptions.PageInfo.Height = 612;
htmlOptions.PageInfo.Width = 792;
var pdf = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(htmlString)), htmlOptions);
var headerHtml = new HtmlFragment(headerHTML);
HeaderFooter hf;
foreach (Aspose.Pdf.Page page in document.Pages)
{
hf = new Aspose.Pdf.HeaderFooter();
hf.Paragraphs.Add(headerHtml);
page.Header = hf;
}
document.Save(dataDir + “Output.pdf”);