Commit faa2e3ddfd7e5bfd0922deb49b9c88e8eee08fbd

Authored by Jay Berkenbilt
1 parent 81025e49

Handle older PDFs whose form XObjects inherit resources (fixes #494)

When removing unreferenced resources, notice if a page (recursively)
contains a form XObject with unreferenced resources, and count any
such resources as referenced by the page.
ChangeLog
  1 +2021-02-02 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Bug fix: if a form XObject lacks a resources dictionary,
  4 + consider any names in that form XObject to be referenced from the
  5 + containing page. This is compliant with older PDF versions. Also
  6 + detect if any form XObjects have any unresolved names and, if so,
  7 + don't remove unreferenced resources from them or from the page
  8 + that contains them. Fixes #494.
  9 +
1 10 2021-01-31 Jay Berkenbilt <ejb@ql.org>
2 11  
3 12 * Bug fix: properly handle strings if they appear in inline image
... ...
include/qpdf/QPDFPageObjectHelper.hh
... ... @@ -317,9 +317,9 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
317 317 void flattenRotation();
318 318  
319 319 private:
320   - static void
  320 + static bool
321 321 removeUnreferencedResourcesHelper(
322   - QPDFPageObjectHelper ph);
  322 + QPDFPageObjectHelper ph, std::set<std::string>& unresolved);
323 323  
324 324 class Members
325 325 {
... ...
libqpdf/QPDFPageObjectHelper.cc
... ... @@ -701,10 +701,16 @@ NameWatcher::handleToken(QPDFTokenizer::Token const&amp; token)
701 701 writeToken(token);
702 702 }
703 703  
704   -void
  704 +bool
705 705 QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
706   - QPDFPageObjectHelper ph)
  706 + QPDFPageObjectHelper ph, std::set<std::string>& unresolved)
707 707 {
  708 + bool is_page = (! ph.oh.isFormXObject());
  709 + if (! is_page)
  710 + {
  711 + QTC::TC("qpdf", "QPDFPageObjectHelper filter form xobject");
  712 + }
  713 +
708 714 NameWatcher nw;
709 715 try
710 716 {
... ... @@ -714,16 +720,17 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
714 720 {
715 721 ph.oh.warnIfPossible(
716 722 std::string("Unable to parse content stream: ") + e.what() +
717   - "; not attempting to remove unreferenced objects from this page");
718   - return;
  723 + "; not attempting to remove unreferenced objects"
  724 + " from this object");
  725 + return false;
719 726 }
720 727 if (nw.saw_bad)
721 728 {
722 729 QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names");
723 730 ph.oh.warnIfPossible(
724 731 "Bad token found while scanning content stream; "
725   - "not attempting to remove unreferenced objects from this page");
726   - return;
  732 + "not attempting to remove unreferenced objects from this object");
  733 + return false;
727 734 }
728 735  
729 736 // We will walk through /Font and /XObject dictionaries, removing
... ... @@ -733,6 +740,7 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
733 740 // of mutating the one it was copied from.
734 741 QPDFObjectHandle resources = ph.getAttribute("/Resources", true);
735 742 std::vector<QPDFObjectHandle> rdicts;
  743 + std::set<std::string> known_names;
736 744 if (resources.isDictionary())
737 745 {
738 746 std::vector<std::string> to_filter = {"/Font", "/XObject"};
... ... @@ -744,33 +752,86 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
744 752 dict = dict.shallowCopy();
745 753 resources.replaceKey(iter, dict);
746 754 rdicts.push_back(dict);
  755 + auto keys = dict.getKeys();
  756 + known_names.insert(keys.begin(), keys.end());
747 757 }
748 758 }
749 759 }
  760 +
  761 + std::set<std::string> local_unresolved;
  762 + for (auto const& name: nw.names)
  763 + {
  764 + if (! known_names.count(name))
  765 + {
  766 + unresolved.insert(name);
  767 + local_unresolved.insert(name);
  768 + }
  769 + }
  770 + // Older versions of the PDF spec allowed form XObjects to omit
  771 + // their resources dictionaries, in which case names were resolved
  772 + // from the containing page. This behavior seems to be widely
  773 + // supported by viewers. If a form XObjects has a resources
  774 + // dictionary and has some unresolved names, some viewers fail to
  775 + // resolve them, and others allow them to be inherited from the
  776 + // page or from another form XObjects that contains them. Since
  777 + // this behavior is inconsistent across viewers, we consider an
  778 + // unresolved name when a resources dictionary is present to be
  779 + // reason not to remove unreferenced resources. An unresolved name
  780 + // in the absence of a resource dictionary is not considered a
  781 + // problem. For form XObjects, we just accumulate a list of
  782 + // unresolved names, and for page objects, we avoid removing any
  783 + // such names found in nested form XObjects.
  784 +
  785 + if ((! local_unresolved.empty()) && resources.isDictionary())
  786 + {
  787 + QTC::TC("qpdf", "QPDFPageObjectHelper unresolved names");
  788 + ph.oh.warnIfPossible(
  789 + "Unresolved names found while scanning content stream; "
  790 + "not attempting to remove unreferenced objects from this object");
  791 + return false;
  792 + }
  793 +
