Dinesh Sk
Dinesh Sk

Reputation: 1

PDF to image render issue with Mutool.exe (MuPdf by Artifex)

I am trying to convert a sample PDF file to image which contains a special PDF objects, so-called Optional Content Groups (OCGs), where I am getting an invalid conversion in gradient colors like pink color to a black or tint color in the result

I have tried the following command

public void ConvertPdfToImage(string pdfPath, int dpi, string fileName, bool isParticularPage = false, int PageNumber = 0)
{
    string command = "";
    if (isParticularPage)
    {
        command = $@"mutool.exe convert -O resolution={dpi} -o ""{fileName}"" ""{pdfPath}"" ""{PageNumber}""";
    }
    else
        command = $@"mutool.exe convert -O resolution={dpi} -o ""{fileName}"" ""{pdfPath}""";

    ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);

    procStartInfo.RedirectStandardOutput = true;
    procStartInfo.UseShellExecute = false;
    procStartInfo.CreateNoWindow = true;
    procStartInfo.RedirectStandardError = true;

    // wrap IDisposable into using (in order to release hProcess) 
    using (Process process = new Process())
    {
        process.StartInfo = procStartInfo;
        process.Start();

        // Add this: wait until process does its work
        process.WaitForExit();     
    }
}

I have got an invalid output image:

invalid output image

Expected image:

Expected image

Upvotes: 0

Views: 22

Answers (0)

Related Questions