I have some pages that I want to save the PRINT version of the HTML that the browser would render. I need to do this server side, because I want to convert it to a PDF and them embed it in an email. These pages I want to print have the following in the header of their Master Page.
<link media="all" href="../css/stylenav.css" type="text/css" rel="stylesheet" />
<link media="screen" href="../css/stylescreen.css" type="text/css" rel="stylesheet" />
<link media="print" href="../css/styleprint.css" type="text/css" rel="stylesheet" />
When I do the following I get the HTML for the Screen Version. I need the Print Version. Can this be done?
Dim url As String = HttpContext.Current.Request.Url.AbsoluteUri
'Prepare Request
Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(url)
request.Method = "GET"
request.ContentType = "text/html"
'Execute the request
Dim response As System.Net.WebResponse = request.GetResponse()
'Read data
Dim ResponseStream As Stream = response.GetResponseStream()
'Write content into the MemoryStream
Dim resReader As New BinaryReader(ResponseStream)
Dim docStream As New MemoryStream(resReader.ReadBytes(CInt(response.ContentLength)))
Dim doc As New Document(docStream)
'Save document
doc.Save("out.pdf", SaveFormat.Pdf, SaveType.OpenInApplication, Page.Response)
Thanks.
Edits: Here is some more details. I am using the ASPOSE Library to convert the stream to a document and then PDF. This part works fine, but it is not what gets printed.