ARIS Community - We Love BPM

How to export an EPC as a jpg or png using ARIS script?

Will Yang's picture
by Will Yang in Reports & Macros posted on 2011-02-15

Hi,

I have got a request to export EPC as a graphic file like JPEG or some other common format. However, it seems ARIS Script only supports doc/pdf/xls/rtf/txt/html format. I noticed that when exporting EPC as html, a png file would be created. Does any one know how to get the png file directly using ARIS script?

 

Thanks in advance.

 

Regards,

Will

24811 Views
0 Likes
10 Comments
There are no attachments
Eva Klein posted on 2011-02-15

Hi Will,

First, you need to specify which model should be exported. This is done as follows: 

var models = ArisData.getSelectedModels()

Then you need the method “createOutputObejct()”, which returns a new output object with preset name, format, and media size . 

var outputDummy = Context.createOutputObject() 

Getting the graphic of a model can be done by calling the Graphic method of the model object. This method uses three parameters. The first parameter means that the object is always visible on a part of the graphic. The second parameter defines whether the returned graphic should be black & white or contain colors (false = color, true = black and white). The last parameter specifies the language to be returned.

var picture = models[i].Graphic(false, false, Context.getSelectedLanguage()

The method“Save()” saves a picture object as an EMF, PNG, or JPG file. In our example the picture is saved as a png

picture.Save(outputDummy, imageFileName)

Everything else is just iterating over the list of models, etc..

var models = ArisData.getSelectedModels()

var outputDummy = Context.createOutputObject()
for(var i=0; i<models.length; i++)
{
var picture = models[i].Graphic(false, false, Context.getSelectedLanguage() )
var imageFileName = "ModelImage_"+i+1+".png"
picture.Save(outputDummy, imageFileName)
Context.addOutputFileName(imageFileName)
Context.setSelectedFile(imageFileName)
}

Make sure to watch the Reports & Macros group. There you will find additional tutorials which will help you to get started with ARIS scripting.

Regards
Eva

Matus Novotny posted on 2014-08-15

Hello!

I used following code in ARIS 7.2 script and it worked fine.

    var output = Context.createOutputObject();
    var picture = model.Graphic(false, false, Context.getSelectedLanguage());
    var imageFileName = model.Name(g_nLoc)+".png";
    picture.Save(output, imageFileName);

Now I am trying to run the same script in ARIS 9.6 and I am getting an error on calling ‘Save’ function:

Can't find method com.idsscheer.report.output.external.interfaces.impl.APicture.Save(com.idsscheer.report.output.outputobject.asposeapi.AMergeableOutputObject,string)

Does anyone know where could be the problem by running the script in ARIS 9.6?

Thanks

Matus

Will Yang posted on 2011-02-16

Hi Eva,

I have tried your program and it works! The Save() method is what I am looking for. Thank you so much for reply.

Of course I will watch Reports & Macros group and hope I can help this community.

Thanks again.

Regards,

Will

Esteban Moyao posted on 2011-08-22

reply excelent!!! Eva, thanks, I am hope help too!

Gilad Wilk posted on 2012-01-17

Hello Eva,

I have a question that the Save option might be the answer for,

I am trying to reduce the size of a report that I created. The report summarize some (a lot) models into a word document.

The problem that we encountered was that the file created as RTF and because of this exceeds the 512 MB size allowed (by Microsoft).

I tried to lower the resolution of the pictures and transfer them to black and white, but it only partly helped (the file is smaller but still above the 512 MB).

Is there any chance that the save function could help me reduce the pictures resolution inside the RTF document?

Thank you very much in advance,

Gilad

Gilad Wilk posted on 2012-01-18

Hello once again,

does anyone have any answer for me?

I am in a bit of a time shortage and desperate for  a response...

Thanks in advance,

Gilad

Torsten Haase posted on 2012-01-18

Hi Gilad,

Which ARIS version do you use? If it's the latest 7.2, you could try a new feature which will become 'official' soon. If you use output format MS Word ("doc"), not RTF(!), calling the following line of code before creating an output object in your script, will use a new implementation of the output object, which creates much smaller DOC output files:

Context.setProperty("use-new-output", true)

Best regards,

Torsten

Gilad Wilk posted on 2012-01-19

Hi Torsten,

Thank you very much for the replay,

I am using the 7.2 and I even tried to use the Context.setProperty("use-new-output", true).

The problem with that, beside the very good outcome of a smaller size document, it "destroyed" my index and "demolished" my in-text hyperlinks.

Did you ever tried using those 2 (index + hyperlink) with the new feature?

Thank you once again,

Gilad

 

 

Torsten Haase posted on 2012-01-19

Hi Gilad,
I have not heard about such errors yet. Could you provide a small script demonstrating the issues? With this, this can be fixed for the next service release.

BR,
Torsten

Gilad Wilk posted on 2012-01-19

Hi Torsten,

I am ataching the relevant parts from my code,

any help will be highly appreciated,

Thanks again,

Gilad

 

 Code regarding TOC

Constants.C_BLACK, Constants.C_TRANSPARENT,Constants.FMT_BOLD| Constants.FMT_LEFT, 0, 0, 0, 0);

    g_ooutfile.SetTOCFormat(1, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT ,1, 1, 0, 0);

    g_ooutfile.SetTOCFormat(2, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_LEFT ,2, 2, 0, 0);

    g_ooutfile.SetTOCFormat(3, "Arial", 9, Constants.C_BLACK, Constants.C_TRANSPARENT,Constants.FMT_BOLD|  Constants.FMT_LEFT ,3,10, 0, 0);

 

    var firstLevel = "HEADING 1"

    var secondLevel = "HEADING 2"

    var thirdLevel = "HEADING 3"

    var fourthLevel = "HEADING 4"

Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_BOLD|Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY0, 0, 0, 0, 0, 0, 1);

    g_ooutfile.DefineF(secondLevel, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY1 , 4, 0, 0, 0, 0, 1);

    g_ooutfile.DefineF(thirdLevel, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY2 , 8, 0, 0, 0, 0, 1);

g_ooutfile.DefineF(fourthLevel, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY3, 12, 0, 0, 0, 0, 1);

 

function outputTOC(  ){

    g_ooutfile.BeginSection(true, Constants.SECTION_INDEX);

    g_ooutfile.OutputLnF("Table Of Contents", "Ariel18BoldCenter" );

    g_ooutfile.OutputLnF("","Ariel18BoldCenter" );

    g_ooutfile.SetAutoTOCNumbering(true)

 

    g_ooutfile.BeginParagraph(Constants.FMT_LEFT, 5, 5, 5, 5, 0, 2, 10);

    g_ooutfile.OutputField( Constants.FIELD_TOC, "Arial", 10,Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_LEFT);

    g_ooutfile.EndParagraph();

    //g_ooutfile.EndParagraph();

    g_ooutfile.EndSection();

}//END::outputTOC()

 

g_ooutfile.OutputLnF("Executive Summary", firstLevel);

 

Code regarding Hyperlink -

Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP  | Constants.FMT_LINKTARGET | Constants.FMT_TOCENTRY1, 4, 0, 0, 0, 0, 1);

g_ooutfile.DefineF("insteadOfHeading2", "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP  | Constants.FMT_LINKTARGET | Constants.FMT_TOCENTRY2, 8, 0, 0, 0, 0, 1);

 

g_ooutfile.OutputLinkF(ScreenViewAppName,ScreenViewAppName,"Ariel10LeftLink");

 

g_ooutfile.OutputLnF(ScreenViewAppName, "insteadOfHeading");

"