Skip to content

Commit c85989a

Browse files
committed
rename wps2pdf -> doc2pdf; add README_CN.md; add CI workflow
1 parent c06f664 commit c85989a

5 files changed

Lines changed: 203 additions & 73 deletions

File tree

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
tags: [ "v*" ]
7+
pull_request:
8+
branches: [ "master" ]
9+
release:
10+
types: [ published ]
11+
12+
jobs:
13+
build:
14+
runs-on: windows-2022
15+
strategy:
16+
matrix:
17+
arch: [Win32, x64]
18+
include:
19+
- arch: Win32
20+
suffix: x86
21+
- arch: x64
22+
suffix: x64
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Configure CMake
28+
run: cmake -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -B build
29+
30+
- name: Build
31+
run: cmake --build build --config Release
32+
33+
- name: Upload artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: doc2pdf-${{ matrix.suffix }}
37+
path: build\Release\doc2pdf.exe
38+
39+
- name: Upload to release
40+
if: github.event_name == 'release' && github.event.action == 'published'
41+
uses: svenstaro/upload-release-action@v2
42+
with:
43+
repo_token: ${{ secrets.GITHUB_TOKEN }}
44+
file: build\Release\doc2pdf.exe
45+
tag: ${{ github.ref }}
46+
asset_name: doc2pdf-${{ matrix.suffix }}.exe
47+
overwrite: true

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(wps2pdf LANGUAGES CXX)
2+
project(doc2pdf LANGUAGES CXX)
33

44
set(CMAKE_CXX_STANDARD 11)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

7-
#if(CMAKE_SIZEOF_VOID_P EQUAL 8)
8-
# message(FATAL_ERROR "This project must be built as 32-bit (x86). Use -A Win32 or set CMAKE_GENERATOR_PLATFORM=Win32")
9-
#endif()
10-
117
if(MSVC)
128
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /utf-8")
139
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /utf-8")
1410
endif()
1511

16-
add_executable(wps2pdf wps2pdf.cpp)
17-
target_link_libraries(wps2pdf ole32 oleaut32)
12+
add_executable(doc2pdf doc2pdf.cpp)
13+
target_link_libraries(doc2pdf ole32 oleaut32)

README.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
# wps2pdf
1+
# doc2pdf
22

