{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/6194","labels_url":"https://api.github.com/repos/mozilla/pdf.js/issues/6194/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/pdf.js/issues/6194/comments","events_url":"https://api.github.com/repos/mozilla/pdf.js/issues/6194/events","html_url":"https://github.com/mozilla/pdf.js/pull/6194","id":94367111,"number":6194,"title":"Subtract start offset for xrefs in recovery mode","user":{"login":"Rob--W","id":1365071,"avatar_url":"https://avatars.githubusercontent.com/u/1365071?v=3","gravatar_id":"","url":"https://api.github.com/users/Rob--W","html_url":"https://github.com/Rob--W","followers_url":"https://api.github.com/users/Rob--W/followers","following_url":"https://api.github.com/users/Rob--W/following{/other_user}","gists_url":"https://api.github.com/users/Rob--W/gists{/gist_id}","starred_url":"https://api.github.com/users/Rob--W/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rob--W/subscriptions","organizations_url":"https://api.github.com/users/Rob--W/orgs","repos_url":"https://api.github.com/users/Rob--W/repos","events_url":"https://api.github.com/users/Rob--W/events{/privacy}","received_events_url":"https://api.github.com/users/Rob--W/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mozilla/pdf.js/labels/1-core","name":"1-core","color":"DDDDDD"}],"state":"open","locked":false,"assignee":{"login":"timvandermeij","id":1993262,"avatar_url":"https://avatars.githubusercontent.com/u/1993262?v=3","gravatar_id":"","url":"https://api.github.com/users/timvandermeij","html_url":"https://github.com/timvandermeij","followers_url":"https://api.github.com/users/timvandermeij/followers","following_url":"https://api.github.com/users/timvandermeij/following{/other_user}","gists_url":"https://api.github.com/users/timvandermeij/gists{/gist_id}","starred_url":"https://api.github.com/users/timvandermeij/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timvandermeij/subscriptions","organizations_url":"https://api.github.com/users/timvandermeij/orgs","repos_url":"https://api.github.com/users/timvandermeij/repos","events_url":"https://api.github.com/users/timvandermeij/events{/privacy}","received_events_url":"https://api.github.com/users/timvandermeij/received_events","type":"User","site_admin":false},"milestone":null,"comments":9,"created_at":"2015-07-10T18:42:45Z","updated_at":"2015-07-10T22:05:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla/pdf.js/pulls/6194","html_url":"https://github.com/mozilla/pdf.js/pull/6194","diff_url":"https://github.com/mozilla/pdf.js/pull/6194.diff","patch_url":"https://github.com/mozilla/pdf.js/pull/6194.patch"},"body":"Xref offsets are relative to the start of the PDF data, not to the start of the PDF file. This is clear if you look at the other code:\r\n\r\n- In the XRef's [readXRefTable](https://github.com/mozilla/pdf.js/blob/ccfafea20b9c70ea69a175fcbdf2732e4b6598fb/src/core/obj.js#L884-L885) and [processXRefTable](https://github.com/mozilla/pdf.js/blob/ccfafea20b9c70ea69a175fcbdf2732e4b6598fb/src/core/obj.js#L986-L992) methods of XRef, the  offset of a xref entry is set to the bytes as given by a PDF file. These values are always relative to the start of the PDF file (%PDF-).\r\n\r\n- The [XRef's readXRef method](https://github.com/mozilla/pdf.js/blob/ccfafea20b9c70ea69a175fcbdf2732e4b6598fb/src/core/obj.js#L1146) adds the start offset of the stream to Xref entry's offset. Clearly, this line assumes that the entry offset excludes the start offset.\r\n\r\nHowever, when the PDF is parsed in recovery mode, the xref table is filled with entries whose offset is relative to the start of the stream rather than the PDF file. This is incorrect, and the fix is to subtract the start offset of the stream from the entry's byte offset. Otherwise you'll get a \"Bad XRef entry\" error.\r\n\r\nFixes #6069."},"comment":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/comments/120539288","html_url":"https://github.com/mozilla/pdf.js/pull/6194#issuecomment-120539288","issue_url":"https://api.github.com/repos/mozilla/pdf.js/issues/6194","id":120539288,"user":{"login":"pdfjsbot","id":1036361,"avatar_url":"https://avatars.githubusercontent.com/u/1036361?v=3","gravatar_id":"","url":"https://api.github.com/users/pdfjsbot","html_url":"https://github.com/pdfjsbot","followers_url":"https://api.github.com/users/pdfjsbot/followers","following_url":"https://api.github.com/users/pdfjsbot/following{/other_user}","gists_url":"https://api.github.com/users/pdfjsbot/gists{/gist_id}","starred_url":"https://api.github.com/users/pdfjsbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdfjsbot/subscriptions","organizations_url":"https://api.github.com/users/pdfjsbot/orgs","repos_url":"https://api.github.com/users/pdfjsbot/repos","events_url":"https://api.github.com/users/pdfjsbot/events{/privacy}","received_events_url":"https://api.github.com/users/pdfjsbot/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T22:05:33Z","updated_at":"2015-07-10T22:05:33Z","body":"#### From: Bot.io (Windows)\n\n----\n\n# Success\n\nFull output at http://107.22.172.223:8877/c1f371e59de3dee/output.txt\n\nTotal script time: 18.47 mins\n\n+ **Font tests:** Passed\n+ **Unit tests:** Passed\n+ **Regression tests:** Passed"}}