Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graph elements with transparency not showing up when imported into MS Word for Windows

    When I -graph export- figures that contain items with transparency (using updated Stata 15.1 MP on Mac OSX), I get two issues:

    1. When exporting to .eps format, I see no transparency at all. (I think the response is probably that the eps format lacks some ability for transparency ((similar to how it has issues using certain system fontface/styles)) , but I couldn't find anything in the manuals that led me to expect this behavior)

    2. More importantly (to me), when I export the graph to .pdf (my preferred file export format for my workflow) the transparent elements do not show up if I import the graph into MS Word for Windows - they do however show up in the same document on MS Word for Mac OSX (all versions of MS office and OS are latest updates). Any elements that have transparency within the graphs do not show up on the Windows version. Transparent elements in the graph do show up if I export to png.

    A few more notes:
    • By transparency, I mean something like (see - help colorstyle-):
    Code:
    scatter x y, mcolor(red%50)
    and then :

    Code:
    graph export "fig1.png" , as(png) // transparent elements show up in Mac AND windows version of word, but I prefer not to use this since the resolution for png file is low quality in Word files - I prefer pdf or eps
    graph export "fig1.pdf" , as(pdf) //transparent elements only show up in Mac version of Word
    graph export "fig1.eps" , as(eps) //transparent elements appear solid
    Any non-transparent elements show up without issues in all versions of the figure in both types of OS.
    • By 'import the graph into MS Word' I mean that I have tried both drag/dropping the file into the document and using the 'insert from file' and 'insert picture' from the drop-down menus in MS Word. I get the same result with each method. ((I assume this has to do with the way that MS Word for Windows converts the pdf image when it's imported? [R figures with transparency show up without any issue] ))
    Has anyone else had this issue or found a solution for transparency in PDF files in MS Word for Windows??


    Last edited by eric_a_booth; 03 Apr 2018, 17:23.
    Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

  • #2
    I can only confirm that I have the same problem here in Mac OSX (high sierra). *.pdf and *.pngs are okay but *.eps ignoring color transparency.
    Roman

    Comment


    • #3
      I have three thoughts.

      First, this sounds less like a feature and more like a bug of some sort, although it is not clear to me where the bug lies. StataCorp staff have discussed the use of native macOS code to create png files; perhaps something similar occurs with pdf and eps as well. In which case we can have a three-way battle between StataCorp, Apple, and Microsoft to place the blame. You might refer this question to Stata Technical Services.

      Second, I know this isn't the answer you want to hear, but you can use the height() and width() options on export png to increase the size, which otherwise defaults to the size of your Graph window. When the larger png is scaled down in Word, the resolution is improved. Of course that increases the file size and the size of your Word document, and isn't a solution any good-thinking believer in the supremacy of vector graphics would espouse, but if you've got a deadline near, it may let you make progress.

      And third, I was surprised that pdf and eps behave differently. Dumps of the two files show that the eps is apparently generated by Stata; while I'd guess the pdf is, like the png, generated by native macOS functionality. This suggests there's some hope the eps issues lie with and are correctable by StataCorp.
      Last edited by William Lisowski; 03 Apr 2018, 18:34.

      Comment


      • #4
        what happenbs if you use th eclipboard copy/paste function to paste directly into MS Word?

        on Windows with Stata14, graphic fills with reduced intensity would appear corectly when pasted as metafiles, but the fiull regions got messed up when I tried editting the pasted figs in Word or Powerpoint.
        on windows10 / Stata15, the fill regions, even if reduced intensity and opacity, appear correctly. however, editing in PP still messes these up with editing. i do recall that this worked for a while, but i can not able to recall the OR/Office/Stata combo
        i will test some more.

        one of the main reasons i keep using Windows is for the way it handles graphics information that allows cut/paste while retining both ector info and editing ability
        in OSX, there is no way to edit the pasted figs - at least i couldn;t figure it out.

        Comment


        • #5
          1. When exporting to .eps format, I see no transparency at all. (I think the response is probably that the eps format lacks some ability for transparency ((similar to how it has issues using certain system fontface/styles)) , but I couldn't find anything in the manuals that led me to expect this behavior)
          The EPS format is a legacy graphics format and does not support transparency. I thought we did mention somewhere that the EPS format doesn't support transparency but I'll ask our group in charge of documentation about this.

          2. More importantly (to me), when I export the graph to .pdf (my preferred file export format for my workflow) the transparent elements do not show up if I import the graph into MS Word for Windows - they do however show up in the same document on MS Word for Mac OSX (all versions of MS office and OS are latest updates). Any elements that have transparency within the graphs do not show up on the Windows version. Transparent elements in the graph do show up if I export to png.
          I'm using MS Word 2016 for Windows which evidently doesn't support PDF at all because nothing shows up when I insert a PDF into Word much less one with transparency. I'll look into trying it on a more recent version. However, you can export graphs from Stata for Windows using the EMF+ format which does support transparency. Just save the graph as an EMF file and Stata will output the graph in both EMF/EMF+ formats within one file. This allows legacy applications that don't support the EMF+ format to still import our graphs.
          -Chinh Nguyen

          Comment


          • #6
            • By 'import the graph into MS Word' I mean that I have tried both drag/dropping the file into the document and using the 'insert from file' and 'insert picture' from the drop-down menus in MS Word. I get the same result with each method. ((I assume this has to do with the way that MS Word for Windows converts the pdf image when it's imported? [R figures with transparency show up without any issue] ))
            I've been told that Word for Windows does not support importing PDF without a plugin. After you drag and drop or insert a Stata graph that was exported as a PDF into Word for Windows, are you saying that you see the graph image but with no transparency (the marker symbols are visible but fully opaque)? When you say that "R figures with transparency show up without any issue", are you saying that the R figure, with transparency, is exported as a PDF and that PDF is inserted into Word for Windows and that the transparency is visible?
            -Chinh Nguyen

            Comment


            • #7
              Originally posted by Chinh Nguyen (StataCorp) View Post

              The EPS format is a legacy graphics format and does not support transparency.
              That is disappointing; I have journal guidelines that state

              EPS (Encapsulated PostScript) is the preferred format for vector graphics (charts, graphs, technical drawings, annotated images).
              In tracking down more info about EPS, I find that in the next few months Microsoft will be removing the ability to insert EPS graphics into Office documents using Office for Mac; this apparently was removed from the Windows versions in 2017. I expect this implies that PDF files as well will no longer be able to be inserted - I'm guessing that PDFs are inserted by converting them to EPS.

              Office supports for vector graphics, only SVG (which Stata for Mac can produce) and various Windows Metafile formats (which Stata for Mac, which Eric and I both use, cannot produce).

              More from Microsoft at the following link, and my thanks to the Wikipedia article on EPS for the heads-up.

              https://support.office.com/en-us/art...5-cbb0c334a840

              https://en.wikipedia.org/wiki/Encapsulated_PostScript

              Comment


              • #8
                Chinh Nguyen (StataCorp) Thanks for the quick reply - sorry I'm just now getting back to this thread.

                The EPS format is a legacy graphics format and does not support transparency. I thought we did mention somewhere that the EPS format doesn't support transparency but I'll ask our group in charge of documentation about this.
                I probably just missed it in the documentation/help files, but William Lisowski 's right that there is still a need for eps (when I use it, I do so with the understanding that it's a legacy format & I dont expect the font/typeface to work in EPS, so now I'll just add similar expectations for transparency).

                I'm using MS Word 2016 for Windows which evidently doesn't support PDF at all because nothing shows up when I insert a PDF into Word much less one with transparency. I'll look into trying it on a more recent version. However, you can export graphs from Stata for Windows using the EMF+ format which does support transparency. Just save the graph as an EMF file and Stata will output the graph in both EMF/EMF+ formats within one file. This allows legacy applications that don't support the EMF+ format to still import our graphs.I might have just missed this.
                I dont have the set up to be able to export emf files and for this project I create the pdf images and then send them to a (non-Stata user) colleague who inserts them in a Word doc manually (I know there are a lot of issues with this workflow and it's a (necessary) exception to my usual workflow involving latex/html/or putdocx). I do wish there was a way to export to emf files on the Mac even if I cannot use/view them.
                Apparently my colleague does have a plug-in which explains the drag/drop approach, but to address William's comment about the conversion that's happening from what I've read (on non-official blog sites) the conversion in the background on the Mac is from pdf to a binary file (like netpbm/ppm), not eps, so hopefully that functionality wont be affected by the changes you are citing.

                An important note: When I -graph export- to pdf in Stata for Mac and then manually drag/drop the pdf into a Word file on the Mac the graph elements with transparency show up. However, if I email that file to a colleague with Windows and they open the file, the (converted) pdf images in the document do show up but the elements with transparency are missing from the figures. This might be the most concerning/important issue for anyone working across these platforms - if you do not convert the image to png before inserting it on MS Word for Mac you might lose information in the image if you share with someone with MS Word for Windows.

                Unless I'm missing something this means that the highest quality graphics will come from this workflow - but I'd love to hear that this is wrong or better ideas:
                • Windows Word: EMF
                • Mac Word (and *tex ): PDF (or eps), but convert to png to avoid losing information.
                • HTML: SVG (though I use large pngs quite often. Also, does Stata for Windows produce SVG or only Stata for Mac?)
                In researching the option William mentions about increasing the size (height/width) of the png, I discovered this thread which describes how in Mac OSX the image resolution is set to 'high fidelity' (essentially the highest resolution/dpi) by default but in windows it's set much lower and that you have to access the File>Options>Advanced menu to turn on a high fidelity image import (some users report it doesnt change globally, so you have to do it for each document). We tried this and did notice considerable differences in quality of the png files that were inserted into Word on Windows. (Of course, as William mentions, increasing the size and dpi of these images like this quickly bloats a MS Word doc with 100 figures/images)

                https://answers.microsoft.com/en-us/...f-58fa6216dc8b


                Last edited by eric_a_booth; 05 Apr 2018, 06:58.
                Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

                Comment


                • #9
                  eric_a_booth Thanks for the comprehensive report.

                  It led me to realize that I had misinterpreted the Microsoft document I cited in post #7. All references in that document to "Office" and "Office 365" refer only to the Windows version; despite my having an "Office 365 subscription" the Mac product is instead "Office 2016 for Mac". So Mac users are apparently unaffected by the announced removal of support for EPS in "Office" and "Office 365", contrary to what I wrote, and also, SVG is supported in "Office", but apparently not in "Office 2016 for Mac" based on my attempt just now, inspired by Eric's post #8.

                  It appears there's no reliable cross-platform support for vector graphics in the Office/Office 365/Office for Mac range of products. An exception may be WMF format, but that would depend on the availability and quality of a Mac utility for converting PDF or SVG to WMF. An unauthoritative web site claimed that inserting a PDF into a Word document was done by converting it to WMF and embedding the WFM, but if that were the case, Eric's experience suggests it's done unreliably.

                  Comment


                  • #10
                    I was able to import a couple of PDF images into Word but the result was not very good. I just don't think MS Office for Windows supports importing PDF natively. Without a plugin, I used Insert Object to insert the PDF which resulted in a very rough image preview of my graphs (a Stata graph with transparency and an R chart with transparency). Outputting that Word document resulted in similarly less than desirable output. I'm curious as to what steps were taken to import an R chart with transparency into Word because I believe the limitation is with Word's (limited) support for PDF, not Stata's PDF export.

                    Supposedly, MS Office with Office 365 subscription does support importing of SVG.

                    Stata for all platforms does support exporting to SVG and assuming you have a version of MS Office that supports it, could be the ideal solution for your cross platform workflow. One limitation with Stata's SVG implementation is font support. I won't get into specifics but portable fonts is a tricky problem with SVG and one we hope to work on in the future.
                    -Chinh Nguyen

                    Comment


                    • #11
                      With reference to my post #9 above, as of Microsoft Office 2016 for Mac release 16.12 (April 11 2018) SVG graphics are now supported in Word, PowerPoint, and Excel, per the following Mac release note.

                      https://support.office.com/en-us/art...4-7e3209681a41

                      The following support link from Microsoft describes SVG support (insertion and editing) across the range of platforms.

                      https://support.office.com/en-us/art...5-dbe5e7ea528c

                      I will add that this document says that SVG support is only available if you have an Office 365 subscription. I do not know if this means that someone who made a one-time purchase of Office 2016 does not get upgrade 16.12, or if Microsoft was just trying to say that older versions (Office 2011 for Mac, e.g.) do not have this capability.

                      So it appears going forward that Microsoft has embraced SVG support as a replacement for EPS support. This suggests that Eric's recommendation in post #8 above could become SVG across the board, with illustrations supplied as EPS files (typically journals want them separated from the text and tables) to journals that continue to require that format.

                      Comment


                      • #12
                        Hi all, I only found this thread now, but am still dealing with this issue in late 2023 (though I did figure out a couple of workarounds--see below). Hopefully Stata can find a way of resolving this at some point since, as a previous post noted, .png/.pdf graphs that are created in R do not seem to have this issue.

                        Basically the issue is this: I use Stata on a Mac and when making graphs that have any somewhat transparent elements (or italicized/bolded text), it does not display correctly when opened in Microsoft Office for PC. It does not matter how I insert the graph into Word--whether a .pdf, .png, or copied and pasted directly from Graph Editor, the problem always happens. It's been happening across different versions of both Stata and Word.

                        See here for a side-by-side view of how such a graph looks on a PC (left) vs. how it should look (right). The colors disappear; the text becomes illegible. It's especially frustrating because everything looks fine on my Mac, but then I learn from co-authors using PCs that the graphs look badly distorted. This also happens when submitting research articles to journals--once I preview the file it generates, the graphs look extremely distorted.

                        I hope this can eventually be resolved, but for any other Mac users else coming across this issue, here are two approaches that seem to work:
                        1. Just take a screenshot of the graph and insert the screenshot into Word. This is simple to do and does not result in any distortion when opened on a PC.
                        2. Save the graph file as a .png file. Then use a free online PDF converter (I had luck with Adobe : you might need to make account after one or two PDFs, but the account to use the PDF converter is free). Once you download the PDF, just insert it into your Word document. It should look correct when opened on a PC.
                        Would love to know if others are still experiencing this issue or if people have found even better/easier workarounds.



                        Last edited by John Kane; 31 Aug 2023, 20:55.

                        Comment


                        • #13
                          I also am experiencing the same problem John Kane describes above.

                          Comment

                          Working...
                          X