<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to write a script to save a currently open report as a PDF in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78885#M36600</link>
    <description>&lt;P&gt;Worked great, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did modify the scaling factor based on some discussion in this thread: &lt;A title="https://community.jmp.com/t5/Discussions/Scaling-to-fit-to-page-width/td-p/33952" href="https://community.jmp.com/t5/Discussions/Scaling-to-fit-to-page-width/td-p/33952" target="_self"&gt;https://community.jmp.com/t5/Discussions/Scaling-to-fit-to-page-width/td-p/33952&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, it will adjust the size of the report to fit the page width as needed, which is really nice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the quick help!&lt;/P&gt;</description>
    <pubDate>Sun, 14 Oct 2018 09:11:07 GMT</pubDate>
    <dc:creator>SDF1</dc:creator>
    <dc:date>2018-10-14T09:11:07Z</dc:date>
    <item>
      <title>How to write a script to save a currently open report as a PDF</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78879#M36597</link>
      <description>&lt;P&gt;Hi All, I'm not new JMP, but relatively new to JSL. I'm trying to write a script to help automate some data analysis and output of said analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a parent JSL script that I'm running that allows users to open files of interest for analysis and then perform a possible sequence of analyses, e.g. distributions, models fits, multivariate, bivariate fits, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using a generic function in the script to ask the user to select from the current list of windows (data tables) on which to perform the analysis. The user would select a data table for performing, e.g. a multivariate analysis. I want to have this parent script also have a button script that offers them an option to then save a selected report (again calling the generic select window function). I am having a hard time taking the existing report window, e.g. multivariate analysis, and then sending that to a PDF. I have tried writing code to get the script from the report window and rerun that to send to a journal and save as a PDF, but this fails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is my parent script:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
choose_data_table = Function( {},
	list = {};
	For( i = 1, i &amp;lt;= N Table(), i++,
		list[i] = Data Table( i ) &amp;lt;&amp;lt; get name
	);
	win = New Window( "Select a data table",
		&amp;lt;&amp;lt;Modal,
		hb = H List Box(
			Panel Box( "Choose a data table",
				dt = List Box( list, max selected( 1 ), chosen = Data Table( (dt &amp;lt;&amp;lt; get selected)[1] ) )
			),

		)
	);
);
New Window( "Data Workup",
	Button Box( "JMP?",
		Web( "C:\Program Files\SAS\JMP\14\Help\index.html" ),
		&amp;lt;&amp;lt;Style( "Underline" ),
		&amp;lt;&amp;lt;Horizontal Alignment( "Right" )
	),
	Text Box(
		"A script to help automate data analysis",
		&amp;lt;&amp;lt;Horizontal Alignment( "center" ),
		&amp;lt;&amp;lt;Set Wrap( 350 ),
		&amp;lt;&amp;lt;Set Font Size( 12 )
	),
	Text Box( "", &amp;lt;&amp;lt;Justify Text( "left" ), &amp;lt;&amp;lt;Set Wrap( 350 ) ),
	H List Box(
		Panel Box( "File Operations",
			V List Box(
				Button Box( "Open file", Open() ),
				Button Box( "Rename data table",
					choose_data_table;
					Wait( 1 );
					User_Input = New Window( "Enter new name",
						&amp;lt;&amp;lt;Modal,
						H List Box( Text Box( "New name:" ), rename = Text Edit Box( "", &amp;lt;&amp;lt;set width( 200 ) ), ),
						Text Box( "Click OK to save" ),
						Button Box( "OK", newname = rename &amp;lt;&amp;lt; get text() ),

					);
					chosen &amp;lt;&amp;lt; Set Name( newname );
				)
			)
		),
		Panel Box( "Analysis Operations",
			V List Box(
				Button Box( "Select distributions",
					choose_data_table;
					Distribution();
				),
				Button Box( "Graph builder",
					choose_data_table;
					Graph Builder( Variables, Elements( Points( Legend( 1 ) ) ) );
				),
				Button Box( "Fit Y by X",
					choose_data_table;
					Bivariate();
				),
				Button Box( "Fit model",
					choose_data_table;
					Fit Model();
				),
				Button Box( "Multivariate",
					choose_data_table;
					Multivariate();
				)
			)
		)
	)
) &amp;lt;&amp;lt; Size Window( 300, 300 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the script I'm using to try and extract the data to a jrn and save as pdf:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
wlist = Get Window List() &amp;lt;&amp;lt; Get Window Title();
choose_window = Function( {},
	win = New Window( "Select a Report",
		&amp;lt;&amp;lt;Modal,
		hb = H List Box(
			Panel Box( "Select a report window",
				tcf = List Box( wlist, Max Selected( 1 ), chosen = tcf &amp;lt;&amp;lt; Get Selected() )
			), 

		)
	)
);
choose_window;
chosen[1] &amp;lt;&amp;lt; SaveAs();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's the error I get:&lt;/P&gt;
&lt;P&gt;Send Expects Scriptable Object in access or evaluation of 'Send' , chosen[1] &amp;lt;&amp;lt; /*###*/SaveAs() /*###*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried many ways to get around this, but somehow I can't seem to get the JSL script to exectute a function allowing the user to select the report window of choice and have that then saved as a PDF (or PNG, or JPG, etc. -- as desired by the user).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 14:02:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78879#M36597</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2020-05-19T14:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a script to save a currently open report as a PDF</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78884#M36599</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
wlist = Get Window List() &amp;lt;&amp;lt; Get Window Title();
choose_window = Function( {},
	win = New Window( "Select a Report",
		&amp;lt;&amp;lt;Modal,
		hb = H List Box(
			Panel Box( "Select a report window",
				tcf = List Box( wlist, Max Selected( 1 ), chosen = tcf &amp;lt;&amp;lt; Get Selected() )
			), 

		)
	);
 chosen;	
);
chosen = choose_window();
w = window(chosen[1]);
w &amp;lt;&amp;lt; journal;
//you might need to scale the report to fit in the pdf page
w &amp;lt;&amp;lt; Set page setup( margins( 0.5, 1, 0.5, 1 ), scale( .9 ), portrait( 1 ), paper size( "Letter" ) );
w &amp;lt;&amp;lt; save pdf("C:/temp/chosen_test.pdf")


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Oct 2018 08:04:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78884#M36599</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-10-14T08:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a script to save a currently open report as a PDF</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78885#M36600</link>
      <description>&lt;P&gt;Worked great, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did modify the scaling factor based on some discussion in this thread: &lt;A title="https://community.jmp.com/t5/Discussions/Scaling-to-fit-to-page-width/td-p/33952" href="https://community.jmp.com/t5/Discussions/Scaling-to-fit-to-page-width/td-p/33952" target="_self"&gt;https://community.jmp.com/t5/Discussions/Scaling-to-fit-to-page-width/td-p/33952&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, it will adjust the size of the report to fit the page width as needed, which is really nice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the quick help!&lt;/P&gt;</description>
      <pubDate>Sun, 14 Oct 2018 09:11:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-write-a-script-to-save-a-currently-open-report-as-a-PDF/m-p/78885#M36600</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2018-10-14T09:11:07Z</dc:date>
    </item>
  </channel>
</rss>

