Book a Demo

Author Topic: Import image from Enterprise Architect to ms Word  (Read 8863 times)

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Import image from Enterprise Architect to ms Word
« on: August 18, 2014, 07:55:13 pm »
Working on an Enterprise Architect add-in I want to import an image from Enterprise Architect to ms Word using c#. For now I have solved this by saving the diagram/image as a .pdf file and then reading it again using the iTextSharp.

It seems to me that this is the hard way around the problem and therefore I think there must be a more simple way to get the image from Enterprise Architect to ms Word using c#.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #1 on: August 19, 2014, 01:25:31 am »
No. That's actually the EA way to go.

q.

AndyJ

  • EA User
  • **
  • Posts: 337
  • Karma: +5/-3
  • It's only a model
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #2 on: August 19, 2014, 09:10:51 am »
In user-land, it's just Ctrl-A, Ctrl-C, (change focus to the word document) Ctrl-V...

I'm surprised that you need to generate a .pdf file in scripting-land.

Of course, word has an annoying tendency to paste the diagram with the borders extending beyond the page boundaries, so if the .pdf method overcomes that, then that's a good thing!

Andy
Sun Tzu: "If you sit by the river long enough, eventually the body of MS Visio floats past."

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8090
  • Karma: +118/-20
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #3 on: August 19, 2014, 09:19:03 am »
It's probably easier to use Project.SaveDiagramImageToFile ()

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #4 on: August 19, 2014, 09:20:06 am »
Quote
In user-land, it's just Ctrl-A, Ctrl-C, (change focus to the word document) Ctrl-V...
ICR a method to copy the image to paste board via API.

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #5 on: August 19, 2014, 09:44:57 am »
There is also the PutDiagramImageOnClipboard and PutDiagramImageToFile methods available on the Project Class which may be useful.

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #6 on: August 19, 2014, 05:30:50 pm »
How do you initialize the project class to the current repository and how do you copy the image from clipboard?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #7 on: August 19, 2014, 07:45:40 pm »
You get it via Repository.GetProjectInterface(). How to get things out of the clip board you better ask on a MS forum (or on StackOverflow).

q.

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #8 on: August 19, 2014, 07:51:53 pm »
Thanks to all of you. Everything is working just fine now!
Here's a link to the solution I did come up with:
http://stackoverflow.com/questions/25358337/import-image-from-enterprise-architect-to-ms-word
« Last Edit: August 19, 2014, 10:49:02 pm by Stenvang »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import image from Enterprise Architect to ms W
« Reply #9 on: August 21, 2014, 10:35:45 pm »
I wasn't happy with the fact that my add-in would steal my clipboard (and I would loose whatever I copied before) so I figured out a workaround that first writes the image to a temporary file, then reads the file and then copies the contents into my document.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Import image from Enterprise Architect to ms W
« Reply #10 on: August 21, 2014, 11:54:31 pm »
Quote
I wasn't happy with the fact that my add-in would steal my clipboard (and I would loose whatever I copied before) so I figured out a workaround that first writes the image to a temporary file, then reads the file and then copies the contents into my document.

Geert
As you have already guessed, I'm no windoze programmer. But can't you push the current clipboard contents while doing the diagram operation and then pop it back?

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import image from Enterprise Architect to ms W
« Reply #11 on: August 22, 2014, 04:01:25 pm »
Quote
Quote
I wasn't happy with the fact that my add-in would steal my clipboard (and I would loose whatever I copied before) so I figured out a workaround that first writes the image to a temporary file, then reads the file and then copies the contents into my document.

Geert
As you have already guessed, I'm no windoze programmer. But can't you push the current clipboard contents while doing the diagram operation and then pop it back?

q.
I guess that would have been possible as well, but given the choice I'd rather not touch the clipboard at all.

Geert