|
|
3587f3 |
--- a/utils/pdfunite.cc
|
|
|
3587f3 |
+++ b/utils/pdfunite.cc
|
|
|
3587f3 |
@@ -165,7 +165,9 @@ int main (int argc, char *argv[])
|
|
|
3587f3 |
for (i = 1; i < argc - 1; i++) {
|
|
|
3587f3 |
GooString *gfileName = new GooString(argv[i]);
|
|
|
3587f3 |
PDFDoc *doc = new PDFDoc(gfileName, nullptr, nullptr, nullptr);
|
|
|
3587f3 |
- if (doc->isOk() && !doc->isEncrypted()) {
|
|
|
3587f3 |
+ if (doc->isOk() && !doc->isEncrypted() &&
|
|
|
3587f3 |
+ (doc->getCatalog()->getPageRef(1) || gTrue) &&
|
|
|
3587f3 |
+ doc->getXRef()->getCatalog().isDict()) {
|
|
|
3587f3 |
docs.push_back(doc);
|
|
|
3587f3 |
if (doc->getPDFMajorVersion() > majorVersion) {
|
|
|
3587f3 |
majorVersion = doc->getPDFMajorVersion();
|
|
|
3587f3 |
@@ -176,8 +177,13 @@ int main (int argc, char *argv[])
|
|
|
3587f3 |
}
|
|
|
3587f3 |
}
|
|
|
3587f3 |
} else if (doc->isOk()) {
|
|
|
3587f3 |
- error(errUnimplemented, -1, "Could not merge encrypted files ('{0:s}')", argv[i]);
|
|
|
3587f3 |
- return -1;
|
|
|
3587f3 |
+ if (doc->isEncrypted()) {
|
|
|
3587f3 |
+ error(errUnimplemented, -1, "Could not merge encrypted files ('{0:s}')", argv[i]);
|
|
|
3587f3 |
+ return -1;
|
|
|
3587f3 |
+ } else if (!doc->getXRef()->getCatalog().isDict()) {
|
|
|
3587f3 |
+ error(errSyntaxError, -1, "XRef's Catalog is not a dictionary ('{0:s}')", argv[i]);
|
|
|
3587f3 |
+ return -1;
|
|
|
3587f3 |
+ }
|
|
|
3587f3 |
} else {
|
|
|
3587f3 |
error(errSyntaxError, -1, "Could not merge damaged documents ('{0:s}')", argv[i]);
|
|
|
3587f3 |
return -1;
|