TeX to PNG
Convert TeX to PNG via API Solution for Java
How to Convert TeX to PNG Using Java
Aspose.TeX for TeX to PNG converter transforms a TeX file to PNG using the Java programming language.
The API presented here can be used to create your own cross-platform application or integrated into your Java project.
In order to convert TeX to PNG:
- Use the Aspose.TeX for Java API, which is a feature-rich, powerful and easy-to-use document processing and conversion API for Java platform.
- You can download its latest version directly from Aspose Maven Repository and install it within your Maven-based project by adding the following configurations to the pom.xml:
Repository
<repository>
<id>snapshots</id>
<name>repo</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-tex</artifactId>
<version>21.4</version>
</dependency>
Steps of the TeX to PNG Conversion in Java
Aspose.TeX makes it easy for the developers to transform TeX files to PNG in just a few lines of code.
- Create an object of the TeXOptions class.
- To set the space, or area, where TeX output will be written, set the file system working directory for the output using the OutputWorkingDirectory property.
- Initialize save options for the PNG format using the PngSaveOptions class.
- Create an object of the TeXJob class and run the LaTeX to PNG conversion using the run() method.
System Requirements
Aspose.TeX for Java is supported on all major operating systems. Just make sure that you have the following prerequisites:
- J2SE 8.0 (1.8) or above.
// Create conversion options for Object TeX format on Object TeX engine extension.
TeXOptions options = TeXOptions.consoleAppOptions(TeXConfig.objectTeX());
// Specify the file system working directory for the output.
options.setOutputWorkingDirectory(new OutputFileSystemDirectory(Utils.getOutputDirectory()));
// Initialize the options for saving in PNG format.
options.setSaveOptions(new PngSaveOptions());
// Run TeX to PNG conversion.
new TeXJob(Utils.getInputDirectory() + "hello-world.tex", new ImageDevice(), options).run();
TeX What is TeX File Format
TeX is not actually a format. It is both a programming language and also an interpreter engine that understands this language. A TeX file is a plain text file created using TeX syntax to be converted to some target format by being processed by a TeX engine. This output document may include graphics, tables, lists, formulas, and equations.
PNG What is PNG File Format
Portable Network Graphics or PNG is one of the most popular image formats. It gives you really good compression maintaining the high level of quality of the picture. PNG is also one of the best formats for web projects, as the files are lighter and images are easy to scale. One drawback of the format when used on the web is that it is not possible to add keywords to the image directly.