0
0

More than 3 years have passed since last update.

googleスプレッドシートのPDF化を楽にするブックマークレット

Posted at

googleスプレッドシートをPDF化するときの自分用設定をブックマークレット化してみました。

javascript:(function(){const current = location.href;if (current.match(/^.+docs\.google\.com\/spreadsheets\/d\//)) {const m = current.match(/^.+\/d\/(.+)\/edit#gid=(.+)$/);const printUrl = `https://docs.google.com/spreadsheets/d/${m[1]}/export?exportFormat=pdf&format=pdf&size=A4&portrait=false&sheetnames=false&printtitle=false&fitw=true&pagenumbers=false&gridlines=false&top_margin=0.75&bottom_margin=0.75&left_margin=0.25&right_margin=0.25&horizontal_alignment=LEFT&vertical_alignment=TOP&fzr=false&gid=${m[2]}`;window.open(printUrl);}})()

下記のように各種パラメータを設定しています。

  • exportFormat=pdf format=pdf PDF形式
  • size=A4 A4サイズ
  • portrait=false 横向き印刷
  • sheetnames=false シート名を印刷しない
  • printtitle=false タイトルを印刷しない
  • fitw=true 幅に揃える
  • pagenumbers=false ページ番号を表示しない
  • gridlines=false グリッド線を印刷しない
  • top_margin=0.75 bottom_margin=0.75 上下余白0.75インチ(プリセットの余白「狭」)
  • left_margin=0.25 right_margin=0.25左右余白0.25インチ(プリセットの余白「狭」)
  • horizontal_alignment=LEFT vertical_alignment=TOP 左上寄せ
  • fzr=false 固定行を表示しない

コード

(function(){
    const current = location.href;
    if (current.match(/^.+docs\.google\.com\/spreadsheets\/d\//)) {
        const m = current.match(/^.+\/d\/(.+)\/edit#gid=(.+)$/);
        const printUrl = `https://docs.google.com/spreadsheets/d/${m[1]}/export?exportFormat=pdf&format=pdf&size=A4&portrait=false&sheetnames=false&printtitle=false&fitw=true&pagenumbers=false&gridlines=false&top_margin=0.75&bottom_margin=0.75&left_margin=0.25&right_margin=0.25&horizontal_alignment=LEFT&vertical_alignment=TOP&fzr=false&gid=${m[2]}`;
        window.open(printUrl);
    }
})()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0