Add Markdown-to-PDF converter with RTL support
This commit is contained in:
7 files changed
+1139
-4
No files matched your search
@@ -11,8 +11,10 @@ The exporter reads the structured conversation data embedded in ChatGPT share pa
|
||||
- includes conversation metadata such as title, source URL, conversation ID, timestamps, and model slug
|
||||
- includes per-message metadata such as author, message ID, created/updated time, status, channel, recipient, model, request ID, and turn ID
|
||||
- records uploaded image/file metadata such as name, MIME type, size, dimensions, and source pointer
|
||||
- converts Markdown exports to clean PDF files
|
||||
- supports RTL PDF layout for Persian/Arabic chats
|
||||
- supports custom PDF font family, font file, font size, page size, and margins
|
||||
- can include hidden/system/internal nodes when requested
|
||||
- uses only the Python standard library
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -36,6 +38,8 @@ python3 -m pip install -e .
|
||||
chatgpt-share-exporter "https://chatgpt.com/share/YOUR_SHARE_ID"
|
||||
```
|
||||
|
||||
This installs the PDF dependencies too.
|
||||
|
||||
## Options
|
||||
|
||||
```bash
|
||||
@@ -54,6 +58,52 @@ chatgpt-share-exporter URL -o my_exports --overwrite
|
||||
- `--html-file`: parse an already downloaded share page instead of fetching the URL
|
||||
- `--timeout`: set the download timeout in seconds
|
||||
|
||||
## Convert Exports To PDF
|
||||
|
||||
Convert every Markdown export in `exports/`:
|
||||
|
||||
```bash
|
||||
chatgpt-share-exporter pdf exports
|
||||
```
|
||||
|
||||
or use the dedicated command:
|
||||
|
||||
```bash
|
||||
chatgpt-export-to-pdf exports
|
||||
```
|
||||
|
||||
Generate an RTL PDF:
|
||||
|
||||
```bash
|
||||
chatgpt-share-exporter pdf exports --rtl
|
||||
```
|
||||
|
||||
Use a custom font and size:
|
||||
|
||||
```bash
|
||||
chatgpt-share-exporter pdf exports \
|
||||
--font-family Vazirmatn \
|
||||
--font-path ./fonts/Vazirmatn-Regular.ttf \
|
||||
--font-size 14
|
||||
```
|
||||
|
||||
PDF options:
|
||||
|
||||
- `--direction auto|ltr|rtl`: choose PDF text direction. Default: `auto`
|
||||
- `--rtl`: shortcut for `--direction rtl`
|
||||
- `--ltr`: shortcut for `--direction ltr`
|
||||
- `--font-family`: preferred body font family. Default: `Vazirmatn`
|
||||
- `--font-path`: explicit `.ttf` or `.otf` font file path
|
||||
- `--font-size`: base font size in points. Default: `14`
|
||||
- `--page-size A4|Letter`: PDF page size. Default: `A4`
|
||||
- `--margin-mm`: page margin in millimeters. Default: `16`
|
||||
- `--recursive`: convert Markdown files in nested export directories
|
||||
- `--overwrite`: replace existing PDF files
|
||||
|
||||
Generated PDFs are written to `pdf_exports/`, which is ignored by Git.
|
||||
|
||||
For best Persian output, install Vazirmatn locally or pass its font file with `--font-path`. If Vazirmatn is not installed, the converter searches for common system fallbacks such as Arial Unicode, Tahoma, DejaVu Sans, and Noto Arabic fonts.
|
||||
|
||||
## Development
|
||||
|
||||
Run tests:
|
||||
@@ -65,7 +115,7 @@ python3 -m unittest discover -s tests
|
||||
Run a syntax check:
|
||||
|
||||
```bash
|
||||
python3 -m py_compile main.py chatgpt_share_exporter.py tests/test_exporter.py
|
||||
python3 -m py_compile main.py chatgpt_share_exporter.py chatgpt_pdf_converter.py tests/test_exporter.py tests/test_pdf_converter.py
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
Reference in new issue
Block a user