Skip to content

Commit 8705df8

Browse files
Updated readme and example file name.
1 parent d4ae380 commit 8705df8

File tree

2 files changed

+71
-13
lines changed

2 files changed

+71
-13
lines changed

README.md

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ConvertApi (PowerShell)
22

33
Thin PowerShell wrapper for the ConvertAPI v2 REST endpoints.
4-
Supports **single-file conversions**, **URL-based conversions**, and **multi-file merges** (e.g., PDF → merge) with safe downloads.
4+
Supports **single-file conversions**, **URL-based conversions**, and **multi-file multi-part uploads** (e.g., PDF → merge) with safe downloads.
55

66
> **Get your API token:** https://www.convertapi.com/a/authentication
77
@@ -12,16 +12,28 @@ Supports **single-file conversions**, **URL-based conversions**, and **multi-fil
1212
- 🔐 Token-based auth via `CONVERTAPI_API_TOKEN` or `Set-ConvertApiToken`
1313
- 📄 Single local file upload (raw bytes, `Content-Disposition`)
1414
- 🌐 Single URL conversion (query param `Url=…`)
15-
- 📦 Multi-input **multipart/form-data** for merges: `Files[0]`, `Files[1]`, …
15+
- 📦 Multi-input **multipart/form-data** (`Files[0]`, `Files[1]`, …) when you pass multiple inputs
16+
- 📎 **Extra file parameters**: any parameter whose name ends with `File` (e.g., `OverlayFile`, `BackgroundFile`) is detected and uploaded as a file part automatically
1617
- ⚙️ Extra options via `-Parameters @{ Name = 'Value' }`
17-
- 💾 Saves results to disk; preserves API-provided filenames
18+
- 💾 Saves results to disk; preserves APIprovided filenames
1819
- 🧪 `-WhatIf`/`-Confirm` safety (SupportsShouldProcess)
1920
- 🖥 Works on Windows PowerShell 5.1 and PowerShell 7+
2021

2122
---
2223

2324
## Install
2425

26+
### Option A — PowerShell Gallery (recommended)
27+
Once published to the Gallery, end users can install with:
28+
```powershell
29+
Install-Module ConvertApi -Scope CurrentUser
30+
Import-Module ConvertApi -Force
31+
# later updates
32+
Update-Module ConvertApi
33+
```
34+
> Notes: First-time installs may prompt to trust the PSGallery repo and to install the NuGet provider—this is normal.
35+
36+
### Option B — Manual install from source
2537
Place the folder:
2638

2739
```
@@ -36,11 +48,17 @@ into your user modules path:
3648
- PowerShell 7+ → `~/Documents/PowerShell/Modules/ConvertApi`
3749

3850
Then:
39-
4051
```powershell
4152
Import-Module ConvertApi -Force
4253
```
4354

55+
> If you downloaded a ZIP in a browser, Windows may mark files as “downloaded from internet.”
56+
> Run once to unblock (not needed when installing via **PowerShell Gallery** or **git clone**):
57+
> ```powershell
58+
> Set-ExecutionPolicy -Scope Process Bypass -Force
59+
> Unblock-File -Path '<repo>\*' -Recurse
60+
> ```
61+
4462
---
4563
4664
## Authentication
@@ -119,7 +137,29 @@ Invoke-ConvertApi -From pdf -To merge `
119137
-OutputPath .\out -StoreFile
120138
```
121139

122-
> The module automatically switches to **multipart/form-data** with `Files[0]`, `Files[1]`, … when it detects multiple inputs (files and/or URLs).
140+
> When you pass multiple inputs (files and/or URLs), the module automatically uses **multipart/form‑data** and sends them as `Files[0]`, `Files[1]`, …
141+
142+
---
143+
144+
## Watermark / Overlay (extra file parameter)
145+
146+
Some converters accept **additional files** as parameters. Any parameter whose name ends with `File` is treated as a file part when the value is a local path.
147+
148+
**PDF → watermark-overlay (overlay from local PDF):**
149+
```powershell
150+
Invoke-ConvertApi -From pdf -To watermark-overlay `
151+
-File .\a.pdf `
152+
-Parameters @{ OverlayFile = '.\b.pdf'; Opacity = 0.6 } `
153+
-OutputPath .\out -StoreFile -Verbose
154+
```
155+
156+
**Overlay from a URL:**
157+
```powershell
158+
Invoke-ConvertApi -From pdf -To watermark-overlay `
159+
-File .\a.pdf `
160+
-Parameters @{ OverlayFile = 'https://example.com/b.pdf' } `
161+
-OutputPath .\out -StoreFile
162+
```
123163

124164
---
125165

@@ -130,7 +170,7 @@ Invoke-ConvertApi -From pdf -To merge `
130170

