Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5968911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:09:23+00:00 2026-05-22T20:09:23+00:00

I would like to draw a rectangle (or more) which printed on paper shows

  • 0

I would like to draw a rectangle (or more) which printed on paper shows the rectangle in units of cm.
So

Graphics[{Rectangle[{0, 0}, {19, 28}], Orange, Rectangle[{0, 0}, {1, 1}]}]

will print out as two rectangles which can be measured as exactly 1cm x 1cm (orange one) and the black one as 19×28 cm.

It seems that some variables are important:
The ImageSize and of course the AspectRatio.

I used AspectRatio->19/28 and for the ImageSize various settings like ImageSize->{19*27,28*27} but it keeps being not very accurate.

I export the graphics to TIFF and then print out with windows photo gallery to a full page photo. Does anyone have experience with this? There must be a formula instead of trial and error.

UPDATE:
I tried the suggestion of @Szabolcs and I used the following code:

   g = Graphics[{White, EdgeForm[Directive[Thick, Black]], 
   Rectangle[{0, 0}, {18, 28}], Orange, Rectangle[{0, 0}, {10, 10}]}]

   final = Show[g, AspectRatio -> Automatic, 
   PlotRange -> {{-0.5, 18.5}, {-0.5, 28.5}}]

   cm = 72/2.54

   Export["final.pdf", Show[final, ImageSize -> {19 cm, 29 cm}]]

This works great. The orange rectangle of 10x10cm is when measured exactly 10x10cm

the cm 72/2.54 value was not what I expected since I though Windows uses 96dpi and Mac 72dpi (reading from the www). However 72 is the value that works.
I’ve also beenn playing with the frames but then it gets ugly. Haven’t found a way to get the right results dispite playing with all possible settings. What should work is create the frames/ticks etc myself inside the selected boundaries but that’s not the path I would like to pursue..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:09:24+00:00Added an answer on May 22, 2026 at 8:09 pm
    g = Graphics[{Rectangle[{0, 0}, {19, 28}], Orange, Rectangle[{0, 0}, {1, 1}]}]
    

    Okay, first thing you need to do is set the x and y directions to use the same units, which means

    Show[g, AspectRatio -> Automatic]
    

    But this is already the default.

    Second thing you need to do is choose a size and range for your plot area. Let’s make it 21 by 30 with your rectangles centred:

    plotArea = {{0, 21}, {0, 30}} - {1, 1}
    Show[g, AspectRatio -> Automatic, PlotRange -> plotArea]
    

    Third thing you need to do is turning off adding any padding/margins that make the actual size of your figure larger than your plot range:

    final = Show[g, AspectRatio -> Automatic, PlotRange -> plotArea, PlotRangePadding -> 0, ImagePadding -> 0]
    

    I believe ImageMargins does not make a difference, but if it does, set that to 0 as well.

    The final thing you need to do is export this to a printable format that preserves the image dimensions, and set the size of the image so that 1 cm will be 1 unit on your plot. Mathematica accepts image sizes in printer’s points, so let’s define:

    cm = 72/2.54
    Export["final.pdf", Show[final, ImageSize -> 21 cm]]
    

    We want the plot to be 21 cm wide because it’s 21 units wide. Use PDF as export format, not TIFF. The ImageSize needs to be used inside Show to work around some problems with Export …

    Now open your PDF in Adobe Reader, open the print dialogue, and make sure that Page Scaling is set to None! I don’t know how to do this in other readers … Also make sure your figure fits the paper (21 by 30 cm is too large for A4 …)

    I’m not going to do a test print, so let me know if this works for you 🙂 The size of the PDF generated this way is exactly 21 by 30 cm, so if something goes wrong, it must happen at the printing stage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to draw a rectangle around a video playing on my screen.
I would like to draw a transparent TMetaFile on a Canvas, used for print
I would like to draw lines (of arbitrary position and length) onto a surface
I would like to draw a random number from the interval 1,49 but I
I would like to draw in C# with the mouse, like if the mouse
I am new to Quartz, and I would like to draw a candlestick chart
I have some (fairly large) UIButtons. Instead of text, I would like to draw
I would like draw a vector-based graphic within a WPF ListBoxItem. The 2D shapes
I would like to draw a grid in perspective and draw a circle in
I would like to draw a table using System.Drawings, and then fill cells with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.