建议收藏!Java 中的文档查看器大盘点!

文档管理和共享已成为各个行业的重要方面。Java 提供了强大的框架,使开发人员能够构建功能丰富的应用程序。在这篇博文中,我们将探讨 Java 中的文档查看器以及它如何简化文档查看和协作流程。

Aspose API支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

文档查看器是一个应用程序,允许用户查看不同类型的文档并与之交互,而无需安装专用软件。Aspose提供对不同文件格式的支持,使您能够在 Java 应用程序中操作和查看文档。

Java 中的 EPS 文档查看器

Aspose.Page for Java API 可用于操作或转换 XPS、PS、EPS 等。您可以将这些文件格式渲染为任何流行的图像格式,如 PNG、JPG、TIFF 等,以便快速查看文件内容。

// initialize PostScript input stream
FileInputStream psStream = new FileInputStream("input.eps");

// load EPS document
PsDocument document = new PsDocument(psStream);

//create an instance of JpegSaveOptions
JpegSaveOptions options = new JpegSaveOptions();
//create rendering device for EPS format
ImageDevice device = new ImageDevice();
//save EPS as JPG
document.save(device, options);

Java 中的 DWG 绘图文档查看器

使用Aspose.CAD for Java可以轻松地将 DWG 绘图转换为 JPG 图像。输出图像可以在任何设备或操作系统上查看,无需任何专用软件。只需使用以下代码片段即可在 Java 中将 DWG 转换为 JPG 图像:

// Load input DWG file
Image image = Image.load("Test.dwg");

// Create an instance of CadRasterizationOptions
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

// Set page width & height
rasterizationOptions.setPageWidth(1200);
rasterizationOptions.setPageHeight(1200);

// Create an instance of JpegOptions for the resultant image
ImageOptionsBase options = new JpegOptions();

// Set rasterization options
options.setVectorRasterizationOptions(rasterizationOptions);

// Convert CAD DWG DXF file to JPG image
image.save("output_image.jpg" , options);

Java 中的 PUB Publisher 文档查看器

Java 中的 PUB 查看器可以开启高效处理 Microsoft Publisher 文件的无限可能。使用Aspose.PUB for Java,您可以创建功能强大的 PUB 查看器,使您能够无缝查看、导航 .pub 文件并与之交互。下面的代码片段展示了如何用 Java 创建 PUB Viewer:

// Load input PUB file
IPubParser parser = PubFactory.createParser("Test.pub");
Document doc = parser.parse();

// Convert PUB to PDF file
PubFactory.createPdfConverter().convertToPdf(doc, "Test.pdf");

// Load the PDF file
Document document = new Document("Test.pdf");
facades.PdfFileInfo info = new facades.PdfFileInfo(document);
for (Page page : document.getPages())
{
// Get page dimensions from the PDF document
int width = (int) info.getPageWidth(page.getNumber());
int height = (int) (info.getPageHeight(page.getNumber()));

// Set resolution for the output image
devices.Resolution resolution = new devices.Resolution(300);

// Create JPEG device with specified Width and Height
devices.JpegDevice jpegDevice = new devices.JpegDevice(width, height , resolution);

// Convert PUB to JPG image
jpegDevice.process(page, "Page" + page.getNumber() + ".jpg");
}

Java 中的 PSD Photoshop 文档查看器

您可以使用 Java 创建 PSD 查看器来轻松查看和使用 .psd 文件。以下代码片段演示了如何使用 [Aspose.PSD for Java]在 Java 中创建 PSD 查看器。

import com.aspose.psd.Image;
import com.aspose.psd.License;
import com.aspose.psd.fileformats.psd.PsdImage;
import com.aspose.psd.imageoptions.JpegOptions;

public class PSDToJPG {
public static void main(String[] args) throws Exception {

String path= "/Users/Documents/KB/TestData/";
// Apply the API license to convert PSD to JPEG
License psdLicence = new License();
psdLicence.setLicense(path + "Conholdate.Total.Product.Family.lic");

//Load a PSD file into PsdImage object
PsdImage psdFile = (PsdImage)Image.load(path + "AllAdjustments.psd");

// Set the desired output JPEG options
JpegOptions jpegOpts = new JpegOptions();
jpegOpts.setQuality(80);
jpegOpts.setJpegLsAllowedLossyError (10);

// Save the exported JPG on the disk
psdFile.save(path + "ConvertedPsd.jpg", jpegOpts);
}
}

然而,下面的列表编译了 Java 中 PSD 文档查看器的一些功能:

  • PSD 文件打开和查看:打开 PSD 文件并准确显示其内容,同时提供用户友好的界面。
  • 缩放:您可以放大或缩小 PSD 文件内容。
  • 导出和保存选项:PSD 查看器主要侧重于查看 PSD 文件并与之交互,它还提供导出或保存选项。
  • 还有很多…

Java 中的 LaTeX 文档查看器

在科学和学术写作领域,LaTeX已成为创建精美排版文档的事实上的标准。您可以将 LTX 或 TeX 文件渲染为图像以预览其内容,而无需任何专门的软件或插件。以下示例代码展示了如何在 Java 中将 LaTeX 文件转换为 PNG 图像:

// Create conversion options for Object LaTeX format on Object TeX engine extension.
TeXOptions options = TeXOptions.consoleAppOptions(TeXConfig.objectLaTeX());

// Specify the file system working directory for the output.
options.setOutputWorkingDirectory(new OutputFileSystemDirectory(Utils.getOutputDirectory()));

// Initialize the options for saving in JPG format.
options.setSaveOptions(new JpegSaveOptions());

// Run LaTeX to JPG conversion.
new TeXJob(Utils.getInputDirectory() + "helloworld.ltx", new ImageDevice(), options).run();

在线文档查看器

在线文档查看器彻底改变了我们与文档交互的方式。它们提供了多种优势,从可访问性和简化的管理到轻松的协作和增强的安全性。采用这些数字工具可以让个人和企业利用便利和高效的力量。您可以访问在线文档查看器,从任何设备或操作系统打开和查看文件。

aspose在线文档查看

猜你喜欢

转载自blog.csdn.net/m0_67129275/article/details/131910730