如何运行示例 Demo
快速验证
发版包提供 samples/demo/demo.js 作为示例入口。不传入 PDF 文件时,示例会将 samples/input_files 下的内置 PDF 转换为 Word、Excel、PowerPoint、CSV、HTML、RTF、图片、TXT、JSON、Markdown、可搜索 PDF 和 OFD,并输出到 samples/output_files。
shell
cd /path/to/ComPDF_conversion_node
node samples/demo/demo.js关键输出示例:
text
licenseVerify => 0
version => 4.1.0
setDocumentAIModel => 0
pdf to word: result=0, output=...
all conversion tasks finished多文件 Demo
示例也支持多文件转换。每个 worker 进程都会独立初始化 SDK。
shell
cd /path/to/ComPDF_conversion_node
node samples/demo/demo.js \
--threads 2 \
samples/input_files/word.pdf \
samples/input_files/excel.pdf默认情况下,示例会将转换结果写入 samples/output_files。只有需要将结果写入其他目录时,才需要使用 --output 参数。
示例默认使用 samples/license.xml。如需测试其他许可证 XML 路径或许可证密钥,可以通过 --license 或 ComPDF_LICENSE 覆盖。
shell
node samples/demo/demo.js \
--license /path/to/license.xml \
samples/input_files/word.pdf示例默认加载发版包中的 DocumentAI 模型:
text
resource/models/documentai.model如需加载其他模型,可以通过 --model 或 ComPDF_MODEL_PATH 覆盖:
shell
node samples/demo/demo.js \
--model /path/to/documentai.model \
--threads 2 \
samples/input_files/word.pdf