Other managing TeX options | Java

How to set the interaction mode

As we mentioned here, Aspose.TeX for Java allows us to set the initial interaction mode in which the engine starts. Here’s how we do it:

1// Create conversion options instance.
2...
3// Set the interaction mode.
4options.setInteraction(Interaction.NonstopMode);

How to set the job name

When we pass the main input file as a file name, we get output files with the same name, although with other extensions. The TeX engine calls the input file’s name the job name and uses it for output files, except in cases when auxiliary files with explicitly specified other names are written. When we pass the main input file as a stream, the TeX engine uses the default job name, which is texput. In both cases, we can override the job name by assigning the appropriate conversion option.

1// Create conversion options instance.
2...
3// Set the job name.
4options.setJobName("my-job-name");

How to “stop time”

LaTeX has a feature to automatically generate a title from some definitions in the preamble. This title normally contains the current date. We may wish to freeze the date in some desired value. Here’s how it can be done:

1// Create conversion options instance.
2...
3// Force the TeX engine to output the specified date in the title.
4options.setDateTime(new GregorianCalendar(2022, Calendar.DECEMBER, 18).getTime());

How to ignore missing packages

We may want to convert a LaTeX file that references some packages that are not supported by the Aspose.TeX for .NET library. In this case, the TeX engine will halt with an error when trying to load such a package. To avoid this, we can use the following option:

1// Create conversion options instance.
2...
3// Set to true to make the engine skip missing packages (when your file references one) without errors.
4options.ignoreMissingPackages(true);

How to avoid building ligatures

Normally, the TeX engine builds ligatures for certain pairs of characters if the font provides the data required to do so. We can instruct the engine to skip ligature building with the following code:

1// Create conversion options instance.
2...
3// Set to true to make the engine not construct ligatures where normally it would.
4options.noLigatures(true);

How to repeat the job

As we have mentioned above regarding labels and references, there are cases when we may want to run the same job twice. Here is how it can be done:

1// Create conversion options instance.
2...
3// Ask the engine to repeat the job.
4options.repeat(true);

How to turn math formulas to raster images

Sometimes we may need to have math formulas as raster images rather than typed in fonts. The following option can serve for this purpose:

1// Create conversion options instance.
2...
3// Create and assign saving options instance if needed.
4...
5// Set to true if you want math formulas to be converted to raster images.
6options.getSaveOptions().rasterizeFormulas(true);

How to turn graphics to raster images

The ObjectTeX engine allows us to include graphic files in raster formats (PNG and JPG) as well as PS(EPS) and XPS(OXPS) formats. The last two formats usually contain vector elements and texts. To have them rasterized and included as solid images, we can use the following option:

1// Create conversion options instance.
2...
3// Create and assign saving options instance if needed.
4...
5// Set to true if you want included graphics (if it contains vector elements) to be converted to raster images.
6options.getSaveOptions().rasterizeIncludedGraphics(true);

How to subset fonts

In case we want to reduce the size of the output file, we can resort to font subsetting, which means that the fonts in the output document will only contain data about the glyphs that are used in the document. Here’s how we can solve this:

1// Create conversion options instance.
2...
3// Create and assign saving options instance if needed.
4...
5// Set to true to make the device subset fonts used in the document.
6options.getSaveOptions().subsetFonts(true);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.