locked
Print HTML documents via .NET framework RRS feed

  • Question

  • User-1292065167 posted

    I hope someone can help me.

     

    We have HTML documents stored in a database table, and we use them to send emails, or view them on screen. In our application we add certain parameters to the HTML text before sending the email, e.g. Customer number, Due date etc. The HTML works great because we are able to format, add graphics etc., and is required for the emails.

     

    Some customers may want to get the documents in the post instead of as an email, so I would like to be able to print these same HTML documents. How can I do that?

    I need to be able to choose the queue I'm sending them to, as they often needs to be printed at a dedicated print facility in batch. The System.Printing namespace functionality looks great, but how do I add the HTML document to the Job? You could say that I would like to create the document in the print queue in the same way as I'm creating it in an AlternateView for a MailMessage.


    We are on .NET 3.5 using C#

    Thanks.

    Monday, December 1, 2008 10:11 AM

Answers

  • User-1136466523 posted

    Hi,

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    From your description, it seems that you want to print the html contents in the database, right?

    <o:p> </o:p>

    Basically, as one of the general way is rendering these html markup in a page, and invoke the built-in print function in browser. You can create a page, and it can refresh automatically, it requests for new html contents every time, and it render different html markup onto the page and call the printing function, send the print job to the printer.

    <o:p> </o:p>

    “it requests for new html contents every time” à How to achieve that? Actually you can add a new field in your datatable, add a flag which indicates if the record has been requested (printed), find those records with false flag and update the field to true while you get the record.

    <o:p> </o:p>

    Thanks.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2008 12:54 AM

All replies

  • User-1136466523 posted

    Hi,

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    From your description, it seems that you want to print the html contents in the database, right?

    <o:p> </o:p>

    Basically, as one of the general way is rendering these html markup in a page, and invoke the built-in print function in browser. You can create a page, and it can refresh automatically, it requests for new html contents every time, and it render different html markup onto the page and call the printing function, send the print job to the printer.

    <o:p> </o:p>

    “it requests for new html contents every time” à How to achieve that? Actually you can add a new field in your datatable, add a flag which indicates if the record has been requested (printed), find those records with false flag and update the field to true while you get the record.

    <o:p> </o:p>

    Thanks.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2008 12:54 AM
  • User-1292065167 posted

    Hi Michael

    Thank you very much for coming back to me.

    Do you know if there is a way to print it to a printer of my own choice. There is a need for the operation to manage printers and queues in a batch environment. For other print, e.g. of a word document saved as a PDF or XPS I can send it to the right queue, but I'm struggling with the HTML. 

    Thanks for the tip with the new column on the table. We are already working with a request table where rows are deleted after succesful execution, either via email or (hopefully) print, so that should be ok.

    Thanks

    Jan

    Friday, December 5, 2008 6:49 AM
  • User423518150 posted

    Hi Guys,,


    I am also facing the same problem.

    I have a html string (I have generated this using the ctrl.RenderControl()), I am using this string to send a mail. now i have to add print functionality too.

    So i am trying to use this same string to print it.

    I have tried with "PrintDocument" but its not supporting HTML string. its printing whole string as it is.

    So i want to ask you that how can i print HTMLstring  ?

    Please help me.


    Thank you

    Friday, March 5, 2010 5:10 AM