I have two pdf with have Fonts whose Length2 is set to 0
This makes our exporting to PS generate wrong PS.
Any objection to committing this patch to both branches?
Albert
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index a111894..c18fb5f 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <signal.h>
#include <math.h>
+#include <limits.h>
#include "goo/GooString.h"
#include "goo/GooList.h"
#include "poppler-config.h"
@@ -1878,6 +1879,7 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
int c;
int start[4];
GBool binMode;
+ GBool writePadding = gTrue;
int i;
// check if font is already embedded
@@ -1949,6 +1951,17 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
binMode = gTrue;
}
+ if (length2 == 0)
+ {
+ // length2 == 0 is an error
+ // trying to solve it by just piping all
+ // the stream data
+ error(-1, "Font has length2 as 0, trying to overcome the problem reading the stream until the end");
+ length2 = INT_MAX;
+ writePadding = gFalse;
+ }
+
+
// convert binary data to ASCII
if (binMode) {
for (i = 0; i < 4; ++i) {
@@ -1987,12 +2000,15 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
}
}
- // write padding and "cleartomark"
- for (i = 0; i < 8; ++i) {
- writePS("00000000000000000000000000000000"
- "00000000000000000000000000000000\n");
+ if (writePadding)
+ {
+ // write padding and "cleartomark"
+ for (i = 0; i < 8; ++i) {
+ writePS("00000000000000000000000000000000"
+ "00000000000000000000000000000000\n");
+ }
+ writePS("cleartomark\n");
}
- writePS("cleartomark\n");
// ending comment
writePS("%%EndResource\n");
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler