Subscribe Bookmark RSS Feed

JMP Script Question regarding saving Journal as PDF

Hoping someone can help out with the following question,

At the moment I'm saving jmp journals in a pdf format. Part of this process involves modifying the "page scale" setting under the "page setup" dialog box that pops up during the process.

Unforetuneatly, I don't see any instructions/examples where I can automate sending a script command to set the value of the page scale. Can this be done?

Appreciate your help. Thanks,

2 REPLIES
mattf

Community Trekker

Joined:

Jun 23, 2011

Hi:

Here is one way to modify the pdf's properties after creating it - via Perl and MS COM.

The Perl script can be kicked directly from JSL

Best regards,

-Matt

/*

#-------------------------------------------------------------------------------

# References

#-------------------------------------------------------------------------------

# NESUG 2010 Multiple Methods in JMP® to Interact with R

# http://www.nesug.org/Proceedings/nesug10/po/po06.pdf

# NESUG 2009 Automating JMP via Scripting tools and MS Windows COM

# http://www.nesug.org/Proceedings/nesug09/ap/ap09.pdf

*/

// open existing journal

jrn = Open("C:\Documents and Settings\mjflynn\My Documents\frb.jrn");

wait(1);

// save as pdf

jrn << Save pdf("C:\Documents and Settings\mjflynn\My Documents\frb.pdf" );

// modfiy saved pdf via Perl

SaveTextFile( "C:\temp\deleteme.pl","

     #http://search.cpan.org/~ssimms/PDF-API2-2.019/lib/PDF/API2.pm

     #!C:/Perl10/bin/perl.exe

     use strict;

     use warnings;

     use PDF::API2;

     # Create a blank PDF file

     $pdf = PDF::API2->new();

     # Open an existing PDF file

     $pdf = PDF::API2->open('frb.pdf');

     # Set the default print setting for page scaling to none.

     $pdf->preferences(-printscalingnone)

     # Add a blank page

     $page = $pdf->page();

     # Retrieve an existing page

     $page = $pdf->openpage($page_number);

     # Set the page size

     $page->mediabox('Letter');

     # Add a built-in font to the PDF

     $font = $pdf->corefont('Helvetica-Bold');

     # Add an external TTF font to the PDF

     #$font = $pdf->ttfont('/path/to/font.ttf');

     # Add some text to the page

     $text = $page->text();

     $text->font($font, 20);

     $text->translate(200, 700);

     $text->text('Hello World!');

     # Save the PDF

     $pdf->saveas('C:/temp/new.pdf');

");

SaveTextFile( "C:\temp\deleteme.bat",

                "C:\Perl10\bin\perl C:\temp\deleteme.pl"    

);

Open( "C:\temp\deleteme.bat" );

tova

Community Trekker

Joined:

Feb 17, 2013

How can I use Perl to change the orientation of my pdf file to landscape?

thanks,

Tova