ラベル pdf の投稿を表示しています。 すべての投稿を表示
ラベル pdf の投稿を表示しています。 すべての投稿を表示

2018年8月2日木曜日

複数PDFを一括印刷する、PDF毎の一枚目は飛ばす。ドラッグアンドドロップ

'//Bath Print multiple pdfs without the first page
'//複数PDFを一括印刷する、PDF毎の一枚目は飛ばす。ドラッグアンドドロップでできます

set WshShell = CreateObject ("Wscript.Shell")
set fs = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments

if objArgs.Count < 1 then
msgbox("Please drag a file on the script")
WScript.quit
end if

Set gApp = CreateObject("AcroExch.App")
gApp.show '<- br="" comment="" hidden="" in="" mod="" or="" out="" take="" to="" work=""> 

'open via Avdoc and print
for i=0 to objArgs.Count - 1
FileIn = ObjArgs(i)
Set AVDoc = CreateObject("AcroExch.AVDoc")
If AVDoc.Open(FileIn, "") Then
Set PDDoc = AVDoc.GetPDDoc()
Set JSO = PDDoc.GetJSObject
x = PDDoc.GetNumPages
jso.print false, 1, x-1, true
gApp.CloseAllDocs
end if
next

gApp.hide : gApp.exit : Quit()
MsgBox "Done!"

Sub Quit
Set JSO = Nothing : Set PDDoc = Nothing : Set gApp =Nothing : Wscript.quit
End Sub

2014年3月23日日曜日

エクセル、シートをPDFファイルに保存するメソッド

Sub savePdf(ByRef st As Worksheet, saveTo As String)
    st.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        saveTo, Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
End Sub
使い方:

Call savePdf(ActiveSheet, "c:\abc.pdf")

2011年12月21日水曜日

CentOS6(64bit)にmsttcorefontsをインストール

ちなみに、前回はprinceのインストール方法を紹介しました。必要があれば参照してください。

htmlをPDFに変換してくれるlib princeを使おうと思ったけど、「fontがない」と怒れる

$ /usr/local/bin/prince --input=html --server -s /home/kagen/work/anyproj/public/stylesheets/application.css -s /home/kagen/work/anyproj/public/stylesheets/print.css -s /home/kagen/work/anyproj/public/stylesheets/prince.css ~/test.html -o test.pdf
...
Fontconfig error: Cannot load default config file
...
msg|wrn||no glyphs for character U+0074, fallback to '?'
msg|err||no available fonts

問題は2つ有るようだ
①Fontconfigがない
②linux上msのtruetype fontがインストールされてないのが原因らしい。
解決
①について、インストールすればいいとおもう。

$ sudo yum install fontconfig

②の解決策は2つ、/usr/local/lib/prince/style/fonts.cssを弄るか、msttcorefontsをインストールするか
私はmsttcorefontsをインストールすることにした。
まずはrepoを新規作成

$ sudo vi /etc/yum.repos.d/puias-unsupported.repo
[puias-unsupported]
name=PUIAS Unsupported
baseurl=http://elders.princeton.edu/data/puias/unsupported/5/i386/
enabled=1
gpgcheck=0

早速yumしてみると

$ sudo yum install msttcorefonts
...
Requires: /usr/sbin/chkfontpath
...

と怒れる。取り敢えずまたyumしてみると

$ sudo yum install chkfontpath
...
No package chkfontpath available.
...

またダメか!ググッてたら、chkfontpath Install Howto
ここが書いてありました!
まずatrpms-repoのrpmをダウンロード、ここ。64bitだからatrpms-repo-6-4.el6.x86_64.rpm←これ

$ wget http://dl.atrpms.net/el6-x86_64/atrpms/stable/atrpms-repo-6-4.el6.x86_64.rpm
$ sudo rpm -Uvh atrpms-repo*rpm
...

$ sudo yum install chkfontpath
...
Complete!

成功!最後はfontだ

$ sudo yum install msttcorefonts
...
Complete!

やったー!もう一回princeを実行してみる

