I have an existing Web application which creates a dynamic HTML report with embedded JPG’s. The user wants the report to instead be generated in a PDF and/or Word format - but still show up in a browser screen using either a PDF or a Word add-in. Additionally, I need a batch process which runs on a schedule and emails these same reports as PDF and Word attachments to the users. It looks like the Aspose product line might do this, but I am unsure which products and how. Ideally I need a server-based solution which my existing web application would feed/stream HTML. If in interactive mode, the user would immediately see a pop-up of a PDF or Word report instead of the existing HTML screen. If in batch mode, the generated PDF and Word documents would be available to the batch process to be used as attachments to emails.
Hi,
Hi,
I am a representative of Aspose.Email.
My colleauge Nayyer has already guided you about how to convert HTML to PDF using Aspose.Pdf. Once you get your desired output file, you can use Aspose.Email for .NET for sending this file as an attachment in an email as follow:
//Create an instance of the MailMessage
class<o:p></o:p>
MailMessage message = new MailMessage();
//From field
message.From = “username@gmail.com”;
//To field
message.To.Add(“receiver@aspose.com”);
//Adding 1st attachment
//Create an instance of Attachment class
Attachment attachment;
//Load or add an attachment
attachment = new Attachment(@“phase 3 - billing timer records.pdf”);
//Now add the attachment to the message
message.Attachments.Add(attachment);
//Create an instance of the SmtpClient Class
//UseSmtp(message);
SmtpClient client = new SmtpClient();
client.Host = “smtp.gmail.com”;
//Specify your mail user name
client.Username = “username”;
//Specify your mail password
client.Password = “password”;
//Specify your Port #
client.Port = 587;
client.EnableSsl = true;
client.SecurityMode = SmtpSslSecurityMode.Explicit;
client.Send(message);
You can get more information about Aspose.Email by visiting our online documentation that contains a number of examples. If you have any additional query/inquiry related to Aspose.Email, please feel free to write to us by visiting the Aspose.Email forum. We’ll be glad to assist you further.
I appreciate the prompt responses. Just a couple of additional question for now: (1) In addition to PDF, I also need to build a Word document at the same time using the same HTML. Is the Aspose Word component what I need for that? Or can I go from HTML to PDF and then from PDF to Word using just the PDF product? (2) My HTML contains some embedded Javascript. Will that code get converted correctly? Thanks again.
Hi,
- First read the HTML
- Convert it to PDF format using Aspose.Pdf.Generator namespace
- Store the resultant file in Stream object
- Instantiate a new Document object from Stream
- Render the output in DOC format.
Will HTML code with embedded Javascript get converted properly?
Hi,
Hi there,
I am representative from Aspose.Words team.
Thanks for your inquiry. You can convert HTML document to Pdf and MS Word file formats by using Aspose.Words . Please use the following code snippet to convert html to Pdf/Doc/Docx file formats.
Document doc = new Document(MyDir + "Sample+2003.doc");
// Save html document to Pdf
doc.Save(MyDir + "Out.pdf", SaveFormat.Pdf);
// Save html document to Doc
doc.Save(MyDir + "Out.doc", SaveFormat.Doc);
// Save html document to Docx
doc.Save(MyDir + "Out.docx", SaveFormat.Docx);
Moreover, you can find formats of the document that can be loaded into Aspose.Words’ DOM from here:
http://www.aspose.com/docs/display/wordsnet/LoadFormat+Enumeration
Once html document is loaded into Aspose.Words’ DOM , you can save your html into other file format mentioned here:
http://www.aspose.com/docs/display/wordsnet/SaveFormat+Enumeration
Please read following documentation lik for your kind referece and let us know if you have any more queries.
http://www.aspose.com/docs/display/wordsnet/Loading%2C+Saving+and+Converting