这篇文章重点介绍如何在 Java 中将 MPP 转换为 TIFF。它包括所有配置详细信息、分步程序流程以及展示该功能的可运行示例代码。您可以借助简单的 API 调用轻松开发一个应用程序,以使用 Java **将 MPP 文件转换为 TIFF。
使用 Java 将 MPP 转换为 TIFF 的步骤
- 设置开发环境以包含 Aspose.Tasks for Java,使用存储库管理器使用 Java 将 MPP 转换为 TIFF
- 使用 Project 类对象加载现有 MPP 文件,以使用 Java 将 MPP 更改为 TIFF
- 使用 ImageSaveOptions 类对象设置输出 TIFF 文件选项
- Java中使用save方法将MPP保存为TIFF
上述步骤代表了完整的配置详细信息以及使用 Java 将 MS Project 转换为 TIFF* 的逐步过程。 Project 类实例用于从磁盘访问源 MPP 文件,然后 ImageSaveOptions 类实例用于设置输出 TIFF 文件特征。值得一提的是,TIFFOptions 类实例不是强制性的,可以通过使用输出 TIFF 文件的默认设置来排除。
在 Java 中将 MPP 保存为 TIFF 的代码
import com.aspose.tasks.ImageSaveOptions; | |
import com.aspose.tasks.License; | |
import com.aspose.tasks.PixelFormat; | |
import com.aspose.tasks.Project; | |
import com.aspose.tasks.SaveFileFormat; | |
public class MppToTiff { | |
public static void main(String[] args) throws Exception {// Handle exceptions to process the MPP file | |
String FilePath = "//Users//KB//TestData//"; | |
// Set the product license to Load and process the MPP file | |
License TasksLic = new License(); | |
TasksLic.setLicense(FilePath + "Conholdate.Total.Product.Family.lic"); | |
// Access the source MS MPP file from the disk | |
Project inputProject = new Project(FilePath + "Input.mpp"); | |
// Set the output Tiff image options | |
ImageSaveOptions tiffOpts = new ImageSaveOptions(SaveFileFormat.Tiff); | |
tiffOpts.setHorizontalResolution(72); | |
tiffOpts.setVerticalResolution(72); | |
tiffOpts.setPixelFormat(PixelFormat.Format24bppRgb); | |
// Convert the MPP to Tiff image file on the disk | |
inputProject.save(FilePath + "OutputTiff.tiff", tiffOpts); | |
} | |
} |
上面的示例提供了借助简单 API 接口使用 Java 将 MPP 转换为 TIFF 的代码。用于从磁盘访问源文件的 Project 类实例还公开构造函数重载,以从 Web 或数据库等源将 MPP 文件作为流加载。 ImageSaveOptions 类实例可用于通过使用 setEncoding、setIncludeHeaders、setDataCategory 和 setTextDelimiter 等 setter 方法来自定义输出 TIFF 文件。
在本文中,我们了解了使用 Java 将 MPP 更改为 TIFF 的过程。如果您想了解将 MPP 转换为 SVG 文件的过程,请参阅 在 Java 中将 MPP 转换为 PNG 上的文章。