I'm converting an HTML decoded string to a PdfMetafile, and after I draw the metafile there is always a vertical scrollbar on the right hand side of the pdf. Is there any way to hide this?
I'm using a mime object in a pop email inbox. As a test you can send any email with text in the body to the pop inbox. I just use a blank email w/ my signature.
Here is my code:
public void convertHTML2PDF(Mime m, int part)
{
try
{
//Create new PDF document
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
SizeF pageSize = page.GetClientSize();
PdfUnitConvertor convertor = new PdfUnitConvertor();
//get width of PDF image
float width = convertor.ConvertToPixels(pageSize.Width, PdfGraphicsUnit.Point);
AspectRatio dimension = AspectRatio.KeepWidth;
using (HtmlConverter c = new HtmlConverter())
{
//Set mime variables
string html = m.Parts[part].DecodedString;
//convert html to pdf metafile
PdfMetafile mf = new PdfMetafile(c.FromString(html, ImageType.Metafile, (int)width, -1, dimension) as Metafile);
mf.Quality = 100;
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Break = PdfLayoutBreakType.FitPage;
format.Layout = PdfLayoutType.Paginate;
//draw the image
mf.Draw(page, new PointF(0,0), format);
}
}
catch (Exception ex)
{
nLog.Error("Error converting the mime part to a PDF", ex);
}
}
Thanks!