如何运行示例 Demo
Linux
Ruby SDK 发布包提供 samples/demo/demo.rb。请在包含 doc/、lib/、resource/ 和 samples/ 的发布包根目录下运行命令。不指定输入 PDF 时,Demo 会转换 samples/input_files 中的示例 PDF,并将结果输出到 samples/output_files。
shell
cd /path/to/linux-x86_64
ruby samples/demo/demo.rb也可以传入自定义输入文件和输出目录:
shell
ruby samples/demo/demo.rb \
--output /tmp/compdf_ruby_demo_out \
/path/to/input.pdf可以通过命令行参数传入许可证信息:
shell
ruby samples/demo/demo.rb \
--license /path/to/license.xml \
--device-id DEVICE_ID \
--app-id com.example.application \
--output /tmp/compdf_word_out \
/path/to/input.pdf也可以通过环境变量传入:
shell
export ComPDF_LICENSE="/path/to/license.xml"
export ComPDF_DEVICE_ID="DEVICE_ID"
export ComPDF_APP_ID="com.example.application"
ruby samples/demo/demo.rb --output /tmp/compdf_word_out /path/to/input.pdfDemo 在未传入参数时默认使用发布包内资源:
- License:
samples/license.xml,或ComPDF_LICENSE/COMPDF_LICENSE_KEY。 - DocumentAI 模型:
resource/models/documentai.model,或ComPDF_MODEL_PATH。 - 输入 PDF:
samples/input_files/word.pdf、samples/input_files/excel.pdf、samples/input_files/powerpoint.pdf。 - 输出目录:
samples/output_files。
显式传入输入 PDF 时,demo.rb 也支持多进程 PDF 转 Word:
shell
ruby samples/demo/demo.rb \
--license /path/to/license.xml \
--output /tmp/compdf_ruby_demo_out \
--threads 2 \
samples/input_files/word.pdf \
samples/input_files/excel.pdf如果需要在 demo 中加载 DocumentAI 模型,可以传入 --model:
shell
ruby samples/demo/demo.rb \
--output /tmp/compdf_ruby_demo_out \
--model /path/to/documentai.model \
/path/to/input.pdf