cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
CaseyL
Level II

Adding external images to report with JSL

I've found that I can copy/paste an image into a report/journal (https://www.jmp.com/support/help/14-2/paste-an-image-at-the-end-of-a-report.shtml#865792)

 

is there a way to do this in JSL? are there any options for placement/resizing? My ultimate goal is to automate the generation of reports add relevent images and then publish to HTML.

 

I had thought to publish the reports and then add the images to the HTML file, but the files generated by JMP are not easy to modify, the <body> sections are blank and I think must be generated dynamically when the page is loaded.

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Adding external images to report with JSL

You can read in external images into a Picture Box(), and then place that into a Journal.

Names Default To Here( 1 );

pb = Picture Box( Open( "$SAMPLE_IMAGES/tile.jpg", jpg ) );

nw = New Window( "jj", <<journal );
nw << append( pb );

You can also adjust the size

Names Default To Here( 1 );

pb = Picture Box( Open( "$SAMPLE_IMAGES/tile.jpg", jpg ) );
pb << set width(800);
pb << set height(800);

nw = New Window( "jj", <<journal );
nw << append( pb );

In the construction of a Journal, you can organize it's contents using the various JSL functions and objects to do location, spacing, page breaks, etc.

See the Scripting Guide

      Help==>Books==>Scripting Guide

and also the Scripting Index

     Help==>Scripting Index

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Adding external images to report with JSL

You can read in external images into a Picture Box(), and then place that into a Journal.

Names Default To Here( 1 );

pb = Picture Box( Open( "$SAMPLE_IMAGES/tile.jpg", jpg ) );

nw = New Window( "jj", <<journal );
nw << append( pb );

You can also adjust the size

Names Default To Here( 1 );

pb = Picture Box( Open( "$SAMPLE_IMAGES/tile.jpg", jpg ) );
pb << set width(800);
pb << set height(800);

nw = New Window( "jj", <<journal );
nw << append( pb );

In the construction of a Journal, you can organize it's contents using the various JSL functions and objects to do location, spacing, page breaks, etc.

See the Scripting Guide

      Help==>Books==>Scripting Guide

and also the Scripting Index

     Help==>Scripting Index

Jim
Miof
Level II

Re: Adding external images to report with JSL

Hi Jim and All
Is there a way to embed the picture directly in the script? In multi user workplace, the path/picture can get deleted

txnelson
Super User

Re: Adding external images to report with JSL

Here is an example of an image being part of JSL in a script;

Names Default To Here( 1 );
textImage = New Image(
	Char To Blob(
		"1iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJ
		cEhZcwAADsMAAA7DAcdvqGQAAAEaSURBVEhL1ZTBDYMwDEW7E7N0BeboGqzALFzZJTfqF+WLyHUCEnDokyyIk/xvp6
		SvlNL2ZGSDuzllsBDrHlP13hqLrgHCw2fZXsTbPQ9inNndMWC6KerzwVNdNA2ogMXDbC3bOxvYONg7c4zJM87rLKbVw
		taP9uSoIDRQ9VoEUQ6yAfky9sQGJuKFFquKSpsGLi9CgwgEQgPLkW9x2oCzRYhzriFHBy1OG/DDRULZ4I4OxtKB57YO
		EOK8PYjf0gFCfDGe3MFVA106jsnT6uDwJteoSm6uZ58rCYOC9DkfGuTvvFRZ/0uKeh5h/zF0DXS5cphIhARlQmAkzhn
		Y5qh6IWGZ1HQNgLP1tzdC/6SeQ4Or/Bg8Gf9ukLYvWuoqiUvI3KwAAAAASUVORK5CYII=",
		"base64compressed"
	),
	"png"
);
New Window( "Test", textImage );

Here is the code that I used to read in the image and create the JSL

Names Default To Here( 1 );
theImage = Open( "C:\Program Files\JMP\JMPPRO\18\Samples\Images\pi.gif" );

textImage = theImage << get picture;
Show( textImage );
Window( "pi.gif" ) << close window;

I just cut and pasted the results of the Show()  from the log, to the script window.

Jim
smithjohn
Level I

Re: Adding external images to report with JSL

It is not possible to insert external photos directly into a report using JSL (JMP Scripting Language || Mulesoft Course). Photos, on the other hand, can be included by referencing them via URL.

 

// Create a new report
myReport = New Report("My Report");

 

// Add a Text Box
myText = Text Box("This is my report.");

 

// Add an Image Box and specify the URL of the image
myImage = Image Box("https://example.com/image.jpg");

 

// Add the Text Box and Image Box to the report
myReport << Add Text Box(myText);

myReport << Add Image Box(myImage);

 

// Display the report
myReport << Show Window;

 

When adding an image, replace "https://example.com/image.jpg" with the URL of the image. When run this script will create a report, with a text box showing the image from the given URL followed by an image box.