Free Java Email Library to Convert EML & MSG to PDF
Open Source Java Email Processing Library for Converting Email Files (EML, MSG) to PDF. It Supports Handling Attachments and Inline Images and Multiple Email Formats inside Java apps.
Email-to-PDF Converter คืออะไร?
ในสภาพแวดล้อมการทำงานดิจิทัลสมัยใหม่ ความสามารถในการแปลงการสื่อสารทางอีเมลให้เป็นเอกสาร PDF ที่ถาวรและพกพาได้กลายเป็นสิ่งที่มีคุณค่ามากขึ้นเรื่อย ๆ Email-to-PDF Converter (เดิมชื่อ EML to PDF Converter) เป็นไลบรารี Java ที่หลากหลายซึ่งแก้ปัญหานี้โดยตรง พร้อมให้บริการบน GitHub เครื่องมือโอเพนซอร์สนี้มอบวิธีที่เชื่อถือได้ให้กับนักพัฒนาและองค์กรในการแปลงไฟล์อีเมล (.eml และ .msg) ให้เป็นเอกสาร PDF ระดับมืออาชีพที่คงรูปแบบ ไฟล์แนบ และเมตาดาต้าไว้ครบถ้วน
Email to PDF Converter เป็นเครื่องมือที่พัฒนาด้วย Java ที่แปลงไฟล์อีเมลให้เป็น PDF พร้อมคงรูปแบบ รูปภาพในบรรทัด และไฟล์แนบไว้เดิม พัฒนาโดย Nick Russler โครงการที่ใช้ใบอนุญาต Apache นี้มีโหมดการใช้งานสามแบบที่แตกต่างกัน: เป็นไลบรารี Java สำหรับการบูรณาการในแอปพลิเคชัน, เป็นยูทิลิตี้บรรทัดคำสั่งสำหรับการประมวลผลเป็นชุด, และเป็นแอปพลิเคชันเดสก์ท็อปพร้อมอินเทอร์เฟซกราฟิก ไลบรารีจัดการกระบวนการซับซ้อนของการวิเคราะห์โครงสร้างอีเมล ทำความสะอาดหัว MIME ที่ผิดรูปแบบ แปลงเนื้อหาเป็น HTML และสุดท้ายเรนเดอร์เป็น PDF ด้วยเครื่องมือเรนเดอร์ wkhtmltopdf ที่ทรงพลัง
เริ่มต้นใช้งาน Email-to-PDF Converter
ก่อนใช้ Email-to-PDF Converter ให้ตรวจสอบว่าคุณมีสภาพแวดล้อมรันไทม์ของ Java และ wkhtmltopdf เวอร์ชันล่าสุดพร้อมใช้งาน รุ่นล่าสุดสามารถดาวน์โหลดได้จากที่เก็บบน GitHub รวมถึงตัวติดตั้ง windows setup.exe และไฟล์ JAR ที่ทำงานได้บนทุกแพลตฟอร์ม
Install Email-to-PDF Converter Library via GitHub
git clone https://github.com/nickrussler/email-to-pdf-converter.git คุณสามารถดาวน์โหลดไลบรารีโดยตรงจากหน้า GitHub
การแปลงไฟล์อีเมลอัจฉริยะเป็น PDF ด้วย Java
TThe Email to PDF Converter library provides a comprehensive solution for transforming email files into universally accessible PDF documents inside Java apps. At its core, the library parses email MIME structures and converts them into clean, well-formatted HTML before PDF generation. This approach ensures that complex email layouts, styled text, and embedded elements render correctly in the final document. This basic example takes an EML file and converts it to PDF using default settings. The library handles all the complexity of parsing the email structure, extracting inline content, and generating the final PDF.
How to Convert EML Email File to PDF Documents via Java Library?
import mimeparser.MimeMessageConverter;
import java.io.File;
public class EmailConverterExample {
public static void main(String[] args) {
try {
File emailFile = new File("example.eml");
File outputPdf = new File("output.pdf");
// Perform the conversion
MimeMessageConverter.convertToPdf(emailFile, outputPdf);
System.out.println("Conversion completed successfully!");
} catch (Exception e) {
System.err.println("Error during conversion: " + e.getMessage());
e.printStackTrace();
}
}
}
จัดการไฟล์แนบระหว่างการแปลงอีเมลเป็น PDF ด้วย Java
The Email-to-PDF Converter library has provided options for extracting email attachments separately. Users can configure whether to extract attachments to a dedicated directory and optionally include a list of attachment names within the PDF document itself. The following code example demonstrates how to parse an email message separately from the conversion process, allowing for inspection or modification of email content before PDF generation. The ConversionOptions object provides programmatic access to all configuration parameters available in the command-line interface.
How Manage Attachments during Email to PDF Conversion via Java?
import mimeparser.MimeMessageConverter;
import mimeparser.MimeMessageParser;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
public class AttachmentHandler {
public static void main(String[] args) {
try {
File emailFile = new File("email-with-attachments.eml");
// Parse the email
MimeMessageParser parser = new MimeMessageParser();
parser.parse(new FileInputStream(emailFile));
// Access attachment information
List attachments = parser.getAttachmentList();
System.out.println("Found " + attachments.size() + " attachments:");
for (File attachment : attachments) {
System.out.println("- " + attachment.getName());
}
// Convert with attachment extraction
ConversionOptions options = new ConversionOptions();
options.setExtractAttachments(true);
options.setAddAttachmentNames(true);
MimeMessageConverter.convertToPdf(
parser,
new File("output-with-attachments.pdf"),
options
);
} catch (Exception e) {
e.printStackTrace();
}
}
}
การสนับสนุนหลายรูปแบบอีเมล
The Email-to-PDF Converter supports both EML and MSG file formats, making it compatible with various email clients. EML files are standard text-based email formats used by many email applications, while MSG files are Microsoft Outlook's proprietary email format. This dual-format support ensures flexibility across different email ecosystems.
การจัดการรูปภาพในบรรทัดขณะส่งออกอีเมลเป็น PDF
One of the standout features is proper handling of inline images embedded within email bodies. The open source Email-to-PDF Converter library correctly identifies and processes these images, ensuring they appear in the appropriate locations within the PDF output rather than as separate attachments.