Reconfig QPDF to ignore chatter on output

This commit is contained in:
Rick Falkvinge
2017-10-02 13:05:58 +02:00
parent 73c1e66a00
commit d06d74f927
2 changed files with 15 additions and 7 deletions
+7 -4
View File
@@ -176,7 +176,7 @@ namespace Swarmops.Frontend.Socket
process.WaitForExit();
if (process.ExitCode != 0)
if (process.ExitCode == 2)
{
// Bad PDF file
failCount++;
@@ -190,9 +190,12 @@ namespace Swarmops.Frontend.Socket
using (StreamReader pageCountReader = new StreamReader(pageCountFileName))
{
string pageCountString = pageCountReader.ReadToEnd().Trim();
debugWriter.WriteLine("{0:D2}%, page count is '{1}'", progress, pageCountString);
currentFilePageCount = Int32.Parse(pageCountString);
string line = pageCountReader.ReadLine().Trim();
while (line.StartsWith("WARNING") || line.StartsWith("qpdf:"))
{
line = pageCountReader.ReadLine().Trim(); // ignore warnings and chatter
}
currentFilePageCount = Int32.Parse(line);
debugWriter.WriteLine("{0:D2}%, parsed to int as {1}", progress, currentFilePageCount);
currentFilePageStepMilli = progressFileStep * 1000 / currentFilePageCount;
}
+8 -3
View File
@@ -283,7 +283,7 @@ namespace Swarmops.Frontend.Automation
process.WaitForExit();
int pdfPageCount = 0;
if (process.ExitCode != 0)
if (process.ExitCode == 2) // error code for qpdf
{
// Bad PDF file
FilesStatus errorStatus = new FilesStatus(fullName, -1); //file.ContentLength);
@@ -301,10 +301,15 @@ namespace Swarmops.Frontend.Automation
using (StreamReader pageCountReader = new StreamReader(pageCountFileName))
{
string pageCountString = pageCountReader.ReadToEnd().Trim();
pdfPageCount = Int32.Parse(pageCountString);
string line = pageCountReader.ReadLine().Trim();
while (line.StartsWith("WARNING") || line.StartsWith("qpdf:"))
{
line = pageCountReader.ReadLine().Trim(); // ignore warnings and chatter
}
pdfPageCount = Int32.Parse(line);
}
File.Delete(pageCountFileName);
if (pdfPageCount < 10)