Hello,
Please examine the code below. I am overriding the Render method of my web page to generate a pdf copy of our aspx page. It works great, except I am getting a 1.5" margin on the right, a 1.25" margin on the left, a 1" margin on the top and a big margin on the bottom. There are no margin problems with the Words library, but isn't working so well with the PDF. Please advise.
protected override void Render(HtmlTextWriter output)
{
// Get HTML of the page
System.IO.StringWriter oStringWriter = new StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
base.Render(oHtmlTextWriter);
StringReader reader = new StringReader(oStringWriter.ToString());
MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd()));
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
Aspose.Pdf.Document docp = new Aspose.Pdf.Document(stream, htmloptions);
Aspose.Pdf.MarginInfo marginInfo = new Aspose.Pdf.MarginInfo();
marginInfo.Top = ConvertUtil.InchToPoint(0.5);
marginInfo.Bottom = ConvertUtil.InchToPoint(0.5);
marginInfo.Left = ConvertUtil.InchToPoint(0.5);
marginInfo.Right = ConvertUtil.InchToPoint(0.5);
docp.PageInfo.Margin = marginInfo;
docp.PageLayout = PageLayout.OneColumn;
docp.Save(Response, "filename.pdf", Aspose.Pdf.ContentDisposition.Attachment, new PdfSaveOptions());
}
=======================
Thanks in advance for any and all consideration.
Please examine the code below. I am overriding the Render method of my web page to generate a pdf copy of our aspx page. It works great, except I am getting a 1.5" margin on the right, a 1.25" margin on the left, a 1" margin on the top and a big margin on the bottom. There are no margin problems with the Words library, but isn't working so well with the PDF. Please advise.
protected override void Render(HtmlTextWriter output)
{
// Get HTML of the page
System.IO.StringWriter oStringWriter = new StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
base.Render(oHtmlTextWriter);
StringReader reader = new StringReader(oStringWriter.ToString());
MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd()));
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
Aspose.Pdf.Document docp = new Aspose.Pdf.Document(stream, htmloptions);
Aspose.Pdf.MarginInfo marginInfo = new Aspose.Pdf.MarginInfo();
marginInfo.Top = ConvertUtil.InchToPoint(0.5);
marginInfo.Bottom = ConvertUtil.InchToPoint(0.5);
marginInfo.Left = ConvertUtil.InchToPoint(0.5);
marginInfo.Right = ConvertUtil.InchToPoint(0.5);
docp.PageInfo.Margin = marginInfo;
docp.PageLayout = PageLayout.OneColumn;
docp.Save(Response, "filename.pdf", Aspose.Pdf.ContentDisposition.Attachment, new PdfSaveOptions());
}
=======================
Thanks in advance for any and all consideration.