1

I've been looking for a way to 'see' more accurately the results of a picture combined with text. When I create some shapes:

  g1 = Graphics[{White, EdgeForm[Directive[Thick, Black]] , 
   Rectangle[{0, 0}, {19, 28}], LightGray, 
   Rectangle[{1, 19}, {9, 27}], Rectangle[{10, 19}, {18, 27}], 
   Rectangle[{1, 23}, {2, 27}]}, 
  Epilog -> { 
    Inset[Text[Style["Information      Here", FontSize -> 8]], {1, 
      25}, {Center, Top}, Automatic, {0, 1}], 
    Inset[Text[Style["some more stuff", FontSize -> 8]], {2, 
      25}, {Center, Bottom}, Automatic, {0, 1}]}]

it shows a scaled down version but the text doesn't fit into the rectangle. However when I port it to pdf it fit's into the rectangle. Is there a way to view the output more as is?

enter image description here

EDIT:

Here's the screenprint (with Windows Snipping Tool) after I changed the the environment to printout. Image after printout environment setting

After this I convert g1 to final1:

final1 = Show[g1, AspectRatio -> Automatic, 
  PlotRange -> {{-0.5, 19.5}, {-0.5, 28.5}}]

This shows the same result and then I export to PDF.

Export["final1.pdf", Show[final1, ImageSize -> {20 cm, 29 cm}]]

I open the PDF (Adobe reader 9) and scale to 40% (for comparison). Here you can see what it looks like in acrobat and on paper.

adobe reader at 40%

This is with Adobe at 100%

Adobe 100%

As you can see there is a clear difference. I could even add a line of text.

EDIT2:

Following Alexey suggestion with code:

In[27]:= SetOptions[$FrontEndSession, 
 PrintingStyleEnvironment -> "Printout"]

In[28]:= Export["finalprintout1.pdf", 
 Show[final1, ImageSize -> {20 cm, 29 cm}]]

Out[28]= "finalprintout1.pdf"

In[29]:= SetOptions[$FrontEndSession, 
 PrintingStyleEnvironment -> "Working"]

In[30]:= Export["finalworking.pdf", 
 Show[final1, ImageSize -> {20 cm, 29 cm}]]

Out[30]= "finalworking.pdf"

It results in the same PDF's. I have no difference at all?

Lou
  • 322
  • 4
  • 12
  • To format code in a more readable fashion, select the code block, and press the {} button. I have submitted an edit to do this. – Chris Walton Jun 06 '11 at 15:36
  • @Chris Walton, Thx I started with the four spaces but that didn't work. Like adding a picture with IExplorer.. Worked with Chrome though! – Lou Jun 06 '11 at 16:22
  • Using Mathematica 7 on Windows XP, the text does not fit in the box even when I export to PDF. – Mr.Wizard Jun 06 '11 at 17:38
  • What happens if you specify an appropriate ImageSize to Graphics? (Bear in the mind the ImageResolution option for PDF export, which has a default setting of 72 dpi.) – Andrew Moylan Jun 07 '11 at 06:26

1 Answers1

3

Switch Screen Environment to "Printout" (menu Format -> Screen Environment -> Printout) and this graphics on-screen will look exactly as it looks in exported PDF. Do not resize the graphics inside Notebook by hands! Just increase magnification to see fine details.

The reason for this behavior is that Export in Mathematica uses by default the "Printout" screen style environment rather than "Working" when exporting to PDF.

P.S. This question is related: "How to export graphics in “Working” style environment rather than “Printout”?". Also related: "General PDF/EMF export problems and solutons". Try the solution suggested by Mr.Wizard if you wish to export graphics as it looks by default.

EDIT

More clear example:

g1 = Graphics[{White, EdgeForm[Directive[Thick, Black]], LightGray, 
   Rectangle[{1, 23}, {2, 27}]}, 
  Epilog -> {Inset[
     Text[Style["Information      Here", FontSize -> 50]], {1, 
      25}, {Center, Top}, Automatic, {0, 1}], 
    Inset[Text[Style["some more stuff", FontSize -> 50]], {2, 
      25}, {Center, Bottom}, Automatic, {0, 1}]}]

Try to switch between Screen Environments and you will see the difference. Try to Export to PDF and compare:

Export["C:\\1.pdf", g1]

Now evaluate:

SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"]

Export again:

Export["C:\\2.pdf", g1]

and compare...

enter image description here enter image description here

Community
  • 1
  • 1
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93
  • @Alexey Could you post the resulting image? I can't get the desired result with [Printout] :( – Dr. belisarius Jun 06 '11 at 17:11
  • @belisarius The graphics suggested in the question is very lame as an illustration. In really I do not get PDF where the text "fit's into the rectangle". But on careful comparison with Magnification 300% I see little difference (in text placement and size) depending on screen environment and it matches what I see in PDF. – Alexey Popkov Jun 06 '11 at 17:45
  • @Alexey Thanks. I thought you got it right and I was missing something – Dr. belisarius Jun 06 '11 at 17:55
  • @belisarius Please try the cleared example graphics in the EDIT section. – Alexey Popkov Jun 06 '11 at 18:00
  • @Alexey Yes the example is lame. I'll update the question later. I tried the printout env setting and it's a bit better but I still see a difference. @Mr Wizard I use Vista with mm8.01. – Lou Jun 06 '11 at 18:00
  • @Alexey I see almost the same picture in both environments, only the size changes. Don't mind, it should be something non standard in my configuration. – Dr. belisarius Jun 06 '11 at 18:04
  • @belisarius I have added screenshots (I use *Mathematica* 7.0.1 for Windows). – Alexey Popkov Jun 06 '11 at 18:12
  • @Alexey Thanks ... my screen looks completely different :) Never mind – Dr. belisarius Jun 06 '11 at 18:13
  • @Alexey thx for the answer. I edited my question with my results to make it more clear. I'll try the switching again. – Lou Jun 06 '11 at 18:30
  • @Lou Have you tried the example in the EDIT section of my answer? It shows as huge dependence on the environment settings on my machine as shown. – Alexey Popkov Jun 06 '11 at 18:51
  • @Lou Try `SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"]` and exporting after restarting *Mathematica*. This form changes global settings permanently but works much more reliable than with `$FrontEndSession`. – Alexey Popkov Jun 06 '11 at 18:55
  • @Alexey I now see a difference and now it looks more similar to what I see. I also believe that the export with the Show[] and ImageSize has an impact (I needed that to have the exact dimension in cm as answered in my previous question). I'll create two nb's with the different settings and restart MM – Lou Jun 06 '11 at 19:07
  • @Lou You should realize that by evaluating `SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"]` you change settings *globally*, not just for the current Notebook. It will affect `Export`ing from all Notebooks. You can revert it backward by evaluating `SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Printout"]`. – Alexey Popkov Jun 06 '11 at 19:17
  • @Alexey. Created two nb's one with SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"] and the other with SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Printout"]. Both PDF's generated the same picture. I restarted mm in between. – Lou Jun 06 '11 at 19:19
  • @Alexey The difference is made by the way I use export. When I use the export as Export["printout.pdf", Show[final1, ImageSize -> {20 cm, 29 cm}]] regardless of the PrintingStyleEnvironment the pdf's are the same. When I just use export with no additional parameters I get a different result but not as different like yours.. – Lou Jun 06 '11 at 19:33
  • @Lou As I understand you are experimenting with the code you given in your question. As I already mentioned before, for this graphics the difference is little. Try my code for graphics in the EDIT section. – Alexey Popkov Jun 07 '11 at 02:14