Đây là một giải pháp chuyên nghiệp để nén EPUB bằng Java. Sử dụng EPUB API tối ưu hóa của chúng tôi để tạo phần mềm di động, mạnh mẽ và an toàn trong Java. Hãy thử nó trực tuyến miễn phí!
Chúng tôi hiện không chấp nhận tệp DOCX làm đầu vào. Nhưng chúng tôi có thể sản xuất các tệp DOCX như một sự bổ sung. Chúng tôi mong muốn được ủng hộ DOCX đầy đủ trong thời gian sắp tới.
Thư viện Java là một giải pháp độc lập và không yêu cầu cài đặt bất kỳ phần mềm bên thứ ba nào.
Thu nhỏ tệp DOCX mà không làm giảm chất lượng. Thư viện Java cung cấp cho các nhà phát triển một API tích hợp để tối ưu hóa nội dung DOCX. Tối ưu hóa DOCX xảy ra bằng cách nén hình ảnh bên trong tệp DOCX, cũng như bằng cách xóa dữ liệu không sử dụng.
Việc nén không mất dữ liệu điện tử và tối ưu hóa nội dung trở nên dễ dàng với 'Aspose.Words for Java'. Ví dụ sau minh họa cách tối ưu hóa nội dung của tệp DOCX trong Java:
// Repository path: https://releases.aspose.com/java/repo/
// Maven, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>ver</version>
<classifier>jdk17</classifier>
</dependency>
Sao chép
// Repository path: https://releases.aspose.com/java/repo/
// Gradle, where 'ver' - Aspose.Words version number, for example, 24.4.
compile(group: 'com.aspose', name: 'aspose-words', version: 'ver', classifier: 'jdk17')
Sao chép
// Repository path: https://releases.aspose.com/java/repo/
// Ivy, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency org="com.aspose" name="aspose-words" rev="ver">
<artifact name="aspose-words" m:classifier="jdk17" ext="jar"/>
</dependency>
Sao chép
// Repository path: https://releases.aspose.com/java/repo/
// Sbt, where 'ver' - Aspose.Words version number, for example, 24.4.
libraryDependencies += "com.aspose" % "aspose-words" % "ver"
Sao chép
import com.aspose.words.*;
Document doc = new Document("Input.docx");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage)
{
// Tùy nhà phát triển chọn thư viện để nén ảnh.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Nén hình ảnh và đặt nó trở lại hình dạng.
shape.getImageData().setImage("yourCompressedImage");
}
}
doc.save("Output.epub");
import com.aspose.words.*;
Document doc = new Document("Input.docx");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage())
{
// Tùy nhà phát triển chọn thư viện để nén ảnh.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Nén hình ảnh và đặt nó trở lại hình dạng.
shape.getImageData().setImage("yourCompressedImage");
}
}
OoxmlSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setCacheBackgroundGraphics(true);
doc.save("Output.epub", saveOptions);
import com.aspose.words.*;
Document doc = new Document("Input.docx");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage)
{
// Tùy nhà phát triển chọn thư viện để nén ảnh.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Nén hình ảnh và đặt nó trở lại hình dạng.
shape.getImageData().setImage("yourCompressedImage");
}
}
doc.save("Output.epub");
import com.aspose.words.*;
Document doc = new Document("Input.docx");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage())
{
// Tùy nhà phát triển chọn thư viện để nén ảnh.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Nén hình ảnh và đặt nó trở lại hình dạng.
shape.getImageData().setImage("yourCompressedImage");
}
}
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompressionLevel(CompressionLevel.MAXIMUM);
doc.save("Output.epub", saveOptions);
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertImage("Input.docx");
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.DOCX);
shape.getShapeRenderer().save("Output.epub", saveOptions);
Chúng tôi lưu trữ các gói Java trong kho Maven. 'Aspose.Words dành cho Java' là một JAR phổ biến chứa mã byte. Vui lòng làm theo hướng dẫn từng bước về cách cài đặt nó vào môi trường nhà phát triển Java của bạn.
Java SE 7 và Java phiên bản Java mới hơn được hỗ trợ. Chúng tôi cũng cung cấp một gói riêng cho Java SE 6 trong trường hợp bạn bắt buộc phải sử dụng JRE lỗi thời này.
Java của chúng tôi đa nền tảng và chạy trên tất cả các hệ điều hành có JVM, bao gồm Microsoft Windows, Linux, macOS, Android và iOS.
Để biết thông tin về các gói phụ thuộc tùy chọn, chẳng hạn như JogAmp JOGL, công cụ phông chữ Harfbuzz Java Advanced Imaging JAI, vui lòng tham khảo Tài liệu sản phẩm.