from slides to handouts

Share your wisdom. Not for support questions!

Moderator: How-to Curator

from slides to handouts

Postby SoulSingin » February 27th, 2012, 11:26 pm

I frequently must read presentation slides. When I do, I sometimes want to print the slides and read them on paper. To save paper, I like to print two slides per page. (It's also easier to read that way).

When the presentation is a PowerPoint file, I can simply send the file to the printer two slides per sheet. But when the presentation is already in PDF format (either because they were sent as a PDF file or because they were produced with LaTeX), the options are not so good.

Below is an easy way to convert the PDF slides to "handouts" (i.e. a file with two slides per page). It's a Perl script that calls LaTeX to "double up" the PDF slides. Save the script somewhere in your $PATH and you can create handouts in a snap.

Enjoy,
- Soul Singin'

ps: You can discuss this HowTo in the other subforum.

Code: Select all
#!/usr/bin/env perl

##  simple Perl script to create doubled PDF pages

use strict ;
use warnings ;

##  arguments are the file to double up
my @files = @ARGV ;

foreach my $file (@files) {
    double_up( $file ) ;
}

##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##

##  SUBROUTINES
##  ===========

##  sub to produce the TeX file
sub mk_tex {

    my $file = $_[0] ;

    my $tex = <<"END_TEX";
\\documentclass[letterpaper]{article}
\\usepackage{pdfpages}

\\begin{document}
\\includepdf[nup=1x2,pages=-]{$file}
\\end{document}
END_TEX

    return $tex ;
}

##  sub to execute the double up

sub double_up {
   
    my $file = $_[0] ;
   
    ##  append "v2" to the PDF file name
    ##  note however that the PDFs file name comes from the TeX file name
    ( my $texname = $file ) =~ s/\.pdf$/_v2.tex/i ;
    $texname = "/tmp/double-up/" . $texname ;
   

    ##  create the TeX
    my $tex = mk_tex( $file ) ;

    ##  run the commands in a temporary directory
    mkdir("/tmp/double-up") ;
    open( OVERWRITE, ">$texname" ) || die "could not overwrite $texname" ;
    print OVERWRITE $tex ;
    close OVERWRITE ;
   
    system( "pdflatex \\\\batchmode\\\\input $texname" ) ;

    ##  now clean up the mess
    ( my $auxname = $file ) =~ s/\.pdf$/_v2.aux/i ;
    ( my $logname = $file ) =~ s/\.pdf$/_v2.log/i ;     
    unlink( $auxname , $logname , $texname ) ;
    rmdir("/tmp/double-up" ) ;
}


.
Wildflower seed in the sand and wind
May the four winds blow you home again
User avatar
SoulSingin
 
Posts: 519
Joined: February 9th, 2011, 1:21 pm

Return to HowTo

Who is online

Users browsing this forum: No registered users and 1 guest

x