TEST.zip (22.4 KB)
我正在测试java的email和pdf,但是发现加载源文件的时间特别长,41K文件要等5,6分钟,附件为源文件,麻烦测试一下,下面是我的部分代码:
static void EmailToPdf(String emailPath) throws Exception
{
try {
com.aspose.email.License emlLicense = new com.aspose.email.License() ;
// File filicenseFilele = new File(dataDir + “Aspose.Total.Java.lic”);
// emlLicense.setLicense(licenseFile);
FileInputStream fstream=new FileInputStream(emailPath);
MailMessage eml = MailMessage.load(fstream);
//Save the Message to output stream in MHTML format
ByteArrayOutputStream emlStream = new ByteArrayOutputStream();
eml.save(emlStream, SaveOptions.getDefaultMhtml());
//Load the stream in Word document
LoadOptions lo = new LoadOptions();
lo.setLoadFormat(LoadFormat.MHTML);
com.aspose.words.Document doc = new com.aspose.words.Document(new ByteArrayInputStream(emlStream.toByteArray()), lo);
//Save to disc
doc.save("2222.Pdf", SaveFormat.PDF);
//or Save to stream
ByteArrayOutputStream foStream = new ByteArrayOutputStream();
doc.save(foStream, SaveFormat.PDF);
}catch(Exception ex) {
throw new Exception(ex.getMessage());
}