Skip to main content

PDF <-> 编写文档转换器

项目描述

pdftowrite:使用 Stylus Labs Write 注释 PDF

将 PDF 转换为Stylus Labs Write 文档的实用程序,反之亦然。

注释 PDF

有两种注释 PDF 的方法。

A. 转换 PDF -> SVG -> PDF(字面意思)

  1. pdftowrite example.pdf: 将 *.pdf 转换为 *.svgz
  2. (用 Stylus Labs 打开example.svgz写下你的笔记)
  3. writetopdf example.svgz -o example-annot.pdf: 将 *.svgz 转换为 *.pdf

pdftowrite将 PDF 页面转换为具有不可见但可选文本层的 SVG 路径,因此您可以将文本保留为可选字符。

您应该使用writetopdf不支持某些功能(例如 Unicode 文本、多坐标 tspan 等)的 Write 的 PDF 导出器来代替。

但是,结果 PDF(不包括注释)与原始 PDF 并非 100% 相同。这是因为:

  • PDF 和 SVG 不是 100% 兼容的
  • Write 不支持整个 SVG 规范,因此需要进行一些修改以与 Write 兼容
  • 原始文本元素被删除。相反,如前所述,将文本层添加到页面

B. 注释模式

  1. pdftowrite example.pdf: 将 *.pdf 转换为 *.svgz
  2. (用 Stylus Labs 打开example.svgz写下你的笔记)
  3. writetopdf --annot example.svgz -o example-annot.pdf: 新 PDF = 原始 PDF + 注释

您可以看到在3--annot中添加了该选项。如果添加了该选项,则 通过在原始 PDF 页面上覆盖注释来创建新 PDF。这类似于 Xournal 的方法。writetopdf

您可以使用选项注释不同的 PDF 文件--pdf-file FILE。例如:

writetopdf --annot --pdf-file example2.pdf example.svgz -o example2-annot.pdf

安装

pip install --user pdftowrite

要求

pdftowrite

  • 波普勒 ( pdfinfo)
  • Inkscape(本机或 flatpak)
  • ImageMagick ( convert)
  • 压缩包
  • lxml (libxml2, libxslt)

writetopdf

  • wkhtmltopdf
  • PDFtk(pdftk-java)
  • 库 ( rsvg-convert)
  • 压缩包

您需要手动安装这些软件包。例如:

  • Debian/Ubuntu:sudo apt install poppler-utils inkscape imagemagick gzip libxml2-dev libxslt-dev wkhtmltopdf pdftk librsvg2-bin
  • 软呢帽:sudo dnf install poppler inkscape ImageMagick gzip libxml2-devel libxslt-devel wkhtmltopdf pdftk librsvg2-tools
  • 拱:sudo pacman -S poppler inkscape imagemagick gzip libxslt wkhtmltopdf pdftk librsvg

用法

pdftowrite

usage: pdftowrite [-h] [-v] [-o OUTPUT] [-f] [-m {mixed,poppler,inkscape}]
                  [-C] [-d DPI] [-g PAGES] [-u NODUP_PAGES] [-Z] [-s SCALE]
                  [-x X] [-y Y] [-X XRULING] [-Y YRULING] [-l MARGIN_LEFT]
                  [-p PAPERCOLOR] [-r RULECOLOR]
                  FILE

Convert PDF to Stylus Labs Write document

positional arguments:
  FILE                  A pdf file

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -o OUTPUT, --output OUTPUT
                        Specify output filename
  -f, --force           Overwrite existing files without asking
  -m {mixed,poppler,inkscape}, --mode {mixed,poppler,inkscape}
                        Specify render mode (default: mixed)
  -C, --no-compat-mode  Turn off Write compatibility mode
  -d DPI, --dpi DPI     Specify resolution for bitmaps and rasterized filters
                        (default: 96)
  -g PAGES, --pages PAGES
                        Specify pages to convert (e.g. "1 2 3", "1-3")
                        (default: all)
  -u NODUP_PAGES, --nodup-pages NODUP_PAGES
                        Specify no-dup pages (e.g. "1 2 3", "1-3") (default:
                        all)
  -Z, --nozip           Do not compress output
  -s SCALE, --scale SCALE
                        Scale page size (default: 1.0)
  -x X                  Specify the x coordinate of the viewport of <svg>
                        (default: 10.0)
  -y Y                  Specify the y coordinate of the viewport of <svg>
                        (default: 10.0)
  -X XRULING, --xruling XRULING
                        Specify x rulling (default: 0.0)
  -Y YRULING, --yruling YRULING
                        Specify y rulling (default: 40.0)
  -l MARGIN_LEFT, --margin-left MARGIN_LEFT
                        Specify margin left (default: 100.0)
  -p PAPERCOLOR, --papercolor PAPERCOLOR
                        Specify paper color (default: #FFFFFF)
  -r RULECOLOR, --rulecolor RULECOLOR
                        Specify rule color (default: #9F0000FF)

写到pdf

usage: writetopdf [-h] [-v] [--annot] [--pdf-file PDF_FILE] [-o OUTPUT] [-f]
                  [-g PAGES] [-s SCALE]
                  FILE

Convert Stylus Labs Write document to PDF

positional arguments:
  FILE                  A Write document

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --annot               Use annotation mode
  --pdf-file PDF_FILE   Specify the PDF file to be annotated
  -o OUTPUT, --output OUTPUT
                        Specify output filename
  -f, --force           Overwrite existing files without asking
  -g PAGES, --pages PAGES
                        Specify pages to convert (e.g. "1 2 3", "1-3")
                        (default: all)
  -s SCALE, --scale SCALE
                        Scale page size (default: 1.0)

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

pdftowrite-2021.5.3.tar.gz (14.5 kB 查看哈希

已上传 source

内置分布

pdftowrite-2021.5.3-py3-none-any.whl (15.7 kB 查看哈希

已上传 py3