[poppler] Branch 'poppler-0.12' - 6 commits - goo/GooString.cc poppler/Parser.cc poppler/PDFDoc.cc test/pdf-fullrewrite.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Fri Oct 2 13:06:00 PDT 2009
goo/GooString.cc | 4 ++--
poppler/PDFDoc.cc | 16 ++++++++++++++--
poppler/Parser.cc | 5 +++++
test/pdf-fullrewrite.cc | 3 ++-
4 files changed, 23 insertions(+), 5 deletions(-)
New commits:
commit 0137b0f0dc0dac6f92b076c0aa9210f842991bd5
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Oct 2 22:04:46 2009 +0200
Strings can have 0 inside so use the length
Fixes saving some files
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index c723bd7..f1f1a8f 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -684,7 +684,7 @@ void PDFDoc::writeString (GooString* s, OutStream* outStr)
} else {
const char* c = s->getCString();
outStr->printf("(");
- while(*c!='\0') {
+ for(int i=0; i<s->getLength(); i++) {
char unescaped = (*c)&0x000000ff;
//escape if needed
if (unescaped == '(' || unescaped == ')' || unescaped == '\\')
commit 05be1252cd551ad6e9bad0cebe27c40b48f9e45f
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Oct 2 22:04:03 2009 +0200
Increase decimals from 5 to 10, a double has that precision
Makes saving more faithful for some files
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index d76b885..c723bd7 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -716,7 +716,7 @@ Guint PDFDoc::writeObject (Object* obj, Ref* ref, OutStream* outStr)
case objReal:
{
GooString s;
- s.appendf("{0:.5g}", obj->getReal());
+ s.appendf("{0:.10g}", obj->getReal());
outStr->printf("%s ", s.getCString());
break;
}
commit 456020775e7c322abd2bcc6c9fd3ec6e594afc93
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Oct 2 22:03:40 2009 +0200
If the stream was wrongly formed save the correct length
Fixes saving of some files
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 4279b33..d76b885 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -771,6 +771,18 @@ Guint PDFDoc::writeObject (Object* obj, Ref* ref, OutStream* outStr)
obj1.free();
} else {
//raw stream copy
+ FilterStream *fs = dynamic_cast<FilterStream*>(stream);
+ if (fs) {
+ BaseStream *bs = fs->getBaseStream();
+ if (bs) {
+ Guint streamEnd;
+ if (xref->getStreamEnd(bs->getStart(), &streamEnd)) {
+ Object val;
+ val.initInt(streamEnd - bs->getStart());
+ stream->getDict()->set("Length", &val);
+ }
+ }
+ }
writeDictionnary (stream->getDict(), outStr);
writeRawStream (stream, outStr);
}
commit 8bcac03940cb401df98649f52835043da8a8d4c2
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Oct 2 22:02:13 2009 +0200
Return the save status as program status
diff --git a/test/pdf-fullrewrite.cc b/test/pdf-fullrewrite.cc
index 89511f0..9658e55 100644
--- a/test/pdf-fullrewrite.cc
+++ b/test/pdf-fullrewrite.cc
@@ -37,9 +37,10 @@ int main (int argc, char *argv[])
}
- doc->saveAs(outputName, writeForceRewrite);
+ int res = doc->saveAs(outputName, writeForceRewrite);
delete doc;
delete globalParams;
delete outputName;
+ return res;
}
commit a9db687d598e75f0046b9b27f9b0c4718f25b248
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Oct 2 22:01:45 2009 +0200
If the Length entry of the stream is wrong, fix it
Fixes saving some files
diff --git a/poppler/Parser.cc b/poppler/Parser.cc
index b531233..05fba86 100644
--- a/poppler/Parser.cc
+++ b/poppler/Parser.cc
@@ -215,6 +215,11 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
shift();
}
length = lexer->getPos() - pos;
+ if (buf1.isCmd("endstream")) {
+ obj.initInt(length);
+ dict->dictSet("Length", &obj);
+ obj.free();
+ }
} else {
// When building the xref we can't use it so use this
// kludge for broken PDF files: just add 5k to the length, and
commit 0712c2e37066813805d321d78c3ac5facbe2a092
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Oct 2 22:00:12 2009 +0200
increase the range of characters we sanitize
Fixes saving of some files
diff --git a/goo/GooString.cc b/goo/GooString.cc
index 6105966..0d4cb73 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -789,11 +789,11 @@ GooString *GooString::sanitizedName(GBool psmode)
for (i = 0; i < getLength(); ++i) {
c = getChar(i);
- if ((psmode && (c <= (char)0x20 || c >= (char)0x7f)) ||
+ if (c <= (char)0x20 || c >= (char)0x7f ||
c == ' ' ||
c == '(' || c == ')' || c == '<' || c == '>' ||
c == '[' || c == ']' || c == '{' || c == '}' ||
- c == '/' || c == '%') {
+ c == '/' || c == '%' || c == '#') {
sprintf(buf, "#%02x", c & 0xff);
name->append(buf);
} else {
More information about the poppler
mailing list