{"action":"created","issue":{"url":"https://api.github.com/repos/sambitdash/PDFIO.jl/issues/39","repository_url":"https://api.github.com/repos/sambitdash/PDFIO.jl","labels_url":"https://api.github.com/repos/sambitdash/PDFIO.jl/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/sambitdash/PDFIO.jl/issues/39/comments","events_url":"https://api.github.com/repos/sambitdash/PDFIO.jl/issues/39/events","html_url":"https://github.com/sambitdash/PDFIO.jl/issues/39","id":386395115,"node_id":"MDU6SXNzdWUzODYzOTUxMTU=","number":39,"title":"`cosDocGetPageNumbers` crashes when there is no `PageLabels` in PDF catalog","user":{"login":"gwierzchowski","id":3616677,"node_id":"MDQ6VXNlcjM2MTY2Nzc=","avatar_url":"https://avatars3.githubusercontent.com/u/3616677?v=4","gravatar_id":"","url":"https://api.github.com/users/gwierzchowski","html_url":"https://github.com/gwierzchowski","followers_url":"https://api.github.com/users/gwierzchowski/followers","following_url":"https://api.github.com/users/gwierzchowski/following{/other_user}","gists_url":"https://api.github.com/users/gwierzchowski/gists{/gist_id}","starred_url":"https://api.github.com/users/gwierzchowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwierzchowski/subscriptions","organizations_url":"https://api.github.com/users/gwierzchowski/orgs","repos_url":"https://api.github.com/users/gwierzchowski/repos","events_url":"https://api.github.com/users/gwierzchowski/events{/privacy}","received_events_url":"https://api.github.com/users/gwierzchowski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-01T00:11:07Z","updated_at":"2018-12-03T22:10:21Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi. Working on Outline support implementation I got following error:\r\n```julia\r\n        @test begin\r\n            filename=\"files/1.pdf\"\r\n            DEBUG && println(filename)\r\n            doc = pdDocOpen(filename)\r\n            @assert length(pdDocGetPageRange(doc, \"1\")) >= 1\r\n            pdDocClose(doc)\r\n            length(utilPrintOpenFiles()) == 0\r\n        end\r\n```\r\nFails with:\r\n`MethodError: no method matching get(::CosNullType, ::CosName)`\r\n\r\nI think `pdDocGetPageRange` should fall back to parsing label as number and return appropriate page if there are no labels dictionary in PDF or at least return empty vector.\r\n\r\nI have ready fix so would like to submit PR."},"comment":{"url":"https://api.github.com/repos/sambitdash/PDFIO.jl/issues/comments/443889564","html_url":"https://github.com/sambitdash/PDFIO.jl/issues/39#issuecomment-443889564","issue_url":"https://api.github.com/repos/sambitdash/PDFIO.jl/issues/39","id":443889564,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Mzg4OTU2NA==","user":{"login":"gwierzchowski","id":3616677,"node_id":"MDQ6VXNlcjM2MTY2Nzc=","avatar_url":"https://avatars3.githubusercontent.com/u/3616677?v=4","gravatar_id":"","url":"https://api.github.com/users/gwierzchowski","html_url":"https://github.com/gwierzchowski","followers_url":"https://api.github.com/users/gwierzchowski/followers","following_url":"https://api.github.com/users/gwierzchowski/following{/other_user}","gists_url":"https://api.github.com/users/gwierzchowski/gists{/gist_id}","starred_url":"https://api.github.com/users/gwierzchowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwierzchowski/subscriptions","organizations_url":"https://api.github.com/users/gwierzchowski/orgs","repos_url":"https://api.github.com/users/gwierzchowski/repos","events_url":"https://api.github.com/users/gwierzchowski/events{/privacy}","received_events_url":"https://api.github.com/users/gwierzchowski/received_events","type":"User","site_admin":false},"created_at":"2018-12-03T22:10:21Z","updated_at":"2018-12-03T22:10:21Z","author_association":"CONTRIBUTOR","body":"@sambitdash, Hi.\r\nAd question1:\r\nYes pages associate with outline items are little tricky and generally go into 2 (main) branches:\r\n- using `Dest` key - what is easier part and I already have this done\r\n- using `A` key - what is harder and leads to GoTo actions and `Names` entry in catalog\r\n\r\nDoing second part I met common structure referred as `name tree` in PDF spec. Before going into coding, I did search if You maybe already implemented reading such structures and I found out that You actually do.\r\nThen I reviewed the code and found issues reported here.\r\nSo I probably will not use directly the function `pdPageGetPage` or `pdPageGetPageRange` but I will use underlying `find_ntree` to read and search `Names` catalog entry. I may however need `PageLabels` as I want to associate outline item with appropriate page label (if page labels are present in document) - not have details yet, but will relay on my fixes.\r\nBTW: Unfortunately it takes some time because I have to sometimes put this work down for a while, so not working on this everyday.\r\n\r\nAd question2:\r\nI think it is good and convenient if numeric page number given as string be properly interpreted as valid page  label. This is what actually most PDF viewers does (e.g. when you use goto-page function).\r\nBefore my changes it depended on weather PDF had (optional) `PageLabels` entry, after the change it does not - what I think is desired. I think that function `pdDocGetPageRange(doc::PDDoc, label::AbstractString)` should more-less behave as viewers goto-page option and should not depend on internal PDF structure (i.e. existence of `PageLabels` entry).\r\nTechnically, in the patch I `return range(pgnum, length=1)` because the function generally return a range: see comment before method `find_page_label`. I'm not sure if this has to be continue object (aka range), or maybe even it could be more general page numbers **vector** (if one may shift back page counter by respective entry in `PageLabels`) - maybe we can consider this."}}
{"actor":{"display_login":"gwierzchowski"}}