I have no idea what link you are referring to and there is no indication how you are calling the two methods.
Below is an example that overrides the Web Form's Render() method.
protected void Button1_Click(object sender, EventArgs e)
{
returnPdf = true;
}
protected override void Render(HtmlTextWriter Writer)
{
string Content = string.Empty;
MemoryStream pdfStream = new MemoryStream();
if (returnPdf)
{
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(stringWriter))
{
base.Render(HtmlTextWriter);
HtmlTextWriter.Close();
// get the page content
Content = stringWriter.ToString();
//Get a PDF stream
MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(Content));
HtmlConverter.ConvertToPdf(htmlStream, pdfStream);
}
}
// render the PDF content
Response.ContentType = "application/pdf";
Response.BinaryWrite(pdfStream.ToArray());
Response.End();
Response.Flush();
Response.Clear();
}
else
{
//Render HTML content
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(stringWriter))
{
base.Render(HtmlTextWriter);
HtmlTextWriter.Close();
Content = stringWriter.ToString();
}
}
Writer.Write(Content);
}
}
If the button is clicked a PDF is returned otherwise HTML is returned. I'm not sure if this is what you are trying to do exaclty.