{"id":26,"date":"2009-03-03T08:02:12","date_gmt":"2009-03-03T13:02:12","guid":{"rendered":"http:\/\/coherentpdf.com\/blog\/?p=26"},"modified":"2010-02-16T10:05:13","modified_gmt":"2010-02-16T15:05:13","slug":"a-pdf-version-of-ocamls-graphics-module","status":"publish","type":"post","link":"https:\/\/coherentpdf.com\/blog\/?p=26","title":{"rendered":"A PDF Version of OCaml&#8217;s Graphics Module"},"content":{"rendered":"<p>I&#8217;ve just completed a PDF version of the <a href=\"http:\/\/caml.inria.fr\/pub\/docs\/manual-ocaml\/manual039.html\">Graphics<\/a> module from the standard OCaml distribution, based on <a href=\"http:\/\/www.coherentpdf.com\/ocaml-libraries.html\">CamlPDF<\/a> and following the conventions of Pierre Weis&#8217; Postscript version <a href=\"http:\/\/pauillac.inria.fr\/graphps\/\">GraphPS<\/a>.<\/p>\n<p>The implementation is mostly straightforward, but there are are some complications &#8211; some shapes (arcs etc.) need to be approximated from bezier curves sections, since they don&#8217;t exist as primitives in PDF (Oddly, circles and arcs are primitive in PostScript).<\/p>\n<p>In common with GraphPS, it doesn&#8217;t yet support the bitmapped image parts of the Graphics module, though that would be easy to add.<\/p>\n<p>Here&#8217;s a particularly luridly coloured example (source PDF <a href=\"http:\/\/www.coherentpdf.com\/graph.pdf\">here<\/a>):<\/p>\n<p><a href='https:\/\/coherentpdf.com\/blog\/wp-content\/uploads\/2009\/03\/pdf.png'><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/coherentpdf.com\/blog\/wp-content\/uploads\/2009\/03\/pdf.png\" alt=\"Example GraphPDF Output\" title=\"Example GraphPDF Output\" width=\"470\" height=\"534\" class=\"aligncenter size-full wp-image-27\" srcset=\"https:\/\/coherentpdf.com\/blog\/wp-content\/uploads\/2009\/03\/pdf.png 470w, https:\/\/coherentpdf.com\/blog\/wp-content\/uploads\/2009\/03\/pdf-264x300.png 264w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/a><\/p>\n<p>GraphPDF will ship with the next release of CamlPDF.<\/p>\n<p>What might be nice for the future would be a single module shipping with OCaml which can be used as the ordinary graphics module would be, and then dump the result to PDF when required.<\/p>\n<p>We&#8217;d need to extend the graphics module with the ability to optionally keep a list of all commands executed thus far, but that&#8217;s about all. Getting the PDF output into Ocaml would require some license work on CamlPDF, though, so won&#8217;t happen yet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve just completed a PDF version of the Graphics module from the standard OCaml distribution, based on CamlPDF and following the conventions of Pierre Weis&#8217; Postscript version GraphPS. The implementation is mostly straightforward, but there are are some complications &#8211; &hellip; <a href=\"https:\/\/coherentpdf.com\/blog\/?p=26\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-ocaml"],"_links":{"self":[{"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":0,"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coherentpdf.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}