750 794 for (auto& dict: rdicts)
751 795 {
752 796 for (auto const& key: dict.getKeys())
753 797 {
754   - if (! nw.names.count(key))
  798 + if (is_page && unresolved.count(key))
  799 + {
  800 + // This name is referenced by some nested form
  801 + // xobject, so don't remove it.
  802 + QTC::TC("qpdf", "QPDFPageObjectHelper resolving unresolved");
  803 + }
  804 + else if (! nw.names.count(key))
755 805 {
756 806 dict.removeKey(key);
757 807 }
758 808 }
759 809 }
  810 + return true;
760 811 }
761 812  
762 813 void
763 814 QPDFPageObjectHelper::removeUnreferencedResources()
764 815 {
  816 + // Accumulate a list of unresolved names across all nested form
  817 + // XObjects.
  818 + std::set<std::string> unresolved;
  819 + bool any_failures = false;
765 820 forEachFormXObject(
766 821 true,
767   - [](
  822 + [&any_failures, &unresolved](
768 823 QPDFObjectHandle& obj, QPDFObjectHandle&, std::string const&)
769 824 {
770   - QTC::TC("qpdf", "QPDFPageObjectHelper filter form xobject");
771   - removeUnreferencedResourcesHelper(QPDFPageObjectHelper(obj));
  825 + if (! removeUnreferencedResourcesHelper(
  826 + QPDFPageObjectHelper(obj), unresolved))
  827 + {
  828 + any_failures = true;
  829 + }
772 830 });
773   - removeUnreferencedResourcesHelper(*this);
  831 + if (this->oh.isFormXObject() || (! any_failures))
  832 + {
  833 + removeUnreferencedResourcesHelper(*this, unresolved);
  834 + }
774 835 }
775 836  
776 837 QPDFPageObjectHelper
... ...
manual/qpdf-manual.xml
... ... @@ -4889,6 +4889,16 @@ print &quot;\n&quot;;
4889 4889 <itemizedlist>
4890 4890 <listitem>
4891 4891 <para>
  4892 + If a form XObject lacks a resources dictionary, consider any
  4893 + names in that form XObject to be referenced from the
  4894 + containing page. This is compliant with older PDF versions.
  4895 + Also detect if any form XObjects have any unresolved names
  4896 + and, if so, don't remove unreferenced resources from them or
  4897 + from the page that contains them.
  4898 + </para>
  4899 + </listitem>
  4900 + <listitem>
  4901 + <para>
4892 4902 Properly handle strings if they appear in inline image
4893 4903 dictionaries while externalizing inline images.
4894 4904 </para>
... ...
qpdf/qpdf.testcov
... ... @@ -566,3 +566,5 @@ NNTree non-flat tree is empty after remove 0
566 566 NNTree remove walking up tree 0
567 567 NNTree erased last item in tree 0
568 568 NNTree remove limits from root 0
  569 +QPDFPageObjectHelper unresolved names 0
  570 +QPDFPageObjectHelper resolving unresolved 0
... ...
qpdf/qtest/qpdf.test
... ... @@ -1783,8 +1783,8 @@ my @sp_cases = (
1783 1783 [1, 'broken data', '--pages broken-lzw.pdf --', 'split-out.pdf',
1784 1784 {$td->FILE => "broken-lzw.out", $td->EXIT_STATUS => 3}],
1785 1785 );
1786   -$n_tests += 36;
1787   -$n_compare_pdfs += 1;
  1786 +$n_tests += 43;
  1787 +$n_compare_pdfs += 2;
1788 1788 for (@sp_cases)
1789 1789 {
1790 1790 $n_tests += 1 + $_->[0];
... ... @@ -1943,6 +1943,38 @@ foreach my $i (qw(1 2))
1943 1943 {$td->FILE => "shared-form-xobject-split-$i.pdf"});
1944 1944 }
1945 1945  
  1946 +my @fo_resources = (['form-xobjects-no-resources', 0],
  1947 + ['form-xobjects-some-resources1', 3],
  1948 + ['form-xobjects-some-resources2', 3]);
  1949 +foreach my $d (@fo_resources)
  1950 +{
  1951 + my ($f, $status) = @$d;
  1952 + my $expout = ($status == 0 ?
  1953 + {$td->STRING => ""} :
  1954 + {$td->FILE => "$f.out"});
  1955 + $expout->{$td->EXIT_STATUS} = $status;
  1956 + $td->runtest("split $f",
  1957 + {$td->COMMAND =>
  1958 + "qpdf --empty --static-id --pages $f.pdf 1 --" .
  1959 + " --remove-unreferenced-resources=yes a.pdf"},
  1960 + $expout, $td->NORMALIZE_NEWLINES);
  1961 + $td->runtest("check output ($f)",
  1962 + {$td->FILE => "a.pdf"},
  1963 + {$td->FILE => "$f-out.pdf"});
  1964 + if ($status == 0)
  1965 + {
  1966 + compare_pdfs("$f.pdf", "a.pdf");
  1967 + }
  1968 +}
  1969 +
  1970 +$td->runtest("no warn with pages warnings",
  1971 + {$td->COMMAND =>
  1972 + "qpdf --no-warn --empty --static-id".
  1973 + " --pages form-xobjects-some-resources1.pdf 1 --" .
  1974 + " --remove-unreferenced-resources=yes a.pdf"},
  1975 + {$td->STRING => "", $td->EXIT_STATUS => 3},
  1976 + $td->NORMALIZE_NEWLINES);
  1977 +
