Skip to content

Instantly share code, notes, and snippets.

@y-yu
Last active August 29, 2015 13:58
Show Gist options
  • Save y-yu/10002049 to your computer and use it in GitHub Desktop.
Save y-yu/10002049 to your computer and use it in GitHub Desktop.
ページ番号を振るCGI
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use File::Copy;
my $q = CGI->new;
my $fh = $q->upload('pdf_file');
if (defined $fh) {
unlink './concat_.pdf';
copy ($fh, './concat_.pdf');
system('ssh abelia01 "export PATH=$PATH:/usr/texbin; cd ~/public_html/secure_htdocs/pagenum/; xelatex --output-directory=./ concat.tex > /dev/null"');
print $q->redirect('https://www.coins.tsukuba.ac.jp/~word/pagenum/concat.pdf');
} else {
print $q->header(-type=>'text/html', -charset=>'utf-8');
print $q->start_html(-title=>"pagenum",-lang=>'ja-JP');
print $q->start_form(-method => 'POST', -action => './');
print $q->filefield(-name=>'pdf_file',
-size=>50,
-maxlength=>80);
print $q->submit(-name=>'submit',
-value=>'submit');
print $q->end_form;
print $q->end_html;
}
@y-yu
Copy link
Author

y-yu commented Apr 6, 2014

普通のリクエスト

  • PDFファイルをアップロードするフォームを表示

PDFファイルがアップロードされたとき

  1. PDFファイルをどこかに保存
  2. SSHでMacに接続してxelatexのコマンドを実行
  3. できあがったPDFを返す

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment