return pages;
}
+static void make_info_dict()
+{
+ // Create info dictionary if it did not exist yet
+ QPDFObjectHandle trailer = out_pdf.getTrailer();
+ QPDFObjectHandle info = trailer.getKey("/Info");
+ if (info.isNull())
+ {
+ info = QPDFObjectHandle::newDictionary();
+ trailer.replaceKey("/Info", info);
+ }
+ else
+ assert(info.isDictionary());
+
+ info.replaceKey("/Producer", unicode_string("PaperJam"));
+
+ // Copy entries from the source file's info dictionary
+ QPDFObjectHandle orig_trailer = in_pdf.getTrailer();
+ QPDFObjectHandle orig_info = orig_trailer.getKey("/Info");
+ if (!orig_info.isNull())
+ {
+ const string to_copy[] = { "/Title", "/Author", "/Subject", "/Keywords", "/Creator", "/CreationDate" };
+ for (string key: to_copy)
+ info.replaceOrRemoveKey(key, orig_info.getKey(key));
+ }
+}
+
void process(list<cmd *> &cmds)
{
debug("### Reading input");
}
// Produce info dictionary
- QPDFObjectHandle trailer = out_pdf.getTrailer();
- QPDFObjectHandle info = trailer.getKey("/Info");
- if (info.isNull())
- {
- info = QPDFObjectHandle::newDictionary();
- trailer.replaceKey("/Info", info);
- }
- else
- assert(info.isDictionary());
- // FIXME: More meta-data
- info.replaceKey("/Producer", unicode_string("PaperJam"));
+ make_info_dict();
// Write the output file
QPDFWriter writer(out_pdf, out_name);