1946 1978 show_ntests();
1947 1979 # ----------
1948 1980 $td->notify("--- Keep Files Open ---");
... ...
qpdf/qtest/qpdf/form-xobjects-no-resources-out.pdf 0 โ†’ 100644
No preview for this file type
qpdf/qtest/qpdf/form-xobjects-no-resources.pdf 0 โ†’ 100644
  1 +%PDF-1.3
  2 +%ยฟรทยขรพ
  3 +%QDF-1.0
  4 +
  5 +1 0 obj
  6 +<<
  7 + /Pages 2 0 R
  8 + /Type /Catalog
  9 +>>
  10 +endobj
  11 +
  12 +2 0 obj
  13 +<<
  14 + /Count 1
  15 + /Kids [
  16 + 3 0 R
  17 + ]
  18 + /Resources <<
  19 + /Font <<
  20 + /F1 4 0 R
  21 + >>
  22 + /ProcSet 5 0 R
  23 + /XObject <<
  24 + /Fx1 6 0 R
  25 + /Fx2 8 0 R
  26 + /Im1 10 0 R
  27 + /Im2 12 0 R
  28 + /Im3 14 0 R
  29 + /Im4 16 0 R
  30 + /Im5 18 0 R
  31 + /Im6 20 0 R
  32 + /ImX 20 0 R
  33 + >>
  34 + >>
  35 + /Type /Pages
  36 +>>
  37 +endobj
  38 +
  39 +%% Page 1
  40 +3 0 obj
  41 +<<
  42 + /Contents 22 0 R
  43 + /MediaBox [
  44 + 0
  45 + 0
  46 + 612
  47 + 792
  48 + ]
  49 + /Parent 2 0 R
  50 + /Type /Page
  51 +>>
  52 +endobj
  53 +
  54 +4 0 obj
  55 +<<
  56 + /BaseFont /Helvetica
  57 + /Encoding /WinAnsiEncoding
  58 + /Name /F1
  59 + /Subtype /Type1
  60 + /Type /Font
  61 +>>
  62 +endobj
  63 +
  64 +5 0 obj
  65 +[
  66 + /PDF
  67 + /Text
  68 + /ImageC
  69 +]
  70 +endobj
  71 +
  72 +6 0 obj
  73 +<<
  74 + /BBox [
  75 + 0
  76 + 0
  77 + 300
  78 + 500
  79 + ]
  80 + /Subtype /Form
  81 + /Type /XObject
  82 + /Length 7 0 R
  83 +>>
  84 +stream
  85 +BT
  86 + /F1 24 Tf
  87 + 0 320 Td
  88 + (FX1) Tj
  89 +ET
  90 +q
  91 +100 0 0 100 000 200 cm
  92 +/Im3 Do
  93 +Q
  94 +q
  95 +100 0 0 100 120 200 cm
  96 +/Im4 Do
  97 +Q
  98 +q
  99 +1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 cm
  100 +/Fx2 Do
  101 +Q
  102 +endstream
  103 +endobj
  104 +
  105 +7 0 obj
  106 +173
  107 +endobj
  108 +
  109 +8 0 obj
  110 +<<
  111 + /BBox [
  112 + 0
  113 + 0
  114 + 300
  115 + 200
  116 + ]
  117 + /Subtype /Form
  118 + /Type /XObject
  119 + /Length 9 0 R
  120 +>>
  121 +stream
  122 +BT
  123 + /F1 24 Tf
  124 + 0 120 Td
  125 + (FX2) Tj
  126 +ET
  127 +q
  128 +100 0 0 100 0 0 cm
  129 +/Im5 Do
  130 +Q
  131 +q
  132 +100 0 0 100 120 0 cm
  133 +/Im6 Do
  134 +Q
  135 +endstream
  136 +endobj
  137 +
  138 +9 0 obj
  139 +104
  140 +endobj
  141 +
  142 +10 0 obj
  143 +<<
  144 + /BitsPerComponent 8
  145 + /ColorSpace /DeviceGray
  146 + /Height 15
  147 + /Subtype /Image
  148 + /Type /XObject
  149 + /Width 15
  150 + /Length 11 0 R
  151 +>>
  152 +stream
  153 +`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  154 +endstream
  155 +endobj
  156 +
  157 +%QDF: ignore_newline
  158 +11 0 obj
  159 +225
  160 +endobj
  161 +
  162 +12 0 obj
  163 +<<
  164 + /BitsPerComponent 8
  165 + /ColorSpace /DeviceGray
  166 + /Height 15
  167 + /Subtype /Image
  168 + /Type /XObject
  169 + /Width 15
  170 + /Length 13 0 R
  171 +>>
  172 +stream
  173 +@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  174 +endstream
  175 +endobj
  176 +
  177 +%QDF: ignore_newline
  178 +13 0 obj
  179 +225
  180 +endobj
  181 +
  182 +14 0 obj
  183 +<<
  184 + /BitsPerComponent 8
  185 + /ColorSpace /DeviceGray
  186 + /Height 15
  187 + /Subtype /Image
  188 + /Type /XObject
  189 + /Width 15
  190 + /Length 15 0 R
  191 +>>
  192 +stream
  193 +@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  194 +endstream
  195 +endobj
  196 +
  197 +%QDF: ignore_newline
  198 +15 0 obj
  199 +225
  200 +endobj
  201 +
  202 +16 0 obj
  203 +<<
  204 + /BitsPerComponent 8
  205 + /ColorSpace /DeviceGray
  206 + /Height 15
  207 + /Subtype /Image
  208 + /Type /XObject
  209 + /Width 15
  210 + /Length 17 0 R
  211 +>>
  212 +stream
  213 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  214 +endstream
  215 +endobj
  216 +
  217 +%QDF: ignore_newline
  218 +17 0 obj
  219 +225
  220 +endobj
  221 +
  222 +18 0 obj
  223 +<<
  224 + /BitsPerComponent 8
  225 + /ColorSpace /DeviceGray
  226 + /Height 15
  227 + /Subtype /Image
  228 + /Type /XObject
  229 + /Width 15
  230 + /Length 19 0 R
  231 +>>
  232 +stream
  233 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  234 +endstream
  235 +endobj
  236 +
  237 +%QDF: ignore_newline
  238 +19 0 obj
  239 +225
  240 +endobj
  241 +
  242 +20 0 obj
  243 +<<
  244 + /BitsPerComponent 8
  245 + /ColorSpace /DeviceGray
  246 + /Height 15
  247 + /Subtype /Image
  248 + /Type /XObject
  249 + /Width 15
  250 + /Length 21 0 R
  251 +>>
  252 +stream
  253 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  254 +endstream
  255 +endobj
  256 +
  257 +%QDF: ignore_newline
  258 +21 0 obj
  259 +225
  260 +endobj
  261 +
  262 +%% Contents for page 1
  263 +22 0 obj
  264 +<<
  265 + /Length 23 0 R
  266 +>>
  267 +stream
  268 +BT
  269 + /F1 24 Tf
  270 + 72 720 Td
  271 + (Page) Tj
  272 +ET
  273 +q
  274 +100 0 0 100 72 600 cm
  275 +/Im1 Do
  276 +Q
  277 +q
  278 +100 0 0 100 192 600 cm
  279 +/Im2 Do
  280 +Q
  281 +q
  282 +1.00000 0.00000 0.00000 1.00000 72.00000 200.00000 cm
  283 +/Fx1 Do
  284 +Q
  285 +endstream
  286 +endobj
  287 +
  288 +23 0 obj
  289 +177
  290 +endobj
  291 +
  292 +xref
  293 +0 24
  294 +0000000000 65535 f
  295 +0000000025 00000 n
  296 +0000000079 00000 n
  297 +0000000420 00000 n
  298 +0000000537 00000 n
  299 +0000000655 00000 n
  300 +0000000700 00000 n
  301 +0000001004 00000 n
  302 +0000001024 00000 n
  303 +0000001259 00000 n
  304 +0000001279 00000 n
  305 +0000001691 00000 n
  306 +0000001712 00000 n
  307 +0000002124 00000 n
  308 +0000002145 00000 n
  309 +0000002557 00000 n
  310 +0000002578 00000 n
  311 +0000002990 00000 n
  312 +0000003011 00000 n
  313 +0000003423 00000 n
  314 +0000003444 00000 n
  315 +0000003856 00000 n
  316 +0000003900 00000 n
  317 +0000004134 00000 n
  318 +trailer <<
  319 + /Root 1 0 R
  320 + /Size 24
  321 + /ID [<55269d37282af9edc76855e4cb859987><5044e8073c04a0be007e587c761cce26>]
  322 +>>
  323 +startxref
  324 +4155
  325 +%%EOF
... ...
qpdf/qtest/qpdf/form-xobjects-some-resources1-out.pdf 0 โ†’ 100644
No preview for this file type
qpdf/qtest/qpdf/form-xobjects-some-resources1.out 0 โ†’ 100644
  1 +WARNING: form-xobjects-some-resources1.pdf, stream object 8 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
  2 +qpdf: operation succeeded with warnings; resulting file may have some problems
... ...
qpdf/qtest/qpdf/form-xobjects-some-resources1.pdf 0 โ†’ 100644
  1 +%PDF-1.3
  2 +%ยฟรทยขรพ
  3 +%QDF-1.0
  4 +
  5 +1 0 obj
  6 +<<
  7 + /Pages 2 0 R
  8 + /Type /Catalog
  9 +>>
  10 +endobj
  11 +
  12 +2 0 obj
  13 +<<
  14 + /Count 1
  15 + /Kids [
  16 + 3 0 R
  17 + ]
  18 + /Resources <<
  19 + /Font <<
  20 + /F1 4 0 R
  21 + >>
  22 + /ProcSet 5 0 R
  23 + /XObject <<
  24 + /Fx1 6 0 R
  25 + /Fx2 8 0 R
  26 + /Im1 10 0 R
  27 + /Im2 12 0 R
  28 + /Im3 14 0 R
  29 + /Im4 16 0 R
  30 + /Im5 18 0 R
  31 + /Im6 20 0 R
  32 + /ImX 20 0 R
  33 + >>
  34 + >>
  35 + /Type /Pages
  36 +>>
  37 +endobj
  38 +
  39 +%% Page 1
  40 +3 0 obj
  41 +<<
  42 + /Contents 22 0 R
  43 + /MediaBox [
  44 + 0
  45 + 0
  46 + 612
  47 + 792
  48 + ]
  49 + /Parent 2 0 R
  50 + /Type /Page
  51 +>>
  52 +endobj
  53 +
  54 +4 0 obj
  55 +<<
  56 + /BaseFont /Helvetica
  57 + /Encoding /WinAnsiEncoding
  58 + /Name /F1
  59 + /Subtype /Type1
  60 + /Type /Font
  61 +>>
  62 +endobj
  63 +
  64 +5 0 obj
  65 +[
  66 + /PDF
  67 + /Text
  68 + /ImageC
  69 +]
  70 +endobj
  71 +
  72 +6 0 obj
  73 +<<
  74 + /BBox [
  75 + 0
  76 + 0
  77 + 300
  78 + 500
  79 + ]
  80 + /Subtype /Form
  81 + /Type /XObject
  82 + /Length 7 0 R
  83 +>>
  84 +stream
  85 +BT
  86 + /F1 24 Tf
  87 + 0 320 Td
  88 + (FX1) Tj
  89 +ET
  90 +q
  91 +100 0 0 100 000 200 cm
  92 +/Im3 Do
  93 +Q
  94 +q
  95 +100 0 0 100 120 200 cm
  96 +/Im4 Do
  97 +Q
  98 +q
  99 +1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 cm
  100 +/Fx2 Do
  101 +Q
  102 +endstream
  103 +endobj
  104 +
  105 +7 0 obj
  106 +173
  107 +endobj
  108 +
  109 +8 0 obj
  110 +<<
  111 + /BBox [
  112 + 0
  113 + 0
  114 + 300
  115 + 200
  116 + ]
  117 + /Subtype /Form
  118 + /Type /XObject
  119 + /Length 9 0 R
  120 + /Resources <<
  121 + /XObject <<
  122 + /Im1 20 0 R
  123 + /ImY 20 0 R
  124 + >>
  125 + >>
  126 +>>
  127 +stream
  128 +BT
  129 + /F1 24 Tf
  130 + 0 120 Td
  131 + (FX2) Tj
  132 +ET
  133 +q
  134 +100 0 0 100 0 0 cm
  135 +/Im5 Do
  136 +Q
  137 +q
  138 +100 0 0 100 120 0 cm
  139 +/Im1 Do
  140 +Q
  141 +endstream
  142 +endobj
  143 +
  144 +9 0 obj
  145 +104
  146 +endobj
  147 +
  148 +10 0 obj
  149 +<<
  150 + /BitsPerComponent 8
  151 + /ColorSpace /DeviceGray
  152 + /Height 15
  153 + /Subtype /Image
  154 + /Type /XObject
  155 + /Width 15
  156 + /Length 11 0 R
  157 +>>
  158 +stream
  159 +`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  160 +endstream
  161 +endobj
  162 +
  163 +%QDF: ignore_newline
  164 +11 0 obj
  165 +225
  166 +endobj
  167 +
  168 +12 0 obj
  169 +<<
  170 + /BitsPerComponent 8
  171 + /ColorSpace /DeviceGray
  172 + /Height 15
  173 + /Subtype /Image
  174 + /Type /XObject
  175 + /Width 15
  176 + /Length 13 0 R
  177 +>>
  178 +stream
  179 +@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  180 +endstream
  181 +endobj
  182 +
  183 +%QDF: ignore_newline
  184 +13 0 obj
  185 +225
  186 +endobj
  187 +
  188 +14 0 obj
  189 +<<
  190 + /BitsPerComponent 8
  191 + /ColorSpace /DeviceGray
  192 + /Height 15
  193 + /Subtype /Image
  194 + /Type /XObject
  195 + /Width 15
  196 + /Length 15 0 R
  197 +>>
  198 +stream
  199 +@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  200 +endstream
  201 +endobj
  202 +
  203 +%QDF: ignore_newline
  204 +15 0 obj
  205 +225
  206 +endobj
  207 +
  208 +16 0 obj
  209 +<<
  210 + /BitsPerComponent 8
  211 + /ColorSpace /DeviceGray
  212 + /Height 15
  213 + /Subtype /Image
  214 + /Type /XObject
  215 + /Width 15
  216 + /Length 17 0 R
  217 +>>
  218 +stream
  219 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  220 +endstream
  221 +endobj
  222 +
  223 +%QDF: ignore_newline
  224 +17 0 obj
  225 +225
  226 +endobj
  227 +
  228 +18 0 obj
  229 +<<
  230 + /BitsPerComponent 8
  231 + /ColorSpace /DeviceGray
  232 + /Height 15
  233 + /Subtype /Image
  234 + /Type /XObject
  235 + /Width 15
  236 + /Length 19 0 R
  237 +>>
  238 +stream
  239 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  240 +endstream
  241 +endobj
  242 +
  243 +%QDF: ignore_newline
  244 +19 0 obj
  245 +225
  246 +endobj
  247 +
  248 +20 0 obj
  249 +<<
  250 + /BitsPerComponent 8
  251 + /ColorSpace /DeviceGray
  252 + /Height 15
  253 + /Subtype /Image
  254 + /Type /XObject
  255 + /Width 15
  256 + /Length 21 0 R
  257 +>>
  258 +stream
  259 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  260 +endstream
  261 +endobj
  262 +
  263 +%QDF: ignore_newline
  264 +21 0 obj
  265 +225
  266 +endobj
  267 +
  268 +%% Contents for page 1
  269 +22 0 obj
  270 +<<
  271 + /Length 23 0 R
  272 +>>
  273 +stream
  274 +BT
  275 + /F1 24 Tf
  276 + 72 720 Td
  277 + (Page) Tj
  278 +ET
  279 +q
  280 +100 0 0 100 72 600 cm
  281 +/Im1 Do
  282 +Q
  283 +q
  284 +100 0 0 100 192 600 cm
  285 +/Im2 Do
  286 +Q
  287 +q
  288 +1.00000 0.00000 0.00000 1.00000 72.00000 200.00000 cm
  289 +/Fx1 Do
  290 +Q
  291 +endstream
  292 +endobj
  293 +
  294 +23 0 obj
  295 +177
  296 +endobj
  297 +
  298 +xref
  299 +0 24
  300 +0000000000 65535 f
  301 +0000000025 00000 n
  302 +0000000079 00000 n
  303 +0000000420 00000 n
  304 +0000000537 00000 n
  305 +0000000655 00000 n
  306 +0000000700 00000 n
  307 +0000001004 00000 n
  308 +0000001024 00000 n
  309 +0000001339 00000 n
  310 +0000001359 00000 n
  311 +0000001771 00000 n
  312 +0000001792 00000 n
  313 +0000002204 00000 n
  314 +0000002225 00000 n
  315 +0000002637 00000 n
  316 +0000002658 00000 n
  317 +0000003070 00000 n
  318 +0000003091 00000 n
  319 +0000003503 00000 n
  320 +0000003524 00000 n
  321 +0000003936 00000 n
  322 +0000003980 00000 n
  323 +0000004214 00000 n
  324 +trailer <<
  325 + /Root 1 0 R
  326 + /Size 24
  327 + /ID [<55269d37282af9edc76855e4cb859987><5044e8073c04a0be007e587c761cce26>]
  328 +>>
  329 +startxref
  330 +4235
  331 +%%EOF