3-
> 命令行工具,将 WPS / Microsoft Office 文档(.doc/.docx)转换为 PDF
3+
> A command-line tool to convert WPS / Microsoft Office documents (.doc/.docx) to PDF.
44
55
[![Platform](https://img.shields.io/badge/Platform-Windows-blue)](https://github.com/lilucpp/doc2pdf)
66
[![Language](https://img.shields.io/badge/Language-C++11-00599C)](https://isocpp.org/)
77
[![Build](https://img.shields.io/badge/Build-CMake_%2F_MSVC-6DB33F)](https://cmake.org/)
88
[![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
99

10-
## 特性
10+
## Features
1111

12-
- **无需打印机驱动**通过 COM 自动化调用 WPS / Office 原生导出 API
13-
- **自动检测**优先使用 WPS,回退到 Microsoft Word
14-
- **支持页面范围**可指定起始/结束页码
15-
- **轻量** exe,无外部运行时依赖(静态链接 /MT
16-
- **兼容 32/64 位系统**推荐 32 位构建以兼容大多数 WPS/Office 安装
12+
- **No printer driver required**Uses COM automation to call the native export API of WPS / Office
13+
- **Auto-detection**Prefers WPS, falls back to Microsoft Word
14+
- **Page range support**Specify start/end page numbers
15+
- **Lightweight**Single exe, no external runtime dependencies (static link /MT)
16+
- **32/64-bit compatible**32-bit build recommended for maximum WPS/Office compatibility
1717

18-
## 实现原理
18+
## How It Works
1919

20-
通过 **COM 自动化** 调用应用程序的 `ExportAsFixedFormat` API,无需任何中间件或虚拟打印机。
20+
Uses **COM automation** to invoke the application's `ExportAsFixedFormat` API, no middleware or virtual printer needed.
2121

22-
## 兼容性
22+
## Compatibility
2323

24-
| 应用程序 | ProgID | 要求 |
25-
|----------|--------|------|
26-
| **WPS Office** (推荐) | `KWps.Application` | WPS Office 已安装 |
27-
| **Microsoft Office Word 2007** | `Word.Application` | **SP2** 或安装 [Save as PDF 插件](http://www.microsoft.com/downloads/details.aspx?familyid=4d951911-3e7e-4ae6-b059-a2e79ed87041) |
28-
| **Microsoft Office Word 2010+** | `Word.Application` | 原生支持,无需额外组件 |
29-
| **Microsoft Office 365** | `Word.Application` | 原生支持 |
24+
| Application | ProgID | Requirements |
25+
|-------------|--------|-------------|
26+
| **WPS Office** (recommended) | `KWps.Application` | WPS Office installed |
27+
| **Microsoft Office Word 2007** | `Word.Application` | Requires **SP2** or [Save as PDF add-in](http://www.microsoft.com/downloads/details.aspx?familyid=4d951911-3e7e-4ae6-b059-a2e79ed87041) |
28+
| **Microsoft Office Word 2010+** | `Word.Application` | Native support, no additional components |
29+
| **Microsoft Office 365** | `Word.Application` | Native support |
3030

31-
> 程序启动顺序:先尝试 WPS → 失败则尝试 Office Word → 都失败则报错退出。
31+
> Startup order: tries WPS first → falls back to Office Word → exits with error if both fail.
3232
33-
## 使用
33+
## Usage
3434

3535
```
36-
wps2pdf <输入文件> [-o 输出文件] [-f 起始页] [-t 结束页]
36+
doc2pdf <input file> [-o output file] [-f from page] [-t to page]
3737
```
3838

39-
| 参数 | 说明 |
40-
|------|------|
41-
| `-o` / `--output` | 输出 PDF 路径(默认:输入文件同名.pdf |
42-
| `-f` / `--from` | 起始页码(默认:第 1 页) |
43-
| `-t` / `--to` | 结束页码(默认:最后一页,需同时指定 `-f` |
39+
| Argument | Description |
40+
|----------|-------------|
41+
| `-o` / `--output` | Output PDF path (default: input file name with .pdf extension) |
42+
| `-f` / `--from` | Start page (default: page 1) |
43+
| `-t` / `--to` | End page (default: last page; requires `-f`) |
4444

45-
### 示例
45+
### Examples
4646

4747
```powershell
48-
wps2pdf 1.docx # 全部页面
49-
wps2pdf 1.docx -f 2 -t 5 # 2-5
50-
wps2pdf 1.docx -f 3 # 从第 3 页到末尾
51-
wps2pdf 1.docx -o D:\out.pdf # 指定输出路径
48+
doc2pdf 1.docx # All pages
49+
doc2pdf 1.docx -f 2 -t 5 # Pages 2-5
50+
doc2pdf 1.docx -f 3 # From page 3 to end
51+
doc2pdf 1.docx -o D:\out.pdf # Specify output path
5252
```
5353

54-
## 编译
54+
## Build
5555

56-
### 要求
56+
### Requirements
5757

58-
- Visual Studio 2022 Build Tools(或完整版 VS)
58+
- Visual Studio 2022 Build Tools (or full VS)
5959
- CMake 3.10+
6060

61-
### 构建(32 位,静态链接 /MT
61+
### Build (32-bit, static link /MT)
6262

6363
```powershell
6464
cmake -G "Visual Studio 17 2022" -A Win32 -B build
6565
cmake --build build --config Release
6666
```
6767

68-
产物在 `build\Release\wps2pdf.exe`,不依赖 VC 运行时库。
68+
Output at `build\Release\doc2pdf.exe`, no VC runtime dependencies.
6969

70-
### 架构说明
70+
### Architecture Notes
7171

72-
工具编译为 32 位,通过 COM 调用 WPS/Office。32 位工具只能调用 32 位的 WPS/Office(64 位系统上这是最常见的安装方式)。
72+
The tool is compiled as 32-bit and uses COM to call WPS/Office. A 32-bit tool can only call 32-bit WPS/Office (the most common installation on 64-bit systems).
7373

74-
若需支持纯 64 位 Office,请用 `-A x64` 额外编译 64 位版本:
74+
To support native 64-bit Office, also build a 64-bit version with `-A x64`:
7575

7676
```powershell
7777
cmake -G "Visual Studio 17 2022" -A x64 -B build64
7878
cmake --build build64 --config Release
7979
```
8080

81-
## 相关关键词
81+
## Keywords
8282

83-
`doc2pdf` `docx2pdf` `wps2pdf` `word转pdf` `wps转pdf` `office转pdf` `命令行pdf转换`
83+
`doc2pdf` `docx2pdf` `word to pdf` `wps to pdf` `office to pdf` `command line pdf converter`
8484

85-
## 许可证
85+
## License
8686

8787
[MIT](LICENSE)

README_CN.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# doc2pdf
2+
3+
> 命令行工具,将 WPS / Microsoft Office 文档(.doc/.docx)转换为 PDF。
4+
5+
[![Platform](https://img.shields.io/badge/Platform-Windows-blue)](https://github.com/lilucpp/doc2pdf)
6+
[![Language](https://img.shields.io/badge/Language-C++11-00599C)](https://isocpp.org/)
7+
[![Build](https://img.shields.io/badge/Build-CMake_%2F_MSVC-6DB33F)](https://cmake.org/)
8+
[![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
9+
10+
## 特性
11+
12+
- **无需打印机驱动** — 通过 COM 自动化调用 WPS / Office 原生导出 API
13+
- **自动检测** — 优先使用 WPS,回退到 Microsoft Word
14+
- **支持页面范围** — 可指定起始/结束页码
15+
- **轻量** — 单 exe,无外部运行时依赖(静态链接 /MT)
16+
- **兼容 32/64 位系统** — 推荐 32 位构建以兼容大多数 WPS/Office 安装
17+
18+
## 实现原理
19+
20+
通过 **COM 自动化** 调用应用程序的 `ExportAsFixedFormat` API,无需任何中间件或虚拟打印机。
21+
22+
## 兼容性
23+
24+
| 应用程序 | ProgID | 要求 |
25+
|----------|--------|------|
26+
| **WPS Office** (推荐) | `KWps.Application` | WPS Office 已安装 |
27+
| **Microsoft Office Word 2007** | `Word.Application` |**SP2** 或安装 [Save as PDF 插件](http://www.microsoft.com/downloads/details.aspx?familyid=4d951911-3e7e-4ae6-b059-a2e79ed87041) |
28+
| **Microsoft Office Word 2010+** | `Word.Application` | 原生支持,无需额外组件 |
29+
| **Microsoft Office 365** | `Word.Application` | 原生支持 |
30+
31+
> 程序启动顺序:先尝试 WPS → 失败则尝试 Office Word → 都失败则报错退出。
32+
33+
## 使用
34+
35+
```
36+
doc2pdf <输入文件> [-o 输出文件] [-f 起始页] [-t 结束页]
37+
```
38+
39+
| 参数 | 说明 |
40+
|------|------|
41+
| `-o` / `--output` | 输出 PDF 路径(默认:输入文件同名.pdf) |
42+
| `-f` / `--from` | 起始页码(默认:第 1 页) |
43+
| `-t` / `--to` | 结束页码(默认:最后一页,需同时指定 `-f`|
44+
45+
### 示例
46+
47+
```powershell
48+
doc2pdf 1.docx # 全部页面
49+
doc2pdf 1.docx -f 2 -t 5 # 第 2-5 页
50+
doc2pdf 1.docx -f 3 # 从第 3 页到末尾
51+
doc2pdf 1.docx -o D:\out.pdf # 指定输出路径
52+
```
53+
54+
## 编译
55+
56+
### 要求
57+
58+
- Visual Studio 2022 Build Tools(或完整版 VS)
59+
- CMake 3.10+
60+
61+
### 构建(32 位,静态链接 /MT)
62+
63+
```powershell
64+
cmake -G "Visual Studio 17 2022" -A Win32 -B build
65+
cmake --build build --config Release
66+
```
67+
68+
产物在 `build\Release\doc2pdf.exe`,不依赖 VC 运行时库。
69+
70+
### 架构说明
71+
72+
工具编译为 32 位,通过 COM 调用 WPS/Office。32 位工具只能调用 32 位的 WPS/Office(64 位系统上这是最常见的安装方式)。
73+
74+
若需支持纯 64 位 Office,请用 `-A x64` 额外编译 64 位版本:
75+
76+
```powershell
77+
cmake -G "Visual Studio 17 2022" -A x64 -B build64
78+
cmake --build build64 --config Release
79+
```
80+
81+
## 相关关键词
82+
83+
`doc2pdf` `docx2pdf` `word转pdf` `wps转pdf` `office转pdf` `命令行pdf转换`
84+
85+
## 许可证
86+
87+
[MIT](LICENSE)

0 commit comments

Comments
 (0)