Commit 1fba24aada0290d646b04289ab95395905f10c27

Authored by Jay Berkenbilt
1 parent 0a470d2d

Add another test case for weird page trees

qpdf/qtest/qpdf.test
... ... @@ -1802,8 +1802,8 @@ foreach my $f (qw(screen print))
1802 1802  
1803 1803 show_ntests();
1804 1804 # ----------
1805   -$td->notify("--- Duplicated Page Object ---");
1806   -$n_tests += 4;
  1805 +$td->notify("--- Page Tree Issues ---");
  1806 +$n_tests += 9;
1807 1807  
1808 1808 $td->runtest("linearize duplicated pages",
1809 1809 {$td->COMMAND =>
... ... @@ -1823,6 +1823,31 @@ $td->runtest("extract duplicated pages",
1823 1823 $td->runtest("compare files",
1824 1824 {$td->FILE => "a.pdf"},
1825 1825 {$td->FILE => "extract-duplicate-page.pdf"});
  1826 +$td->runtest("direct pages",
  1827 + {$td->COMMAND =>
  1828 + "qpdf --static-id direct-pages.pdf --pages . -- a.pdf"},
  1829 + {$td->STRING => "", $td->EXIT_STATUS => 0},
  1830 + $td->NORMALIZE_NEWLINES);
  1831 +$td->runtest("check output",
  1832 + {$td->FILE => "a.pdf"},
  1833 + {$td->FILE => "direct-pages-fixed.pdf"});
  1834 +$td->runtest("show direct pages",
  1835 + {$td->COMMAND =>
  1836 + "qpdf --show-pages direct-pages.pdf"},
  1837 + {$td->FILE => "direct-pages.out", $td->EXIT_STATUS => 0},
  1838 + $td->NORMALIZE_NEWLINES);
  1839 +
  1840 +# Json mode for direct and duplicated pages illustrates that the
  1841 +# "objects" section still shows the original objects before correction
  1842 +# but the "pages" section shows the pages with their new object
  1843 +# numbers.
  1844 +foreach my $f (qw(page_api_2 direct-pages))
  1845 +{
  1846 + $td->runtest("json for $f",
  1847 + {$td->COMMAND => "qpdf --json $f.pdf"},
  1848 + {$td->FILE => "$f-json.out", $td->EXIT_STATUS => 0},
  1849 + $td->NORMALIZE_NEWLINES);
  1850 +}
1826 1851  
1827 1852 show_ntests();
1828 1853 # ----------
... ... @@ -2542,7 +2567,7 @@ for (my $n = 16; $n <= 19; ++$n)
2542 2567 show_ntests();
2543 2568 # ----------
2544 2569 $td->notify("--- Specific File Tests ---");
2545   -$n_tests += 7;
  2570 +$n_tests += 4;
2546 2571  
2547 2572 # Special PDF files that caused problems at some point
2548 2573  
... ... @@ -2563,19 +2588,6 @@ $td->runtest("compress objstm and xref",
2563 2588 $td->runtest("check output",
2564 2589 {$td->FILE => "a.pdf"},
2565 2590 {$td->FILE => "compress-objstm-xref.pdf"});
2566   -$td->runtest("direct pages",
2567   - {$td->COMMAND =>
2568   - "qpdf --static-id direct-pages.pdf --pages . -- a.pdf"},
2569   - {$td->STRING => "", $td->EXIT_STATUS => 0},
2570   - $td->NORMALIZE_NEWLINES);
2571   -$td->runtest("check output",
2572   - {$td->FILE => "a.pdf"},
2573   - {$td->FILE => "direct-pages-fixed.pdf"});
2574   -$td->runtest("show direct pages",
2575   - {$td->COMMAND =>
2576   - "qpdf --show-pages direct-pages.pdf"},
2577   - {$td->FILE => "direct-pages.out", $td->EXIT_STATUS => 0},
2578   - $td->NORMALIZE_NEWLINES);
2579 2591  
2580 2592 show_ntests();
2581 2593 # ----------
... ...
qpdf/qtest/qpdf/direct-pages-json.out 0 → 100644
  1 +{
  2 + "acroform": {
  3 + "fields": [],
  4 + "hasacroform": false,
  5 + "needappearances": false
  6 + },
  7 + "objects": {
  8 + "1 0 R": {
  9 + "/Pages": "2 0 R",
  10 + "/Type": "/Catalog"
  11 + },
  12 + "2 0 R": {
  13 + "/Count": 2,
  14 + "/Kids": [
  15 + {
  16 + "/Contents": "3 0 R",
  17 + "/MediaBox": [
  18 + 0,
  19 + 0,
  20 + 612,
  21 + 792
  22 + ],
  23 + "/Parent": "2 0 R",
  24 + "/Resources": {
  25 + "/Font": {
  26 + "/F1": "5 0 R"
  27 + },
  28 + "/ProcSet": "6 0 R"
  29 + },
  30 + "/Type": "/Page"
  31 + },
  32 + {
  33 + "/Contents": "3 0 R",
  34 + "/MediaBox": [
  35 + 0,
  36 + 0,
  37 + 612,
  38 + 792
  39 + ],
  40 + "/Parent": "2 0 R",
  41 + "/Resources": {
  42 + "/Font": {
  43 + "/F1": "5 0 R"
  44 + },
  45 + "/ProcSet": "6 0 R"
  46 + },
  47 + "/Type": "/Page"
  48 + }
  49 + ],
  50 + "/Type": "/Pages"
  51 + },
  52 + "3 0 R": {
  53 + "/Length": "4 0 R"
  54 + },
  55 + "4 0 R": 44,
  56 + "5 0 R": {
  57 + "/BaseFont": "/Helvetica",
  58 + "/Encoding": "/WinAnsiEncoding",
  59 + "/Name": "/F1",
  60 + "/Subtype": "/Type1",
  61 + "/Type": "/Font"
  62 + },
  63 + "6 0 R": [
  64 + "/PDF",
  65 + "/Text"
  66 + ],
  67 + "trailer": {
  68 + "/ID": [
  69 + "\u0013#¥fi|WzfsU…©6ŸÎ<",
  70 + "7,¿DöÛ‹«`Ù&<\u000f\u000bÒj"
  71 + ],
  72 + "/Root": "1 0 R",
  73 + "/Size": 7
  74 + }
  75 + },
  76 + "outlines": [],
  77 + "pagelabels": [],
  78 + "pages": [
  79 + {
  80 + "contents": [
  81 + "3 0 R"
  82 + ],
  83 + "images": [],
  84 + "label": null,
  85 + "object": "7 0 R",
  86 + "outlines": [],
  87 + "pageposfrom1": 1
  88 + },
  89 + {
  90 + "contents": [
  91 + "3 0 R"
  92 + ],
  93 + "images": [],
  94 + "label": null,
  95 + "object": "8 0 R",
  96 + "outlines": [],
  97 + "pageposfrom1": 2
  98 + }
  99 + ],
  100 + "parameters": {
  101 + "decodelevel": "generalized"
  102 + },
  103 + "version": 1
  104 +}
... ...
qpdf/qtest/qpdf/page_api_2-json.out 0 → 100644
  1 +{
  2 + "acroform": {
  3 + "fields": [],
  4 + "hasacroform": false,
  5 + "needappearances": false
  6 + },
  7 + "objects": {
  8 + "1 0 R": {
  9 + "/Pages": "3 0 R",
  10 + "/Type": "/Catalog"
  11 + },
  12 + "10 0 R": 47,
  13 + "2 0 R": {
  14 + "/CreationDate": "D:20120621124041",
  15 + "/Producer": "Apex PDFWriter"
  16 + },
  17 + "3 0 R": {
  18 + "/Count": 3,
  19 + "/Kids": [
  20 + "4 0 R",
  21 + "4 0 R",
  22 + "5 0 R"
  23 + ],
  24 + "/Type": "/Pages"
  25 + },
  26 + "4 0 R": {
  27 + "/Contents": "6 0 R",
  28 + "/MediaBox": [
  29 + 0,
  30 + 0,
  31 + 612,
  32 + 792
  33 + ],
  34 + "/Parent": "3 0 R",
  35 + "/Resources": {
  36 + "/Font": {
  37 + "/F1": "8 0 R"
  38 + },
  39 + "/ProcSet": [
  40 + "/PDF",
  41 + "/Text"
  42 + ]
  43 + },
  44 + "/Type": "/Page"
  45 + },
  46 + "5 0 R": {
  47 + "/Contents": "9 0 R",
  48 + "/MediaBox": [
  49 + 0,
  50 + 0,
  51 + 612,
  52 + 792
  53 + ],
  54 + "/Parent": "3 0 R",
  55 + "/Resources": {
  56 + "/Font": {
  57 + "/F1": "8 0 R"
  58 + },
  59 + "/ProcSet": [
  60 + "/PDF",
  61 + "/Text"
  62 + ]
  63 + },
  64 + "/Type": "/Page"
  65 + },
  66 + "6 0 R": {
  67 + "/Length": "7 0 R"
  68 + },
  69 + "7 0 R": 47,
  70 + "8 0 R": {
  71 + "/BaseFont": "/Times-Roman",
  72 + "/Encoding": "/WinAnsiEncoding",
  73 + "/Subtype": "/Type1",
  74 + "/Type": "/Font"
  75 + },
  76 + "9 0 R": {
  77 + "/Length": "10 0 R"
  78 + },
  79 + "trailer": {
  80 + "/ID": [
  81 + "û\u0018·ƒÿ{5⁄\u0005Ú−S*º‘o",
  82 + "÷\u0017ž³QY¿ÔÀ\u000f\u0012−¼ý\u001f\u0002"
  83 + ],
  84 + "/Info": "2 0 R",
  85 + "/Root": "1 0 R",
  86 + "/Size": 11
  87 + }
  88 + },
  89 + "outlines": [],
  90 + "pagelabels": [],
  91 + "pages": [
  92 + {
  93 + "contents": [
  94 + "6 0 R"
  95 + ],
  96 + "images": [],
  97 + "label": null,
  98 + "object": "4 0 R",
  99 + "outlines": [],
  100 + "pageposfrom1": 1
  101 + },
  102 + {
  103 + "contents": [
  104 + "6 0 R"
  105 + ],
  106 + "images": [],
  107 + "label": null,
  108 + "object": "11 0 R",
  109 + "outlines": [],
  110 + "pageposfrom1": 2
  111 + },
  112 + {
  113 + "contents": [
  114 + "9 0 R"
  115 + ],
  116 + "images": [],
  117 + "label": null,
  118 + "object": "5 0 R",
  119 + "outlines": [],
  120 + "pageposfrom1": 3
  121 + }
  122 + ],
  123 + "parameters": {
  124 + "decodelevel": "generalized"
  125 + },
  126 + "version": 1
  127 +}
... ...