<div dir="ltr">I found empirically that when I save a image to pdf I need to scale it by 1.25.<div><br></div><div>Code below.<br><div><br></div><div>Why? Is there a setting I should use instead?</div><div><br></div><div><br>
</div><div>Thanks</div><div><br></div><div>Dan</div><div><br clear="all"><div><br></div><div>#lang racket</div><div><br></div><div>(provide image->pdf)</div><div><br></div><div>(require racket/draw</div><div> (only-in 2htdp/image</div>
<div> save-image</div><div> image-width</div><div> image-height</div><div> scale</div><div> ))</div><div><br></div><div>(define (image->bitmap image)</div>
<div> (let* ([width (image-width image)]</div><div> [height (image-height image)]</div><div> [bm (make-bitmap width height)]</div><div> [dc (send bm make-dc)])</div><div> (send dc clear)</div>
<div>
(send image draw dc 0 0 0 0 width height 0 0 #f)</div><div> bm))</div><div><br></div><div>(define (image->pdf image output-file)</div><div> (define dc</div><div> (new pdf-dc%</div><div> [ interactive #f ]</div>
<div> [ use-paper-bbox #f ]</div><div> [ width (image-width image)]</div><div> [ height (image-height image)]</div><div> [ output output-file ]))</div><div> </div><div> (send* dc</div><div>
(start-doc "useless string")</div><div> (start-page))</div><div> </div><div> (send dc draw-bitmap (image->bitmap (scale 1.25 image)) 0 0)</div><div> </div><div> (send* dc </div><div> (end-page)</div>
<div> (end-doc)))</div><div><br></div><div>(module+ test</div><div> (require (only-in 2htdp/image</div><div> circle text square overlay above))</div><div> </div><div> (define im </div><div> (overlay</div>
<div> (above</div><div> (circle 50 'solid 'red)</div><div> (text "This is a red circle" 12 'black))</div><div> (square 150 'solid 'lightblue)))</div><div> </div><div> (image->pdf im "image-test.pdf")</div>
<div> (save-image im "image-test.png"))</div><div dir="ltr"><div style="font-family:arial;font-size:small"></div></div>
</div></div></div>