cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
sgpt
Level I

How to save webpages through JSL

How can I save webpages from JSL? I use the following lines of code to open the webpage in a JSL 

 

 

url = "https://www.nytimes.com";
w = New Window( "s1",wb = Web Browser Box(url ), wb << Set Size( 1200, 1200 ););
w << Set Window Size( 1200, 1200 );

 

 

Thereon, what can I do to save the webpage with full graphics in a form that can be consumed later (pdf or full graphic html)? I essentially need to do this for a few hundred internal URLs for a database for visualization that is being turned off.

 

10 REPLIES 10
sgpt
Level I

Re: How to save webpages through JSL

Bumping

txnelson
Super User

Re: How to save webpages through JSL

JMP allows you to generate JMP output and then save that output to either HTML or Interactive HTML.  You can generate a JMP Journal that will allow you to bring in various pieces of output from different graphical and statistical JMP platforms, and then save it to HTML.

If what you want to do, is to build raw HTML code into webpages, then the only way that I know of how to do that in JMP would be to place all of the HTML code into a string variable and then use the Save Text File() function to save the HTML generated code to a file.

Jim
sgpt
Level I

Re: How to save webpages through JSL

Thanks txnelson. I am trying to save the webpages as pdfs. However, I just get void files saved when I run something like this below:

 

url = "http://nytimes.com";
w = New Window( "s1", wb = Web Browser Box());
w << Set window size (1200,1200);
wb << set auto stretching (1,1);
w << set auto stretching (1,1);
wb << Set Max Size( 1200, 1200 );
wb << navigate (url);
wait(2);
wb << select << save pdf ("$Documents\tst.pdf"); 

It feels like I am something really obvious in how I am trying to save the web browser box object. 

 

 

txnelson
Super User

Re: How to save webpages through JSL

I could not find a way to save a Web Box() object to a PDF......maybe another community member can determine a method

Jim
sgpt
Level I

Re: How to save webpages through JSL

Thanks Jim for your response. Do you have any alternate suggestions on how to save webpages as pdfs through JMP? I encountered similar issues as above with saving as journal files or htmls.

Jeff_Perkinson
Community Manager Community Manager

Re: How to save webpages through JSL

JMP may not be the best tool for that specific part of the job - saving a web page as a PDF file. 

 

However, I found the pdfkit library for Python which means you can do it from JMP using the Python interface.

 

Something like this:

 

 

URLs = {"https://jmp.com", "https://community.jmp.com"};

py = Python Connect();

For( i = 1, i <= N Items( URLs ), i++,
	pdf = "C:\TEMP\" || Substitute( Word( 2, URLs[i], "/" ), ".", "" ) || ".pdf";
	py << submit(
		Eval Insert( "import pdfkit; pdfkit.from_url('^URLs[i]^', '^pdf^')" )
			
	);
);

 

 

One hiccup to note: pdfkit is a wrapper for wkhtmltopdf so you'll need to install that also.

-Jeff
ENTHU
Level IV

Re: How to save webpages through JSL

I am trying to save html as pdf.Tried running this code but Python Connect() does not work for me.

I am using JMP12.Is this not supportable for this version of JMP?

 

Thanks

 

Jeff_Perkinson
Community Manager Community Manager

Re: How to save webpages through JSL

No, JMP 12 does not have support for connecting to Python. You’ll need to upgrade to the current release of JMP, JMP 14 to connect to Python.

-Jeff
ENTHU
Level IV

Re: How to save webpages through JSL

Thanks @Jeff_Perkinson .Is there any other option to save html as pdf in jmp12?