Latex file is not converting properly (latex to pdf) in aspose total pdf

Lots of question marks are appearing in the text (see below) where reference is made to citationsimage-20230825-142658.png (141.2 KB)
code snippet:
String texFileName = getFileNameWithoutExtension(outputFileName) + TEX_EXTENSION;
String texFilePath = directoryPath + PATH_SEPARATOR + texFileName;
Files.copy(inputStream, Path.of(texFilePath), StandardCopyOption.REPLACE_EXISTING);
// Create Document object to load the LaTeX file
TeXLoadOptions teXLoadOptions = new TeXLoadOptions();
if(contentProcessWarning != null)
teXLoadOptions.setWarningHandler(new LatexToPdfWarningCallback(contentProcessWarning, actualFileName));
Document document = new Document(texFilePath, teXLoadOptions);
PdfPageEditor pageEditor = new PdfPageEditor();
pageEditor.bindPdf(document);
pageEditor.setPageSize(PageSize.getA4());
// Save to PDF
pageEditor.save(directoryPath + PATH_SEPARATOR + outputFileName);
pageEditor.close();

dependency:

com.aspose aspose-total 23.8 pom

@TandFSP

Can you please make sure that all fonts are properly installed in your system? In case issue still persists, please share your sample TEX file for our reference. We will test the scenario in our environment and address it accordingly.

hi @asad.ali Thanks for your reply. I’m unable to upload the .tex file here. any other way to upload my tex file here?

Hi @asad.ali. i have compressed the tex files as zip. Please check the samples.LETTER.tex.zip (2.5 KB)
ThermoAssim.tex.zip (16.5 KB)

please test the files and let me know the output. Thanks in advance.

@TandFSP

We were able to notice different issues in our environment while testing with 23.8 version of the API. For LETTER.tex file, output PDF was invalid and for other TEX file, there were question marks in the output.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55451,PDFNET-55452

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as PDFNET-55452) have been fixed in Aspose.PDF for .NET 23.9.

@TandFSP

Here are some notes about the sample .tex file:

  1. First of all, there is a problem with {}-grouping. As you can find, there is a { at the end of line 7, and if you trace the balance of the opening and closing braces, you will find that the corresponding } is on line 80. This is clearly unintended. The { should most likely occur on the same line 80 before the \em command to localize the effect of emphasizing. Moreover, this improper grouping suppresses the headings on each page.
  2. There are unicode characters on lines 629, 668-671. There’s no built-in support for unicode in LaTeX2e. And Aspose.TeX is based on LaTeX2e. To handle unicode charaters, the user would have to include the inputenc package with Unicode option in the document preamble. But this package maps unicode characters to non-standard bitmap fonts, which normally should be generated by the METAFONT program, which is closely related to TeX. There’s no implementation of METAFONT in Aspose.TeX. Thus, Unicode characters are a solid problem to the Aspose.TeX’s engine. But in the case of the sample document, there’s actually no real reason to use Unicode characters. It even looks like they were put there by mistake.
  3. The question marks in the output are actually unresolved references. If the user could understand what’s in the .log file, they wouldn’t be confused. Indeed, TeX cannot resolve cross-references at a single run. It needs to be run twice. A double run may be forced “manually” by repeating the same source code block, or by setting the Repeat TeX loading option to true.
  4. To collapse long sequences of references into ranges, the cite package is included in the document preamble (\usepackage{cite}). But since Aspose.TeX didn’t have built-in support for this package (until version 23.9), the user must provide the package executables along with the .tex file. As for Aspose.Pdf, the only way to do so is to place these executables into the input directory defined by the InputWorkingDirectory TeX loading option. Starting with the version 23.9, there is also the RequiredInputDirectory option that allows to specify an additional “input space” other than the InputWorkingDirectory.

Question marks instead of references don’t appear if TeXLoadOptions.Repeat property is set to true:

// Set Repeat to true to make second run and resolve cross-references
TeXLoadOptions Latexoptions = new TeXLoadOptions
{
    Repeat = true
}; 
// Create Document object
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + @"ThermoAssim.tex", Latexoptions); 
// Save the output in PDF file
doc.Save(dataDir + "ThermoAssim_out.pdf");

55452_review.pdf (312.2 KB)

Hi @aspose.notifier,

we are using Aspose total for java with version 23.8

com.aspose
aspose-total
23.8
pom

when will the fix be available in these versions of Java?

@TandFSP

The ticket was logged initially for .NET API. However, every fix in .NET API is included in the equivalent version of Aspose.PDF for Java. Therefore, the fix will be available in Aspose.PDF for Java as well. The target version is set to 23.10 however, we will let you know in case we have further updates.

Thanks, any ETA for Java 23.10?

@TandFSP

It will be released in October, 2023.

@TandFSP

We have investigated the above ticket. The attached LETTER.tex is not a LaTeX file. There is nothing of LaTeX at all. There’s just text. If you put the text from the file as a body into the following construction

\documentclass{article}
\begin{document}
% Body
\end{document}

you will get the valid output.