开发者

Render email messages to PS/PDF?

开发者 https://www.devze.com 2023-03-01 14:13 出处:网络
I\'m looking for a way to take a standard mail message (RFC 822 et. al) in a text file (say, from a mail spool or maildir), format it nicely, and output a postscript or PDF file suitable for printing.

I'm looking for a way to take a standard mail message (RFC 822 et. al) in a text file (say, from a mail spool or maildir), format it nicely, and output a postscript or PDF file suitable for printing. I'd prefer not to reinvent the wheel in terms of developing a pleasing layout, and I'm not familiar with PostScript or any graphics libraries an开发者_StackOverflowyway.

Are there any ready-made libraries or tools that can produce output similar to what most mail clients send to a printer? I've tried a couple of Linux command-line tools (like mp), but the output isn't very attractive.


You can solve your problem in two ways:

First:

Pass e-mail in "HTML Tidy" component or the "HTML Beautifier .Net" for the formatting and cleanup, and then convert with the "PDF Metamorphosis .Net"(www.sautinsoft.net).

Your HTML -> filter, clean up, modify HTML -> convert -> Your PDF

Second way:

Immediately send a message to "PDF Metamorphosis" for the converting to pdf.

Your HTML -> convert -> Your PDF

For example:

SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
string inputFile = @"С:\email.html";
string outputFile = @"С:\email.pdf";

int result = p.HtmlToPdfConvertFile(inputFile, outputFile);

if (result == 0)
{
    System.Console.WriteLine("Converted successfully!");
    System.Diagnostics.Process.Start(outputFile);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消