{"action":"created","issue":{"url":"https://api.github.com/repos/llgcode/draw2d/issues/108","repository_url":"https://api.github.com/repos/llgcode/draw2d","labels_url":"https://api.github.com/repos/llgcode/draw2d/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/llgcode/draw2d/issues/108/comments","events_url":"https://api.github.com/repos/llgcode/draw2d/issues/108/events","html_url":"https://github.com/llgcode/draw2d/issues/108","id":174012826,"number":108,"title":"draw2dpdf: No file created by call to SaveToPdfFile","user":{"login":"Marneus68","id":878305,"avatar_url":"https://avatars.githubusercontent.com/u/878305?v=3","gravatar_id":"","url":"https://api.github.com/users/Marneus68","html_url":"https://github.com/Marneus68","followers_url":"https://api.github.com/users/Marneus68/followers","following_url":"https://api.github.com/users/Marneus68/following{/other_user}","gists_url":"https://api.github.com/users/Marneus68/gists{/gist_id}","starred_url":"https://api.github.com/users/Marneus68/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marneus68/subscriptions","organizations_url":"https://api.github.com/users/Marneus68/orgs","repos_url":"https://api.github.com/users/Marneus68/repos","events_url":"https://api.github.com/users/Marneus68/events{/privacy}","received_events_url":"https://api.github.com/users/Marneus68/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-30T13:01:40Z","updated_at":"2016-09-01T08:56:34Z","closed_at":null,"body":"Hi,\r\n\r\nI have created a simple sample myself to validate the creation of pdf files from postscript files using [draw2d](https://github.com/llgcode/draw2d) in conjunction with [ps](https://github.com/llgcode/ps).\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n        \"github.com/llgcode/draw2d\"\r\n        \"github.com/llgcode/draw2d/draw2dpdf\"\r\n        \"github.com/llgcode/ps\"\r\n        \"io/ioutil\"\r\n        \"log\"\r\n        \"os\"\r\n        \"strings\"\r\n)\r\n\r\nfunc main() {\r\n        pdf := draw2dpdf.NewPdf(\"P\", \"mm\", \"A4\")\r\n        gc := draw2dpdf.NewGraphicContext(pdf)\r\n\r\n        gc.Translate(0, 200)\r\n        gc.Scale(0.35, -0.35)\r\n        gc.Translate(70, -200)\r\n\r\n        Draw(gc, \"tiger.ps\")\r\n        gc.Restore()\r\n\r\n        draw2dpdf.SaveToPdfFile(\"tiger.pdf\", pdf)\r\n}\r\n\r\nfunc Draw(gc draw2d.GraphicContext, filename string) {\r\n        // Open the postscript\r\n        src, err := os.OpenFile(filename, 0, 0)\r\n        if err != nil {\r\n                log.Fatal(err.Error())\r\n        }\r\n        defer src.Close()\r\n        bytes, err := ioutil.ReadAll(src)\r\n        reader := strings.NewReader(string(bytes))\r\n\r\n        // Initialize and interpret the postscript\r\n        interpreter := ps.NewInterpreter(gc)\r\n        interpreter.Execute(reader)\r\n}\r\n```\r\n\r\nWhen trying to convert the [tiger.ps](https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/tiger.ps) (an exact copy of the one present in the examples provided with draw2d) no file is created and no error message is displayed on the standard output.\r\n\r\nWhen replacing the file by a much simpler postscript file ([this one for instance](https://ftp.scsh.net/pub/scsh/contrib/fps/doc/examples/ps/fractal-sqr.ps)) it does create a pdf.\r\n\r\nAm I doing something wrong or is this an unexpected behavior?\r\n\r\nAdditionally, is there any way to reliably test for errors when saving the pdf file?"},"comment":{"url":"https://api.github.com/repos/llgcode/draw2d/issues/comments/244018121","html_url":"https://github.com/llgcode/draw2d/issues/108#issuecomment-244018121","issue_url":"https://api.github.com/repos/llgcode/draw2d/issues/108","id":244018121,"user":{"login":"llgcode","id":524083,"avatar_url":"https://avatars.githubusercontent.com/u/524083?v=3","gravatar_id":"","url":"https://api.github.com/users/llgcode","html_url":"https://github.com/llgcode","followers_url":"https://api.github.com/users/llgcode/followers","following_url":"https://api.github.com/users/llgcode/following{/other_user}","gists_url":"https://api.github.com/users/llgcode/gists{/gist_id}","starred_url":"https://api.github.com/users/llgcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llgcode/subscriptions","organizations_url":"https://api.github.com/users/llgcode/orgs","repos_url":"https://api.github.com/users/llgcode/repos","events_url":"https://api.github.com/users/llgcode/events{/privacy}","received_events_url":"https://api.github.com/users/llgcode/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T08:56:34Z","updated_at":"2016-09-01T08:56:34Z","body":"Hi @Marneus68 \r\nI think you can test error like this\r\nerr := draw2dpdf.SaveToPdfFile(\"tiger.pdf\", pdf)\r\nif err != nil {\r\n   // there's an error\r\n}\r\n"}}
{"actor":{"display_login":"llgcode"}}