[筆記] 使用 command line 處理 pdf
## Tools
- imagick
- ghostscript
- https://github.com/armaab/pdfmark
## Image to pdf
```bash
convert *.jpg output.pdf
```
## Merge
```bash
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf input3.pdf
```
## 上索引
```bash
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=indexed.pdf -dPDFSETTINGS=/prepress pdfmark.txt input.pdf
```
`pdfmark.txt`
```
[/Page 1 /Title <FEFF6A19984C0031>/OUT pdfmark
[/Page 2 /Title <FEFF6A19984C0032>/OUT pdfmark
[/Page 4 /Title <FEFF6A19984C0033>/OUT pdfmark
```
(要先把 UTF-8 的文字用 UTF-16BE encode)
或是可以直接用 [pdfmark](https://github.com/armaab/pdfmark)
## 改標題
```
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf -c "[ /Title <FEFF65874EF66A19984C> /DOCINFO pdfmark"
```
## Reference
- https://www.lexjansen.com/phuse/2018/ad/AD07_ppt.pdf
- https://stackoverflow.com/questions/9188189/wrong-encode-when-update-pdf-meta-data-using-ghostscript-and-pdfmark
- https://askubuntu.com/questions/1327809/how-to-specify-the-title-of-the-pdf-file-gs-produces
2021-08-19 00:43:04
留言
Last fetch: --:--
現在還沒有留言!