... ...
qpdf/qtest/qpdf/form-xobjects-some-resources2-out.pdf 0 โ†’ 100644
No preview for this file type
qpdf/qtest/qpdf/form-xobjects-some-resources2.out 0 โ†’ 100644
  1 +WARNING: form-xobjects-some-resources2.pdf, stream object 6 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
  2 +WARNING: form-xobjects-some-resources2.pdf, stream object 8 0: Unresolved names found while scanning content stream; not attempting to remove unreferenced objects from this object
  3 +qpdf: operation succeeded with warnings; resulting file may have some problems
... ...
qpdf/qtest/qpdf/form-xobjects-some-resources2.pdf 0 โ†’ 100644
  1 +%PDF-1.3
  2 +%ยฟรทยขรพ
  3 +%QDF-1.0
  4 +
  5 +1 0 obj
  6 +<<
  7 + /Pages 2 0 R
  8 + /Type /Catalog
  9 +>>
  10 +endobj
  11 +
  12 +2 0 obj
  13 +<<
  14 + /Count 1
  15 + /Kids [
  16 + 3 0 R
  17 + ]
  18 + /Resources <<
  19 + /Font <<
  20 + /F1 4 0 R
  21 + >>
  22 + /ProcSet 5 0 R
  23 + /XObject <<
  24 + /Fx1 6 0 R
  25 + /Fx2 8 0 R
  26 + /Im1 10 0 R
  27 + /Im2 12 0 R
  28 + /Im3 14 0 R
  29 + /Im4 16 0 R
  30 + /Im6 20 0 R
  31 + /ImX 20 0 R
  32 + >>
  33 + >>
  34 + /Type /Pages
  35 +>>
  36 +endobj
  37 +
  38 +%% Page 1
  39 +3 0 obj
  40 +<<
  41 + /Contents 22 0 R
  42 + /MediaBox [
  43 + 0
  44 + 0
  45 + 612
  46 + 792
  47 + ]
  48 + /Parent 2 0 R
  49 + /Type /Page
  50 +>>
  51 +endobj
  52 +
  53 +4 0 obj
  54 +<<
  55 + /BaseFont /Helvetica
  56 + /Encoding /WinAnsiEncoding
  57 + /Name /F1
  58 + /Subtype /Type1
  59 + /Type /Font
  60 +>>
  61 +endobj
  62 +
  63 +5 0 obj
  64 +[
  65 + /PDF
  66 + /Text
  67 + /ImageC
  68 +]
  69 +endobj
  70 +
  71 +6 0 obj
  72 +<<
  73 + /BBox [
  74 + 0
  75 + 0
  76 + 300
  77 + 500
  78 + ]
  79 + /Subtype /Form
  80 + /Type /XObject
  81 + /Length 7 0 R
  82 + /Resources <<
  83 + /XObject <<
  84 + /Im5 18 0 R
  85 + /ImY 20 0 R
  86 + >>
  87 + >>
  88 +>>
  89 +stream
  90 +BT
  91 + /F1 24 Tf
  92 + 0 320 Td
  93 + (FX1) Tj
  94 +ET
  95 +q
  96 +100 0 0 100 000 200 cm
  97 +/Im3 Do
  98 +Q
  99 +q
  100 +100 0 0 100 120 200 cm
  101 +/Im4 Do
  102 +Q
  103 +q
  104 +1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 cm
  105 +/Fx2 Do
  106 +Q
  107 +endstream
  108 +endobj
  109 +
  110 +7 0 obj
  111 +173
  112 +endobj
  113 +
  114 +8 0 obj
  115 +<<
  116 + /BBox [
  117 + 0
  118 + 0
  119 + 300
  120 + 200
  121 + ]
  122 + /Subtype /Form
  123 + /Type /XObject
  124 + /Length 9 0 R
  125 + /Resources <<
  126 + /XObject <<
  127 + /Im1 20 0 R
  128 + /ImZ 20 0 R
  129 + >>
  130 + >>
  131 +>>
  132 +stream
  133 +BT
  134 + /F1 24 Tf
  135 + 0 120 Td
  136 + (FX2) Tj
  137 +ET
  138 +q
  139 +100 0 0 100 0 0 cm
  140 +/Im5 Do
  141 +Q
  142 +q
  143 +100 0 0 100 120 0 cm
  144 +/Im1 Do
  145 +Q
  146 +endstream
  147 +endobj
  148 +
  149 +9 0 obj
  150 +104
  151 +endobj
  152 +
  153 +10 0 obj
  154 +<<
  155 + /BitsPerComponent 8
  156 + /ColorSpace /DeviceGray
  157 + /Height 15
  158 + /Subtype /Image
  159 + /Type /XObject
  160 + /Width 15
  161 + /Length 11 0 R
  162 +>>
  163 +stream
  164 +`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  165 +endstream
  166 +endobj
  167 +
  168 +%QDF: ignore_newline
  169 +11 0 obj
  170 +225
  171 +endobj
  172 +
  173 +12 0 obj
  174 +<<
  175 + /BitsPerComponent 8
  176 + /ColorSpace /DeviceGray
  177 + /Height 15
  178 + /Subtype /Image
  179 + /Type /XObject
  180 + /Width 15
  181 + /Length 13 0 R
  182 +>>
  183 +stream
  184 +@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  185 +endstream
  186 +endobj
  187 +
  188 +%QDF: ignore_newline
  189 +13 0 obj
  190 +225
  191 +endobj
  192 +
  193 +14 0 obj
  194 +<<
  195 + /BitsPerComponent 8
  196 + /ColorSpace /DeviceGray
  197 + /Height 15
  198 + /Subtype /Image
  199 + /Type /XObject
  200 + /Width 15
  201 + /Length 15 0 R
  202 +>>
  203 +stream
  204 +@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  205 +endstream
  206 +endobj
  207 +
  208 +%QDF: ignore_newline
  209 +15 0 obj
  210 +225
  211 +endobj
  212 +
  213 +16 0 obj
  214 +<<
  215 + /BitsPerComponent 8
  216 + /ColorSpace /DeviceGray
  217 + /Height 15
  218 + /Subtype /Image
  219 + /Type /XObject
  220 + /Width 15
  221 + /Length 17 0 R
  222 +>>
  223 +stream
  224 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  225 +endstream
  226 +endobj
  227 +
  228 +%QDF: ignore_newline
  229 +17 0 obj
  230 +225
  231 +endobj
  232 +
  233 +18 0 obj
  234 +<<
  235 + /BitsPerComponent 8
  236 + /ColorSpace /DeviceGray
  237 + /Height 15
  238 + /Subtype /Image
  239 + /Type /XObject
  240 + /Width 15
  241 + /Length 19 0 R
  242 +>>
  243 +stream
  244 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  245 +endstream
  246 +endobj
  247 +
  248 +%QDF: ignore_newline
  249 +19 0 obj
  250 +225
  251 +endobj
  252 +
  253 +20 0 obj
  254 +<<
  255 + /BitsPerComponent 8
  256 + /ColorSpace /DeviceGray
  257 + /Height 15
  258 + /Subtype /Image
  259 + /Type /XObject
  260 + /Width 15
  261 + /Length 21 0 R
  262 +>>
  263 +stream
  264 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@`````@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  265 +endstream
  266 +endobj
  267 +
  268 +%QDF: ignore_newline
  269 +21 0 obj
  270 +225
  271 +endobj
  272 +
  273 +%% Contents for page 1
  274 +22 0 obj
  275 +<<
  276 + /Length 23 0 R
  277 +>>
  278 +stream
  279 +BT
  280 + /F1 24 Tf
  281 + 72 720 Td
  282 + (Page) Tj
  283 +ET
  284 +q
  285 +100 0 0 100 72 600 cm
  286 +/Im1 Do
  287 +Q
  288 +q
  289 +100 0 0 100 192 600 cm
  290 +/Im2 Do
  291 +Q
  292 +q
  293 +1.00000 0.00000 0.00000 1.00000 72.00000 200.00000 cm
  294 +/Fx1 Do
  295 +Q
  296 +endstream
  297 +endobj
  298 +
  299 +23 0 obj
  300 +177
  301 +endobj
  302 +
  303 +xref
  304 +0 24
  305 +0000000000 65535 f
  306 +0000000025 00000 n
  307 +0000000079 00000 n
  308 +0000000402 00000 n
  309 +0000000519 00000 n
  310 +0000000637 00000 n
  311 +0000000682 00000 n
  312 +0000001066 00000 n
  313 +0000001086 00000 n
  314 +0000001401 00000 n
  315 +0000001421 00000 n
  316 +0000001833 00000 n
  317 +0000001854 00000 n
  318 +0000002266 00000 n
  319 +0000002287 00000 n
  320 +0000002699 00000 n
  321 +0000002720 00000 n
  322 +0000003132 00000 n
  323 +0000003153 00000 n
  324 +0000003565 00000 n
  325 +0000003586 00000 n
  326 +0000003998 00000 n
  327 +0000004042 00000 n
  328 +0000004276 00000 n
  329 +trailer <<
  330 + /Root 1 0 R
  331 + /Size 24
  332 + /ID [<55269d37282af9edc76855e4cb859987><5044e8073c04a0be007e587c761cce26>]
  333 +>>
  334 +startxref
  335 +4297
  336 +%%EOF
