Answered by:
Html to word or pdf doc

Question
-
I need to take the currently created html that is created from a aspx page and turn it into a word document or pdf for the current users convince.
I have an online door builder. After they builder there doors they go to a second page that displays a dynamically created blueprint of the door they just built. I am offering the blueprint so that they can give this blueprint to there contractor for framing purposes while there door is being made.
I was thinking that i need to save the blueprint page to disk so that it can be rendered by some other program if the user elects to convert to word or pdf.
In other words every time the user goes to the blueprint page from creating a new door they create a new html from, "that is the same one that was sent to there browser for viewing"
Is there a com component for office or windows that will allow me to just render that saved html document?
Obivisuly the html document that the user is currently looking at can not be rendered that is why with every reponse that same html is saved to disk and overwritten on subsequent post back.
How can I render that html file on disk and save to pdf or word? Then send this new word or pdf back to the requesting client.?
thanks
http://afccinc.com?siteref=msdnTuesday, April 28, 2009 8:14 PM
Answers
-
If you have MS word, it can open html and you can make it save it as .doc or .pdf file. http://www.microsoft.com/downloads/details.aspx?FamilyID=4d951911-3e7e-4ae6-b059-a2e79ed87041&displaylang=enhttp://msdn.microsoft.com/en-us/library/kw65a0we(VS.80).aspx can help to automate word.Wednesday, April 29, 2009 4:40 AM
All replies
-
Windows Forms is not a document processing library. You need one like Microsoft Word.
MSMVP VC++Tuesday, April 28, 2009 10:18 PM -
HTML converters are a dime a dozen. Please use this forum only to ask questions about Windows Forms programming.
Hans Passant.Wednesday, April 29, 2009 1:03 AM -
If you have MS word, it can open html and you can make it save it as .doc or .pdf file. http://www.microsoft.com/downloads/details.aspx?FamilyID=4d951911-3e7e-4ae6-b059-a2e79ed87041&displaylang=enhttp://msdn.microsoft.com/en-us/library/kw65a0we(VS.80).aspx can help to automate word.Wednesday, April 29, 2009 4:40 AM
-
Hi, I had similar agenda, but I did not want the user to save the html document that he is currently looking and then convert it to PDF.
Here is what I did:
private void brnDownloadAsPDF_Click(object sender, EventArgs e) { WebClient client = new WebClient(); string url = GetCurrentUrl(); if (!string.IsNullOrEmpty(url)) { Stream stream = new MemoryStream(client.DownloadData(url)); DocumentModel.Load(stream, LoadOptions.HtmlDefault).Save("Report.pdf"); Process.Start("Report.pdf"); } }
I used WebClient to download the data from the specific URL.
I get the specific URL from the GetCurrentUrl method which uses the code from the following site: http://stackoverflow.com/questions/3579649/get-url-from-browser-to-c-sharp-application#3579900
It will enable you to retrieve the URL-s from the opened Internet Explorer and for my task I just added the following condition:
if (url.StartsWith(myDomain) && url.Contains(myParametars)) { // ... }
After I retrieve the HTML stream I used this C# Word component to convert HTML to PDF in C# and then show it to the user.
Regards,
Svendsen
- Edited by Svendsen A Tuesday, November 5, 2013 9:25 AM Message body to long...
Tuesday, November 5, 2013 9:25 AM