These VB.NET samples demonstrate how to call pdfRest APIs using HttpClient. A single console project (VBNetSamples.vbproj) acts as a dispatcher so you can run any sample with a simple command.
- .NET SDK 8.0 or newer (check with
dotnet --version). - A pdfRest API key.
- Internet access to reach
https://api.pdfrest.com(or the EU endpoint below).
- From this
VB.NET/folder, copy the environment template and set your API key:
cp .env.example .env- Edit
.envand setPDFREST_API_KEY=your_api_key_here
- Optional: EU/GDPR endpoint for European data residency and performance:
- In
.env, setPDFREST_URL=https://eu-api.pdfrest.com - More info: https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
- Restore and build the project (from this folder):
dotnet restoredotnet build
- Run a sample (examples below). The dispatcher pattern is:
dotnet run -- <command> [args]
VBNetSamples.vbproj: single console app that compiles all VB samples in this folder.Program.vb: a small dispatcher that routes<command>to a specific sample’sExecutemethod.Endpoint Examples/JSON Payload/: two‑step samples (upload, then operate with a JSON body).Endpoint Examples/Multipart Payload/: single multipart/form-data request per operation.Complex Flow Examples/: multi-step workflows combining endpoints..env: holds configuration (PDFREST_API_KEY, optionalPDFREST_URL). Loaded automatically via DotNetEnv.
JSON two‑step (upload → operate via JSON):
markdown— Convert PDF to Markdown- Run:
dotnet run -- markdown /path/to/input.pdf
- Run:
rasterized-pdf— Rasterize a PDF- Run:
dotnet run -- rasterized-pdf /path/to/input.pdf
- Run:
Multipart single request (send file directly):
markdown-multipart— Convert PDF to Markdown- Run:
dotnet run -- markdown-multipart /path/to/input.pdf
- Run:
rasterized-pdf-multipart— Rasterize a PDF- Run:
dotnet run -- rasterized-pdf-multipart /path/to/input.pdf
- Run:
Complex flow:
merge-different-file-types— Merge multiple inputs (PDFs and non‑PDFs)- Run:
dotnet run -- merge-different-file-types file1.pdf file2.docx image.png
- Run:
- Successful calls print the API’s JSON response to stdout.
- Failures write a concise message to stderr and exit with a non‑zero code.
- Tip: redirect output to a file, e.g.,
... > response.json.
- Missing API key:
- Ensure
.envexists withPDFREST_API_KEYset, or export it in your shell before running.
- Ensure
- EU endpoint:
- If using the EU endpoint, verify
PDFREST_URL=https://eu-api.pdfrest.comin.env.
- If using the EU endpoint, verify
- .NET version:
- Check with
dotnet --version. Use .NET 8.0 or newer.
- Check with
- Clean build:
rm -rf bin obj && dotnet build
- Proxy environments:
- If your network requires a proxy, set standard environment variables like
HTTPS_PROXY.
- If your network requires a proxy, set standard environment variables like
- These are focused samples to help you evaluate pdfRest quickly.
- Do not commit secrets. Keep
.envout of version control. - For more APIs, options, and regions, see the pdfRest documentation and pricing page.