... ...
qpdf/qtest/qpdf/shared-images-errors-2.out
1 1 WARNING: shared-images-errors.pdf (offset 4933): error decoding stream data for object 19 0: stream inflate: inflate: data: incorrect header check
2   -WARNING: shared-images-errors.pdf, object 4 0 at offset 676: Unable to parse content stream: content stream (content stream object 19 0): errors while decoding content stream; not attempting to remove unreferenced objects from this page
  2 +WARNING: shared-images-errors.pdf, object 4 0 at offset 676: Unable to parse content stream: content stream (content stream object 19 0): errors while decoding content stream; not attempting to remove unreferenced objects from this object
3 3 WARNING: shared-images-errors.pdf (offset 4933): error decoding stream data for object 19 0: stream inflate: inflate: data: incorrect header check
4 4 WARNING: shared-images-errors.pdf (offset 4933): stream will be re-processed without filtering to avoid data loss
5 5 qpdf: operation succeeded with warnings; resulting file may have some problems
... ...
qpdf/qtest/qpdf/split-tokens-split.out
1   -WARNING: split-tokens.pdf, object 3 0 at offset 181: Bad token found while scanning content stream; not attempting to remove unreferenced objects from this page
  1 +WARNING: split-tokens.pdf, object 3 0 at offset 181: Bad token found while scanning content stream; not attempting to remove unreferenced objects from this object
2 2 WARNING: empty PDF: content normalization encountered bad tokens
3 3 WARNING: empty PDF: normalized content ended with a bad token; you may be able to resolve this by coalescing content streams in combination with normalizing content. From the command line, specify --coalesce-contents
4 4 WARNING: empty PDF: Resulting stream data may be corrupted but is may still useful for manual inspection. For more information on this warning, search for content normalization in the manual.
... ...