]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Added zero-page handling for texttopdf filter. 190/head
authorJaiLuthra1 <luthrajaiji@gmail.com>
Thu, 16 Jan 2020 11:07:37 +0000 (16:37 +0530)
committerJaiLuthra1 <luthrajaiji@gmail.com>
Thu, 16 Jan 2020 11:07:37 +0000 (16:37 +0530)
filter/textcommon.c

index 97a1a7cc5f51eb327d5f4e08cf7ae90720b0ddf9..1c937ccab17f7d08c30d8267288c0c95451d7a0d 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "textcommon.h"
 #include <limits.h>
+#include "pdfutils.h"
 
 
 /*
@@ -536,6 +537,21 @@ TextMain(const char *name, /* I - Name of filter */
     }
   }
 
+  fseek(fp, 0L, SEEK_END);
+  int size = ftell(fp);
+  fseek(fp, 0L, SEEK_SET);
+
+  if(size==0)
+  {
+       if(fp!=stdin)
+       fclose(fp);
+       pdfOut *pdf=pdfOut_new();
+       pdfOut_begin_pdf(pdf);
+       pdfOut_finish_pdf(pdf);
+       pdfOut_free(pdf);
+       return 0;
+  }
+
  /*
   * Process command-line options and write the prolog...
   */