As i commented you can first convert the table into image. Then convert that image into a pdf file.
Converting aspx/html page into image
public Bitmap GenerateScreenshot(string url)
{
return GenerateScreenshot(url, -1, -1);
}
public Bitmap GenerateScreenshot(string url, int width, int height)
{
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
wb.Width = width;
wb.Height = height;
if (width == -1)
{
wb.Width = wb.Document.Body.ScrollRectangle.Width;
}
if (height == -1)
{
wb.Height = wb.Document.Body.ScrollRectangle.Height;
}
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
return bitmap;
}
Then write the code that image into pdf file.
1. create a new empty PDF document
2. add a blank page
3. get the XGraphics object
4. create the XImage from the source file
5. draw the image
6. save the PDF file
The code snippet to convert image to pdf is:
PdfDocument doc = new PdfDocument();
doc.Pages.Add(new PdfPage());
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
XImage img = XImage.FromFile(source);
xgr.DrawImage(img, 0, 0);
doc.Save(destinaton);
doc.Close();