This is a very common situation and not a "corrupt" file. It is a bug in the PDFSharp implementation.
If you remove an "obj" from the PDF file, you don't need to renumber the remaining ones, you can just set the reference of this "obj" (that didn't exist anymore) to the 00000000 offset.
Furthermore you can have the "obj" in any order, the xref-table tells you the correct offset.
This is an example of an iText (very very common library out there) generated PDF with random objs and a missing (11) one. I did not find any part in the PDF specification which does not allow this!
We need both fixed!
Code:
00000000: %PDF-1.6
00000009: %âãÏÓ
00000015: 3 0 obj <</Length 321/Filter/FlateDecode>>stream
00000064: x}ÁnÂ0ïy
00000077: _&!v6ÙiLbÚ8°ÜÐÚ4ÄúþZB»õúÿü;v ÂF"¥JÍA(I|ÆÃ鵬ýáô!-jÑQ( £@ »x5)ìè>8i¾^`W4Ô(Vþ VÅã|ÓÑ;øçPáªÑ%u÷µ)(v5icEC[3e£¨wüCTU"d°.³@mn[ _Ô³*¯óU<íG0&+Ã{0mü+%WA/êSî.%ßçÍé·þëú¸]Ãðd¢ÍVeJÈêKC_·Ûu[a¹æÙárwÝàEçó»ei³PÌ× ìÊÊ4ý¦¼Õû¶Fa1óâéý©|
00000386: endstream
00000396: endobj
00000403: 5 0 obj<</Type/FontDescriptor/StemV 162/FontName/Arial,Bold/ItalicAngle 0/Descent -210/Ascent 728/CapHeight 0/Flags 32/FontBBox[-45 -209 972 903]>>
00000551: endobj
00000558: 4 0 obj<</FontDescriptor 5 0 R/FirstChar 32/Type/Font/BaseFont/Arial,Bold/Encoding/WinAnsiEncoding/LastChar 255/Widths[278 333 474 556 556 889 722 238 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 333 333 584 584 584 611 975 722 722 722 722 667 611 778 722 278 556 722 611 833 722 778 667 778 722 667 611 722 667 944 667 667 611 333 278 333 584 556 333 556 611 556 611 556 333 611 611 278 278 556 278 889 611 611 611 611 389 556 333 611 556 778 556 556 500 389 280 389 584 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 278 333 556 556 556 556 280 556 333 737 370 556 584 333 737 552 400 549 333 333 333 576 556 333 333 333 365 556 834 834 834 611 722 722 722 722 722 722 1000 722 667 667 667 667 278 278 278 278 722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611 556 556 556 556 556 556 889 556 556 556 556 556 278 278 278 278 611 611 611 611 611 611 611 549 611 611 611 611 611 556 611 556]/Subtype/TrueType>>
00001594: endobj
00001601: 7 0 obj<</Type/FontDescriptor/StemV 72/FontName/Arial/ItalicAngle 0/Descent -210/Ascent 728/CapHeight 0/Flags 32/FontBBox[-45 -209 979 896]>>
00001743: endobj
00001750: 6 0 obj<</FontDescriptor 7 0 R/FirstChar 32/Type/Font/BaseFont/Arial/Encoding/WinAnsiEncoding/LastChar 255/Widths[278 278 355 556 556 889 667 191 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584 556 1015 667 667 722 722 667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944 667 667 611 278 278 278 469 556 333 556 556 500 556 556 278 556 556 222 222 500 222 833 556 556 556 556 333 500 278 556 500 722 500 500 500 334 260 334 584 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 278 333 556 556 556 556 260 556 333 737 370 556 584 333 737 552 400 549 333 333 333 576 537 333 333 333 365 556 834 834 834 611 667 667 667 667 667 667 1000 722 667 667 667 667 278 278 278 278 722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611 556 556 556 556 556 556 889 500 556 556 556 556 278 278 278 278 556 556 556 556 556 556 556 549 611 556 556 556 556 500 556 500]/Subtype/TrueType>>
00002782: endobj
00002789: 2 0 obj<</Type/Page/MediaBox[0 0 595.2 841.68]/Resources<</Font<</f0 4 0 R/f1 6 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Parent 8 0 R/Contents[3 0 R]>>
00002948: endobj
00002955: 8 0 obj<</Type/Pages/Kids[2 0 R]/Count 1>>
00002998: endobj
00003005: 10 0 obj<</Parent 9 0 R/Dest[11 0 R/Fit]/Title(1014 - RO 90/8 Nahtlose Präzisionsstahlrohre)>>
00003100: endobj
00003107: 9 0 obj<</Last 10 0 R/Count 1/First 10 0 R>>
00003152: endobj
00003159: 12 0 obj<</Type/Catalog/PageLayout/OneColumn/Pages 8 0 R/Outlines 9 0 R/PageMode/UseOutlines>>
00003254: endobj
00003261: 13 0 obj<</CreationDate(D:20161202121338+01'00')/Producer(iTextSharp 4.0.3 \(based on iText 2.0.2\))/ModDate(D:20161202121338+01'00')>>
00003397: endobj
00003404: xref
00003409: 0 14
00003414: 0000000000 65535 f
00003434: 0000000000 65536 n
00003454: 0000002789 00000 n
00003474: 0000000015 00000 n
00003494: 0000000558 00000 n
00003514: 0000000403 00000 n
00003534: 0000001750 00000 n
00003554: 0000001601 00000 n
00003574: 0000002955 00000 n
00003594: 0000003107 00000 n
00003614: 0000003005 00000 n
00003634: 0000000000 65536 n
00003654: 0000003159 00000 n
00003674: 0000003261 00000 n
00003694: trailer
00003702: <</Size 14/Info 13 0 R/ID [<2bbfdb9d97cc23ae6ceba0258d16912a><2ccb1ceef5b01998b4ef8d61411506b1>]/Root 12 0 R>>
00003813: startxref
00003823: 3404
00003828: %%EOF
00003834: ÿ