{"action":"closed","issue":{"url":"https://api.github.com/repos/pdfkit/pdfkit/issues/343","labels_url":"https://api.github.com/repos/pdfkit/pdfkit/issues/343/labels{/name}","comments_url":"https://api.github.com/repos/pdfkit/pdfkit/issues/343/comments","events_url":"https://api.github.com/repos/pdfkit/pdfkit/issues/343/events","html_url":"https://github.com/pdfkit/pdfkit/issues/343","id":125228714,"number":343,"title":"Expose middleware's #translate_paths, for non-rack usage","user":{"login":"danbernier","id":13077,"avatar_url":"https://avatars.githubusercontent.com/u/13077?v=3","gravatar_id":"","url":"https://api.github.com/users/danbernier","html_url":"https://github.com/danbernier","followers_url":"https://api.github.com/users/danbernier/followers","following_url":"https://api.github.com/users/danbernier/following{/other_user}","gists_url":"https://api.github.com/users/danbernier/gists{/gist_id}","starred_url":"https://api.github.com/users/danbernier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbernier/subscriptions","organizations_url":"https://api.github.com/users/danbernier/orgs","repos_url":"https://api.github.com/users/danbernier/repos","events_url":"https://api.github.com/users/danbernier/events{/privacy}","received_events_url":"https://api.github.com/users/danbernier/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-01-06T17:58:08Z","updated_at":"2016-01-17T16:04:56Z","closed_at":"2016-01-17T16:04:56Z","body":"The middleware _basically_ just turns a response's HTML into PDF, and streams it back. But a key part of that process is translating the relative asset paths to absolute URLs, so wkhtmltopdf can include them in the result.\r\n\r\nIt'd be nice if this functionality was exposed, rather than hidden inside the Rack middleware.\r\n\r\nHere's my motivating use-case: I have a rails controller action and view that I render as PDF. Separately, I have a form where a user can request that the PDF is generated, and sent to another user. I'm using `render_to_string` to get the HTML for the PDF, but before I can pass it to PDFKit, I need to translate the paths. It works if I `send(:translate_paths, html, env)`, which is of course not a good idea.\r\n\r\nMy current thinking is that #translate_paths could be extracted into a separate PDFKit class, and exposed, but I'd love to hear thoughts on other approaches to solving the problem."}}