2019-10-08 書籍スキャンPDFをScrapboxに置く
- https://www.facebook.com/toshiyukimasui/posts/10157675595687498
- 画像にバラした後スクリプトでGyazo Proにアップロード
- Gyazo ProはGoogle Cloud PlatformのCLOUD VISION APIを使ってOCRしている
- 時間がかかるのでしばらく経ってからOCRデータを取得している
https://github.com/masui/Book2Scrapbox の読解
- ScanSnapでのスキャン結果をpdfimagesで取り出している
- 関連 PDFからPNGへの変換
- 裁断スキャンPDFならそれでOK
- スライドのPDFなどはNG
- ローカルにMD5ハッシュでフォルダを切って保存している
- それをAWSにsyncする
- AWS コマンドラインインターフェイス(CLI: AWSサービスを管理する統合ツール)| AWSのインストールが必要
- AWS CLI のインストール - AWS Command Line Interface
- めっちゃ親切に書いてあるな
- AWS CLI の設定 - AWS Command Line Interface
- aws s3 sync
- 手元で削除してもS3上のものは削除されないので安心
- AWSへのsyncは実は必須ではない
- gyazoにfileの中身を送っているから
- https://github.com/nishio/Book2Scrapbox
- スライドはpdfimegesで画像化できないのでpdftocairoを使う
$ pdftocairo -r 200 -f 0 -jpeg <pdf> pages
- see PDFからPNGへの変換
- 複数のPDFをまとめて1つのJSONにするようにした
- pdfstojson.rbがmakejson.rbを呼び出す
- Pythonでやる方法も調べたが、makejson.rbを子プロセスとして使う形で実現できた
- JSONができてしばらくしてからGyazoからOCR結果をダウンロードして加筆する
- スライドはpdfimegesで画像化できないのでpdftocairoを使う