in

The ORM Foundation

Get the facts!

Support for images in PDF documents

Last post 01-17-2014 4:57 by Ken Evans. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-16-2014 3:53

    • koneill
    • Top 25 Contributor
      Male
    • Joined on 02-17-2012
    • The Netherlands
    • Posts 25

    Support for images in PDF documents

    Hi,

    Feature which would be nice to have is an image format that can be displayed in PDF's made in Microsoft Word. Copying an ORM diagram from Visual Studio into a Word document works fine, but if you save it as a PDF the image is no longer displayed.The workaround I use now is to make a screen capture of the picture in Visual studio. However this isn't as sharp as the original and is a bit fiddly.

     Regards,

    Karl

  • 01-16-2014 12:07 In reply to

    Re: Support for images in PDF documents

    Hi Karl,

    Have you considered using Snagit for this?

    You can save a Snagit screen caputure in many formats such as PDF, PNG, JPG, MP4 and SWF.


    Ken

    Filed under:
  • 01-16-2014 15:38 In reply to

    Re: Support for images in PDF documents

    Hi Karl,

    NORMA doesn't have direct PDF support, but the web-viewers at http://ormsolutions.com/tools/orm.aspx and http://ormsolutions.com/tools/ormPrint.aspx display ORM diagrams (but not the relational view) from any browser that can print to PDF. I'd recommend Chrome, which has a built-in 'print to pdf' feature. I've also tried Bullzip's PDF printer, but the results are nowhere near as sharp as the built-in Chrome PDF print. I haven't tried any of the Adobe-native PDF printers.

    You'll need Chrome, Firefox or IE10+ to open .orm files locally with the web viewers.

    Depending on how low-level you want to get, you can also grab the SVG for a diagram directly from the web viewers using a browser debugger. In Chrome, open the JavaScript console with Ctrl-Shift-J, click on the Elements tab (upper left of the debug window), and expand the html elements until you find the svg you need. You'll see parts of the browser window highlight as you mouse over the html for the elements. If the diagram highlights, expand the element. Once you've located the svg for your diagram, you can then right click on the collapsed svg element and 'Copy HTML' to get the raw svg, which you should be able to use with a PDF editor.

    The diagram size can be adjusted with the zoom dropdown on the page, or with the scale query parameter on the page. The default scale is 1.2, so ...orm.aspx?scale=2.4 will make the 100% zoom level on the page twice the normal size.

    The ormPrint.aspx is still pretty basic. I don't have any fit-to-page style support or zoom settings for individual diagrams. Zooming individual diagrams is a pain, so I need to dig into HTML5 printing support at some point and figure out how to print wide diagrams (currently truncated, long diagrams go to the next page). This currently prints one diagram per page in the generated PDF.

    -Matt

    PS IMO, the SVG is actually clearer than the EMF produced by NORMA. There is an extremely low-level bug (in the native GDI+ libraries, below the .NET libraries) that leaves an uninitialized field in the EMF properties for dashed lines. This results in very large purple or blue blobs if the meta files are pulled into tools that look at this field. Short of figuring out how to identify the garbage data, then scanning and cleaning the EMF on the clipboard, there is nothing I can do about this. Unfortunately, it has been known to cause major problems for some printer drivers and non-MS tools. So, if you're pasting to word, I'd recommend Paste Special for the meta file. If you're targeting anything that supports SVG--which word doesn't--I'd use the web viewers instead.

  • 01-16-2014 15:54 In reply to

    Re: Support for images in PDF documents

    Hi Ken,

    This is true, but regardless of the file format, all of these screen snaps are bitmaps and will only look good at the exact zoom level that you snapped them at. If you want the diagram to look good in a document, then you need a scalable (vector graphic) representation. For pasting into Word, this means Copy Image in NORMA, then Paste Special in Word with a choice of Picture (Enhanced Metafile). For programs that don't handle the meta files well you need to use SVG generated by the web viewers, as described in my other response.

    -Matt

  • 01-17-2014 3:24 In reply to

    • koneill
    • Top 25 Contributor
      Male
    • Joined on 02-17-2012
    • The Netherlands
    • Posts 25

    Re: Support for images in PDF documents

    Thanks for the tips guys; I'm already using snagit to paste the ORM diagrams in word in the case that I want to turn the document into a PDF (which my employer demands when any document leaves the building). I tried the paste special option but the created image isn't as nice which is due to the fact that I zoom in when I make a capture with snagit. This just doesn't seem to work with the paste special option.

  • 01-17-2014 4:14 In reply to

    Re: Support for images in PDF documents

    Hi Karl,

    That's an interesting perspective. Glancing at the code, we do a TranslateTransform on the graphics object used to generate the image, but I don't see any graphics.ScaleTransform. If I can get a reasonable quality image with some tweaks to the graphics object then I can break Copy Image into three items (copy at default size, copy at current zoom, copy at custom zoom). The latter would be useful in Word, for example, if you paste in an image which is too big and is automatically reduced to fit in the margins. If you look at the Size and Position properties in Word, you can read off the exact zoom level, then re-copy the image at that custom level. You could paste a sharp bitmap instead of a compressed one and get a much better transfer to PDF than the EMF is currently giving you.

    Would a zoom-aware Copy Image help you out here?

    -Matt

    PS You'll have to ask Microsoft for direct SVG support in Word (Office is supposed to be HTML5 compliant, but clearly isn't IMO without native SVG support). This is supposed to be the path to standardized vector graphics.

  • 01-17-2014 4:57 In reply to

    Re: Support for images in PDF documents

    Matthew Curland:
    This is true, but regardless of the file format, all of these screen snaps are bitmaps and will only look good at the exact zoom level that you snapped them at
     

    Hi Matt,

    I don't know how Snagit works - but on my system I can zoom captures to 800% without any noticeable image degradation.
    The method I use is to save the Snagit capture to either PNG or PDF and then zoom from there.

    Of course you are right when you say that a vector graphics solution would be much better.
    But it seems to me that the practical choice is to use Snagit today and switch to a vector graphics solution if and when it becomes available. 

    Ken

Page 1 of 1 (7 items)
© 2008-2014 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service