Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4029418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:20:34+00:00 2026-05-20T11:20:34+00:00

I want to create a LaTeX editor to produce pdf documents. Behind the scene,

  • 0

I want to create a LaTeX editor to produce pdf documents.
Behind the scene, my application uses pdflatex.exe executed through a Process instance.

pdflatex.exe needs an input file, e.g., input.tex as follows

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\LaTeX\ is my tool.
\end{document}

For the sake of simplicity, here is the minimal c# codes used in my LaTeX editor:

using System;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Process p = new Process();

            p.EnableRaisingEvents = true;
            p.Exited += new EventHandler(p_Exited);

            p.StartInfo.Arguments = "input.tex";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.FileName = "pdflatex.exe";

            p.Start();
            p.WaitForExit();
        }

        static void p_Exited(object sender, EventArgs e)
        {
            // remove all auxiliary files, excluding *.pdf.
        }
    }
}

The question is

How to detect the pdflatex.exe whether it stops working due to an invalid input?

Edit

This is the final working solution:

using System;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Process p = new Process();

            p.EnableRaisingEvents = true;
            p.Exited += new EventHandler(p_Exited);

            p.StartInfo.Arguments = "-interaction=nonstopmode input.tex";// Edit
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.FileName = "pdflatex.exe";
            p.StartInfo.RedirectStandardError = true;
            p.Start();
            p.WaitForExit();

            //Edit
            if (p.ExitCode == 0)
            {
                Console.WriteLine("Succeeded...");
            }
            else
            {
                Console.WriteLine("Failed...");
            }
        }

        static void p_Exited(object sender, EventArgs e)
        {
            // remove all  files excluding *.pdf

            //Edit
            Console.WriteLine("exited...");
        }
    }
}

The idea using -interaction=nonstopmode belongs to @Martin here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:20:34+00:00Added an answer on May 20, 2026 at 11:20 am

    Most command-line applications set an exit code to indicate success or failure. You test it thus:

    p.WaitForExit();
    if (p.ExitCode == 0) {
        // Success
    } else {
        // Failure
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create something like a leaflet/magazine using Latex. Is it possible to
I want to create a command in mediawiki. For example, in latex I can
I want create an application with animate button? how can i do? after click
Let's say I want to create a new document, and cycle quickly through a
I want to create a lab write-up with LaTeX in Ubuntu, however my text
Imagine I want to create an application which is very similar to MS Word
I've created latex macro to typeset guitar chords diagrams(using picture environment). Now I want
i want create multiple search where statement $where_search is a multiple condition from post
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.