Aspose Tex to PDF support

Hello team,

We are working on converting tex file to pdf by following TEX to PDF Converter using Java | Aspose.PDF.

In our tex file, we are using some external tex dependent files as below
(CTAN: /tex-archive/macros/generic/epsf, CTAN: /tex-archive/macros/plain/contrib/harvmac) and few more.

and while running the code, we are getting error like,
I can’t find file `epsf.tex’.

Also we have some eps file as an input but it is missing in the converted pdf.

and this is same for other files as well. Could you please help us to resolve this ?

regards,
Shivanagouda

@shivanbgasp

To resolve the issue of missing external .tex files and EPS files during the conversion of your TeX file to PDF using Aspose, you can follow these steps:

  1. Ensure File Accessibility: Make sure that all external TeX files, such as epsf.tex, are accessible in the working directory specified in your conversion options. The Aspose TeX engine needs to locate these files to process them correctly.

  2. Set Working Directory: When configuring your conversion options, specify the output working directory where the Aspose TeX engine can find the required files. This can be done using the setOutputWorkingDirectory method in your code. For example:

    options.setOutputWorkingDirectory(new OutputFileSystemDirectory("path/to/your/working/directory"));
    
  3. Include EPS Files: If you have EPS files that are not appearing in the converted PDF, ensure that these files are also located in the specified working directory. The TeX engine needs to access these files during the conversion process.

  4. Check File Paths: Verify that the paths to your input TeX file and any external files are correct. Incorrect paths can lead to the engine being unable to find the necessary files.

  5. Example Code: Here is a simplified example of how to set up the conversion:

    import java.io.FileOutputStream;
    import java.io.IOException;
    import com.aspose.tex.OutputFileSystemDirectory;
    import com.aspose.tex.TeXConfig;
    import com.aspose.tex.TeXJob;
    import com.aspose.tex.TeXOptions;
    import com.aspose.tex.rendering.PdfDevice;
    import com.aspose.tex.rendering.PdfSaveOptions;
    
    public class TeXToPdfConversion {
        public static void main(String[] args) throws IOException {
            final OutputStream pdfStream = new FileOutputStream("output.pdf");
            try {
                TeXOptions options = TeXOptions.consoleAppOptions(TeXConfig.objectLaTeX());
                options.setOutputWorkingDirectory(new OutputFileSystemDirectory("path/to/your/working/directory"));
                options.setSaveOptions(new PdfSaveOptions());
                new TeXJob("path/to/your/input.tex", new PdfDevice(pdfStream), options).run();
            } finally {
                if (pdfStream != null) pdfStream.close();
            }
        }
    }
    

By ensuring that all necessary files are in the correct locations and that your working directory is properly set, you should be able to resolve the errors you are encountering during the conversion process.

If you continue to face issues, please provide additional details about the specific errors or behaviors you are observing.

Sources:
[1]: LaTeXPdfConversionAlternative.java

Hi,

Is it possible to download dependent file from Aspose registry or internet instead of adding files manually ?

regards,
Shivanagouda

Hi team,

Could you please update on this ticket ?

  1. Managing tex and other packages instead manually adding
  2. EPS files in pdf are rendering as empty.

Hi,

Please, provide us with your .tex and *.eps files to investigate the issue. Downloading dependent files from internet is possible by writing custom implementation of IInputWorkingDirectory as it is described here.