131171
- `-File` `[string[]]`
132172
One or more local files.
133-
- **1 file** → raw bytes upload (octet-stream + Content-Disposition)
173+
- **1 file** → raw bytes upload (octetstream + ContentDisposition)
134174
- **2+ files** → multipart form with `Files[i]`
135175

136176
- `-Url` `[string[]]`
@@ -139,7 +179,8 @@ Invoke-ConvertApi -From pdf -To merge `
139179
- **2+ URLs** → multipart form with `Files[i]`
140180

141181
- `-Parameters` `[hashtable]`
142-
Additional API options (become query params or form fields, as appropriate).
182+
Additional API options (become query params or form fields).
183+
**Special rule:** keys that end with **`File`** and point to a local path are uploaded as **file parts**; URL strings remain as string fields.
143184

144185
- `-StoreFile` `[switch]`
145186
Adds `StoreFile=true` so the API returns downloadable URLs.
@@ -165,8 +206,22 @@ Invoke-ConvertApi -From pdf -To merge `
165206
```
166207
Token portal: https://www.convertapi.com/a/authentication
167208

168-
- **“Input not found”**
169-
Verify paths or use full paths. On merges, any missing file will halt the request.
209+
- **Execution policy / blocked scripts**
210+
Not an issue when installing via **PowerShell Gallery** or **git clone**.
211+
Only needed for ZIP downloads from the browser:
212+
```powershell
213+
Set-ExecutionPolicy -Scope Process Bypass -Force
214+
Unblock-File -Path '<repo>\*' -Recurse
215+
```
216+
217+
- **AllSigned environments**
218+
Your org may require Authenticode‑signed scripts. Sign the module or ask your admin to trust your code‑signing certificate.
219+
220+
- **Launching a new process with multiple `-File` values**
221+
Repeat the flag:
222+
```powershell
223+
pwsh -NoProfile -File .\examples\Convert-PdfToMerge.ps1 -File .\a.pdf -File .\b.pdf -OutDir .\out
224+
```
170225

171226
- **Filename collisions**
172227
If a target file exists and `-Overwrite` is not set, the module appends a random suffix.
@@ -180,18 +235,21 @@ Invoke-ConvertApi -From pdf -To merge `
180235

181236
Choose a license appropriate for your distribution (e.g., MIT).
182237

183-
184238
---
185239

186240
## Examples
187241

188-
- `examples/Merge-Pdf.ps1` – Merge multiple PDFs (local files and/or URLs).
242+
- `examples/Convert-PdfToMerge.ps1` – Merge multiple PDFs (local files and/or URLs).
189243
- `examples/Convert-DocxToPdf.ps1` – Batch DOCX → PDF for a folder.
244+
- `examples/Watermark-Overlay.ps1` – Apply a PDF overlay using `OverlayFile`.
190245

191246
Run with:
192247
```powershell
193-
pwsh examples/Merge-Pdf.ps1 -File .\a.pdf,.\b.pdf -OutDir .\out -StoreFile
194-
pwsh examples/Convert-DocxToPdf.ps1 -InDir .\docs -OutDir .\out -Recurse
248+
# PowerShell 7
249+
pwsh .\examples\Convert-PdfToMerge.ps1 -File .\a.pdf,.\b.pdf -OutDir .\out -StoreFile
250+
251+
# Windows PowerShell 5.1
252+
powershell -File .\examples\Convert-DocxToPdf.ps1 -InDir .\docs -OutDir .\out -Recurse
195253
```
196254

197255
---

0 commit comments

Comments
 (0)