Book a Demo

Author Topic: The SaveImagePage function  (Read 7751 times)

ThierryL

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
The SaveImagePage function
« on: February 17, 2015, 03:56:23 am »
Hello,

I need more documentation about the parameters of the "SaveImagePage" function.
When the diagram contains only 1 page, there is no problem, but if it is greater than 1 page, SaveImagePage returns an error.

When x or y are different than 1, there is an error, but the diagram is on more than 1 page.

What is the meaning of the parameter Flag ?

//////////////////  Help from EA  ///////////////////////////
Saves a page of the diagram to disk.

Returns true if the operation is successful; returns false if the operation is unsuccessful.
Use GetLastError() to retrieve error information.

Parameters:

· x: Long - the horizontal page
· y: Long - the vertical page
· sizeX: Long - the page width to use
· sizeY: Long - the page height to use
· filename: String - the filename to save the image to.
· flags: Long - options
The image type is determined by the extension of the filename. Currently only .EMF, .BMP and .PNG formats are supported.

///////////////////////////////////////////////////////////////////

Best regards,
Thierry

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: The SaveImagePage function
« Reply #1 on: February 17, 2015, 05:36:28 am »
This is a new function with V12. So when using it you're walking on thin ice...

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: The SaveImagePage function
« Reply #2 on: February 17, 2015, 09:47:36 am »
My analysis is:
  • x and y parameters are reversed. I'll have to wait for feedback on if this will be changed in code or documentation
  • pageX and pageY parameters are currently ignored. They were intended to allow saving images with dimensions than other than current page size
  • flags is intended to allow us to provide behavior options in the future without creating an entire new function. Pass zero to ensure that your call continues to behave the same

I successfully saved two images from the one diagram in tests just run.
« Last Edit: February 17, 2015, 09:48:54 am by simonm »

ThierryL

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: The SaveImagePage function
« Reply #3 on: February 17, 2015, 09:50:38 pm »
Hello Simon,

Thank you for your analysis.

I can not test the "reverse" of x and y parameter, because only 1 and 1 are valid values in my tests. Other values cause an error.
I have a simple model that illustrate the problem. I can "save image to file" with EA himself and I want exactly the same result, but it's not possible with the API, in C# like this :

eaDiagramme = oEA.Repository.GetCurrentDiagram();
if (eaDiagramme.SaveImagePage(1, 1, 1130, 795, "C:\\Users\\Thierry\\Documents\\$\\Diagramme.png", 0) == false)
                TxtErreur.Text = eaDiagramme.GetLastError();

(The SaveAsPdf is ok with the same diagram.)

My diagram is on 2 pages. If I move all entities in one page it's ok. But I want the same result as EA himself (Ctrl-T) : all entities in a file with one page.

If you want, I can send you my model.

Best regards,
Thierry

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: The SaveImagePage function
« Reply #4 on: February 18, 2015, 09:24:05 am »
Quote
I can not test the "reverse" of x and y parameter, because only 1 and 1 are valid values in my tests. Other values cause an error.
Just to be clear. I was talking about swapping the x and y parameters. In my example I had a diagram two pages on the x axis, but to save the second page I had to pass 2 as the y value.

If that doesn't work for you, then it's probably a good idea to send in a bug report because you're getting behavior I can't reproduce. It could be resolved by fixing the errors I'm getting, but I just don't know.
« Last Edit: February 18, 2015, 09:30:21 am by simonm »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: The SaveImagePage function
« Reply #5 on: February 18, 2015, 10:48:27 am »
Quote
I can "save image to file" with EA himself and I want exactly the same result [...] I want the same result as EA himself (Ctrl-T) : all entities in a file with one page.

If you want the equivalent to the "Save image to file" menu command, try calling PutDiagramImageToFile on the Project Class instead.  This will output the entire diagram to a single image file.  The function you are currently trying to call is for output of a separate file for each 'page' within the diagram.

BTW - before calling Diagram.SaveImagePage it may be worth checking the PageWidth and PageHeight values first to see how many horizontal and vertical 'pages' there actually are on the current diagram.

ThierryL

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: The SaveImagePage function
« Reply #6 on: February 18, 2015, 08:21:15 pm »
Thank you Aaron_B for your help !  :)

I did not know this function and with it I get exactly that I wanted.

Best regards,
Thierry