$ /usr/local/bin/prince --input=html --server -s /home/kagen/work/anyproj/public/stylesheets/application.css -s /home/kagen/work/anyproj/public/stylesheets/print.css -s /home/kagen/work/anyproj/public/stylesheets/prince.css ~/test.html -o test.pdf
...
sta|Converting document...
prg|0
prg|100
fin|success

できた…
以上。

2011年12月20日火曜日

CentOS6(64bit)にHTML+CSSをPDFに変換するprince8

railsのプロジェクトでHTML+CSSをPDFに変換する必要がありました。
ApacheのFOPがありました。無料ですが、それはHTMLとCSSではなくXSL-FO(XML)からPDFに変更するというものでした。しかもいろいろできないことが有るみたい(文字を画像の回り込みなど)。
さらに調べたら、princeがあって、HTML+CSSをPDFに変換できる。特徴はいろいろ、かなりイケてる感じ
1.各プラットフォームに対応http://www.princexml.com/download/
2.PDFファイルの出力は当然ですが、標準出力も対応
3.テーブルの中でページが割れないように設定できる
4.ヘッダー、フッター、ページナーンバー
5.大きくしてもボヤけないSVGの読み込みが対応
6.いろんな言語のWrappersがある(Java/Python/Perl/PHP/VB....)⇒rubyがない…でも大丈夫みたい
取り敢えずインストールしてみる

$ cat /etc/redhat-release
CentOS Linux release 6.0 (Final)
$ uname -a
Linux localhost.localdomain 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 2011 x86_64 x86_64 x86_64 GNU/Linux

OSはCentOS6(64bit)みたい。
ここからダウンロード
RHEL5: CentOS 5.5 / 64-bit
prince-8.0-1.centos55.x86_64.rpm

$ cd ~/download
$ wget http://www.princexml.com/download/prince-8.0-1.centos55.x86_64.rpm

普通にインストールしたら怒られた、openssl64bitはちゃんとあるのに

$ sudo rpm -ivh prince-8.0-1.centos55.x86_64.rpm
エラー: 依存性の欠如:
libcrypto.so.6()(64bit) は prince-8.0-1.x86_64 に必要とされています
libcurl.so.3()(64bit) は prince-8.0-1.x86_64 に必要とされています
libexpat.so.0()(64bit) は prince-8.0-1.x86_64 に必要とされています
libfontconfig.so.1()(64bit) は prince-8.0-1.x86_64 に必要とされています
libfreetype.so.6()(64bit) は prince-8.0-1.x86_64 に必要とされています
libgif.so.4()(64bit) は prince-8.0-1.x86_64 に必要とされています
libjpeg.so.62()(64bit) は prince-8.0-1.x86_64 に必要とされています
libpng12.so.0()(64bit) は prince-8.0-1.x86_64 に必要とされています
libpng12.so.0(PNG12_0)(64bit) は prince-8.0-1.x86_64 に必要とされていま す
libssl.so.6()(64bit) は prince-8.0-1.x86_64 に必要とされています
libtiff.so.3()(64bit) は prince-8.0-1.x86_64 に必要とされています
libungif.so.4()(64bit) は prince-8.0-1.x86_64 に必要とされています
[kagen@localhost download]$ rpm -qa | grep openssl-devel
openssl-devel-1.0.0-4.el6_0.2.x86_64

検索したら、ここにたどり着いた。同じ困っている人がいた。http://www.princexml.com/bb/viewtopic.php?f=2&t=7021
8.1から対応してくれそうです。

$ wget http://www.princexml.com/download/prince-8.0-linux-amd64-static.tar.gz
....
$ tar xzvf prince-8.0-linux-amd64-static.tar.gz
....
$ cd prince-8.0-linux-amd64-static
$ sudo ./install.sh
[sudo] password:
Prince 8.0

Install directory
This is the directory in which Prince 8.0 will be installed.
Press Enter to accept the default directory or enter an alternative.
[/usr/local]:⇒ブランクのままエンター

Installing Prince 8.0...
Creating directories...
Installing files...

Installation complete.
Thank you for choosing Prince 8.0, we hope you find it useful.
Please visit http://www.princexml.com for updates and development news.
$ prince --version
Prince 8.0
Copyright 2002-2011 YesLogic Pty. Ltd.
Non-commercial License

取り敢えずインストール出来たみたい。