GL

Good day everyone :)

Can i get a little help please?

I want to generate a doc file from a model and wanna show an image from an attribute which have an image url.

I have an object, which has a description attribute. 

This attribute contains an image url, which is :

https://csoportmunka.mvmh.hu/mvmcsoport/szabdoktar/mvmi/Munka/Kapcsolodo-publikalashoz/20160605_Anett.jpg

My problem is, when i ran my code, it makes a system path from the url like this:

https:\csoportmunka.mvmh.hu\mvmcsoport\szabdoktar\mvmi\Munka\Kapcsolodo-publikalashoz\20160605_Anett.jpg

And the error message is : The filename, directory name, or volume label syntax is incorrect

 

I am running the following code below:

 

//----------------------------Read Image from Attribute----------------------------------

                

                //Path of the requested picture

                var path = oObjList[i1].ObjDef().Attribute(9, nloc).GetValue(false); --> get the correct url link

                                

                //Java File to get the picture

                var fileMyFile = new java.io.File(path); --> Convert to system path

                                

                //FileReader

                var reader = new java.io.FileReader(fileMyFile);

                var fileByteArray = [];

                //Convert picture to ByteArray

                fileByteArray = java.nio.file.Files.readAllBytes(fileMyFile.toPath());

                 

                //Create JavaScript Array

                var javaScriptArray = new Array();

                 

                //Now push data from Java Array to JavaScript Array

                for (var i = 0; i < fileByteArray.length; i++){

                    javaScriptArray.push(fileByteArray[i]);

                }

         

                //Create Image from data

                var image = Context.createPicture(javaScriptArray, Constants.IMAGE_FORMAT_JPG);

                

                ooutfile.value.OutGraphic(image,-1,100,100);

                

                //----------------------------Read Image from Attribute----------------------------------

Thank you for helping me out :)

File attachments
by Torsten Haase
Posted on Thu, 10/22/2020 - 14:10

Hi Gabor,

your picture is not a file on your file system but requires a HTTP connection. See the sample script below how to insert a picture from the web into an ARIS report:
 

var output = Context.createOutputObject()

var obj = ArisData.getSelectedObjDefs()[0]
var attr = obj.Attribute(Constants.AT_DESC, Context.getSelectedLanguage())
if(attr.IsMaintained()) {
    var sVal = attr.getValue()
    
    var url = new java.net.URL(sVal);
    var conn = url.openConnection();
    conn.setRequestMethod("GET");
    var byteArray = conn.getInputStream().readAllBytes()
    var picture = Context.createPicture ( byteArray, "jpg" ) //or "png" ...
    output.OutGraphic (picture, 100, 210, 297)
}
 
output.WriteReport()   

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks
  • Profile picture for user frankweise
  • Profile picture for user Henrik Buckler
  • Profile picture for user UffeK
  • SS
  • MZ
  • PacMan

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock