> brew install poppler でいれる。
> pdftoppm -png inputfile output_prefixouput_prefix_01, output_prefix_02 のようなファイルができる。
技術系の備忘録.基本的に自分だけのためのものなので,詳しく書きません.検索でいらした方、すみません.
> pdftocairo -svg file.pdf file.svgなぜcairoなのかよくわからない。。 ちなみに、ディレクトリにあるpdfを一括で変換するには
> foreach f in *.pdf ; do pdftocairo -svg $f $f:r.svg ; doneとすればいい。
version: '3'
services:
ubuntu:
build:
context: .
dockerfile: Dockerfile
container_name: ubuntu-test
stdin_open: true # docker run -i
tty: true # docker run -t
platform: linux/amd64
entrypoint: bin/bash
volumes:
- "/run/host-services/ssh-auth.sock:/tmp/ssh-agent.sock"
environment:
SSH_AUTH_SOCK: "/tmp/ssh-agent.sock"
最後のvolumeとenvironment がポイント。これはmacでのやり方なので、
linuxだとまた違うようだ。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options=Options()
options.add_extension(pathToExtension)
driver = webdriver.Chrome("./chromedriver", options=options)
注意点としては、savefile.default_directory の指定はどうも絶対パスでないといけないようなので、 Pathを使って作ってやる必要がある。
pathToExtension="2.7.0_0.crx"
def optionsSetUp():
#印刷としてPDF保存する設定
options=Options()
appState = {
"recentDestinations": [
{
"id": "Save as PDF",
"origin": "local",
"account":""
}
],
"selectedDestinationId": "Save as PDF",
"version": 2,
"isLandscapeEnabled": False, #印刷の向きを指定 tureで横向き、falseで縦向き。
"pageSize": 'A4', #用紙タイプ(A3、A4、A5、Legal、 Letter、Tabloidなど)
"isHeaderFooterEnabled": False, #ヘッダーとフッター
"isCssBackgroundEnabled": True, #背景のグラフィック
"isCollateEnabled": True #部単位で印刷
}
prefs = {'printing.print_preview_sticky_settings.appState':
json.dumps(appState),
"savefile.default_directory": str(Path('../rendered').resolve())
} #appState --> pref
options.add_experimental_option('prefs', prefs)
options.add_argument('--kiosk-printing')
options.add_extension(pathToExtension)
return options
driver = webdriver.Chrome("./chromedriver", options=options)
driver.get(URL)
time.sleep(2) # ページが確実にレンダリングされるのを待つ
driver.execute_script('window.print();')
? show the help dialog for a list of all available keys
h scroll left
j scroll down
k scroll up
l scroll right
gg scroll to top of the page
G scroll to bottom of the page
d scroll down half a page
u scroll up half a page
f open a link in the current tab
F open a link in a new tab
r reload
gs view source
i enter insert mode -- all commands will be ignored until you hit Esc to exit
yy copy the current url to the clipboard
yf copy a link url to the clipboard
gf cycle forward to the next frame
gF focus the main/top frame
newpage
o Open URL, bookmark, or history entry
O Open URL, bookmark, history entry in a new tab
b Open bookmark
B Open bookmark in a new tab
find系
/ enter find mode
-- type your search query and hit enter to search, or Esc to cancel
n cycle forward to the next find match
N cycle backward to the previous find match
history
H go back in history
L go forward in history
tab
J, gT go one tab left
K, gt go one tab right
g0 go to the first tab. Use ng0 to go to n-th tab
g$ go to the last tab
^ visit the previously-visited tab
t create tab
yt duplicate current tab
x close current tab
X restore closed tab (i.e. unwind the 'x' command)
T search through your open tabs
W move current tab to new window
pin/unpin current tab
inkscape -o cropped.svg -D source.svg
FileNotFoundError: [Errno 2] No such file or directory: 'inkscape'なので、inkscape をインストールして、下のようにしてpathを通す。inkscapeは、app storeからは インストールできないみたいなので、webページからダウンロードした。
ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape \
/usr/local/bin/inkscape
\documentclass[11pt]{article}
となっているところを、
\documentclass[xelatex,ja=standard]{bxjsarticle}
と直せばいいのだけど、このindex.tex.j2がどこにあるのかわからない。
こちらにあるように、
$ jupyter nbconvert --to pdf filename.ipynb --debugのようにdebugオプションをつけると、templateを探しに行くパスが表示されるのでそこを見ていけばいい。のだが、めちゃめちゃ数が多くてたいへんだった。
jupyter nbconvert --to html --TagRemovePreprocessor.remove_input_tags='{"hide"}' test.ipynb
のようにして、入力セルだけを抑制できる。ここで hide としているのは任意のタグなので、適当に変更することができる。なんで波括弧が要るのか、よくわからない。
remove_input_tags を remove_cell_tags 、 remove_output_tags にすると、それぞれ入出力両方、出力セルのみの出力を抑制できる。
タグは柔軟で素晴らしいのだけど、タグを付けるのが結構面倒だし、ついているのかエディタ上で目視で確認する事ができない。 RegexRemovePreprocessor というものがあり、これはセルの内容に対して、正規表現で検索を行って、マッチしたら出力を抑制してくれる。
jupyter nbconvert --RegexRemovePreprocessor.patterns="['^# hide']" test.ipynb素晴らしい、がこれはまるごと抑制してしまうので、入力だけ抑制することはできない。 ソースコードはsite-packages/nbconvert/preprocessors にあるのだけど、 全く対応していない。ほんのちょっといじればできそうなんだけどなあ。。 ということで、やってみたらできたので、 こちらにまとめた。