{"action":"created","issue":{"url":"https://api.github.com/repos/ariya/phantomjs/issues/14891","repository_url":"https://api.github.com/repos/ariya/phantomjs","labels_url":"https://api.github.com/repos/ariya/phantomjs/issues/14891/labels{/name}","comments_url":"https://api.github.com/repos/ariya/phantomjs/issues/14891/comments","events_url":"https://api.github.com/repos/ariya/phantomjs/issues/14891/events","html_url":"https://github.com/ariya/phantomjs/issues/14891","id":213506214,"number":14891,"title":"Implementing PDF \"Bookmark\" feature","user":{"login":"dhilipsiva","id":502170,"avatar_url":"https://avatars1.githubusercontent.com/u/502170?v=3","gravatar_id":"","url":"https://api.github.com/users/dhilipsiva","html_url":"https://github.com/dhilipsiva","followers_url":"https://api.github.com/users/dhilipsiva/followers","following_url":"https://api.github.com/users/dhilipsiva/following{/other_user}","gists_url":"https://api.github.com/users/dhilipsiva/gists{/gist_id}","starred_url":"https://api.github.com/users/dhilipsiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhilipsiva/subscriptions","organizations_url":"https://api.github.com/users/dhilipsiva/orgs","repos_url":"https://api.github.com/users/dhilipsiva/repos","events_url":"https://api.github.com/users/dhilipsiva/events{/privacy}","received_events_url":"https://api.github.com/users/dhilipsiva/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-03-11T05:07:47Z","updated_at":"2017-03-13T16:12:54Z","closed_at":null,"body":" am implementing PDF \"Bookmark\"  feature. I am working at a startup where we generate reports in PDF and I really need this feature.\r\n\r\nI read the contributing guideline. And I created the a new Discussion Thread on Google Groups: https://groups.google.com/forum/#!topic/phantomjs/EV2IwIuhjtk . \r\n\r\nBut I find it a bit less active. Also, I need to implement this feature over this weekend. Since this looks \"must-have\" features, I thought I will go-ahead and create an Issue here directly. So let me cross post the content here\r\n\r\n**Here is what I researched so far**:\r\n\r\nAFAICT, many people wanted this feature since June 2013 (nearly 4 years as of writing this). Here are some of the Issues that I could come across on GitHub. Most of them are still open:\r\n\r\n- [Add \"Layout\" to generate PDF file](https://github.com/ariya/phantomjs/issues/11442)\r\n- [When rendering to PDF, turn relative fragment identifiers into \"bookmark\" links](https://github.com/ariya/phantomjs/issues/13959)\r\n- [Bookmark for HTML file converted to pdf](https://github.com/ariya/phantomjs/issues/14019)\r\n- [Html to Pdf conversion](https://github.com/ariya/phantomjs/issues/14673)\r\n- [Memory leak with WebPage class, multiple page loads](https://github.com/ariya/phantomjs/issues/11390#issuecomment-278970727)\r\n\r\nAnd maybe many more, but I am not sure. And there are still few unanswered questions on StackOverflow and Quora regarding this same issue. So it is clear that this is a feature that needs to be there. \r\n\r\n**I have done my home work**:\r\n\r\nIf I am not wrong, I think the logic to add bookmarks will go here: https://github.com/ariya/phantomjs/blob/6abff248109fe2b6c0e7581e06dcf3c52b64a15d/src/webpage.cpp#L1291\r\nAnd that I should use: https://github.com/qt-labs/qtpdf/blob/dev/src/pdf/qpdfbookmarkmodel.cpp to create bookmarks.\r\n\r\n**This is how I thought I should approach the problem**:\r\n\r\nI will add a `bookmark` object to the `webpage` object. And when we renderPdf(), I will look at this attribute to determine wether we should create a bookmark or not. Booksmarks will be created only if this attribute is set - that way, we do catch the people who are already using it by surprise (It will be disabled by default). First, I will parse through the page to find all heading tag and nest it, if need be. Then find \"Fragment Identifiers\" in a HTML and convert it into a Bookmark (nesting it under respective heading bookmarks).\r\n\r\n**This is related to the following Issues**: #11442, #13959, #14019, #14673\r\n\r\n**CC**: @ylf2345, @gladson, @anko, @dwarburt, @neilsustc, @hammond13, @caleblloyd, @ckreon, @jasonswearingen, @astefanutti, @wazico, @Nikolay-Kha, @MirrorC, @v-anyukov, @mwittmann, @AttitudeMonger, @sambasivaraomangapati\r\n\r\nAny pointers/suggestions/inputs are greatly appreciated. "},"comment":{"url":"https://api.github.com/repos/ariya/phantomjs/issues/comments/286156665","html_url":"https://github.com/ariya/phantomjs/issues/14891#issuecomment-286156665","issue_url":"https://api.github.com/repos/ariya/phantomjs/issues/14891","id":286156665,"user":{"login":"jasonswearingen","id":814134,"avatar_url":"https://avatars3.githubusercontent.com/u/814134?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonswearingen","html_url":"https://github.com/jasonswearingen","followers_url":"https://api.github.com/users/jasonswearingen/followers","following_url":"https://api.github.com/users/jasonswearingen/following{/other_user}","gists_url":"https://api.github.com/users/jasonswearingen/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonswearingen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonswearingen/subscriptions","organizations_url":"https://api.github.com/users/jasonswearingen/orgs","repos_url":"https://api.github.com/users/jasonswearingen/repos","events_url":"https://api.github.com/users/jasonswearingen/events{/privacy}","received_events_url":"https://api.github.com/users/jasonswearingen/received_events","type":"User","site_admin":false},"created_at":"2017-03-13T16:12:54Z","updated_at":"2017-03-13T16:12:54Z","body":"it's a tough issue, props to you for giving it a try :)"}}
{"actor":{"display_login":"jasonswearingen"}}