Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion DotNET/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ PDFREST_API_KEY=your_api_key_here
# - Default (US): https://api.pdfrest.com
# - EU/GDPR region: https://eu-api.pdfrest.com
PDFREST_URL=https://api.pdfrest.com
# For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
# For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work

# Optional: Immediate deletion of sensitive files
# - Default behavior: files are retained per the File Retention Period.
# - Set to true to immediately delete uploaded/generated files in samples that support it.
# Valid values: true|false (case-insensitive)
PDFREST_DELETE_SENSITIVE_FILES=false
2 changes: 1 addition & 1 deletion DotNET/Complex Flow Examples/ocr-with-extract-text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static async Task Execute(string[] args)
Console.WriteLine("OCR response received.");
Console.WriteLine(ocrResult);
var ocrJson = JObject.Parse(ocrResult);
var ocrPDFID = (string?) (ocrJson["outputId"] ?? ocrJson["id"] ?? ocrJson["files"]?[0]? ["id"]);
var ocrPDFID = (string?)(ocrJson["outputId"] ?? ocrJson["id"] ?? ocrJson["files"]?[0]?["id"]);
if (string.IsNullOrWhiteSpace(ocrPDFID))
{
Console.Error.WriteLine("Failed to obtain OCR output id. Full response:");
Expand Down
10 changes: 7 additions & 3 deletions DotNET/Endpoint Examples/JSON Payload/decrypted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ public static async Task Execute(string[] args)
// is involved, an explicit delete call can be made to the API.
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;

// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
6 changes: 3 additions & 3 deletions DotNET/Endpoint Examples/JSON Payload/delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
*
* Usage:
* dotnet run -- batch-delete <id1> [id2] [...]
* dotnet run -- delete <id1> [id2] [...]
*
* Output:
* - Prints JSON responses; non-2xx results exit non-zero.
Expand All @@ -20,13 +20,13 @@

namespace Samples.EndpointExamples.JsonPayload
{
public static class BatchDelete
public static class Delete
{
public static async Task Execute(string[] args)
{
if (args == null || args.Length < 1)
{
Console.Error.WriteLine("batch-delete requires <id1> [id2] [id3] ... OR a single comma-separated list");
Console.Error.WriteLine("delete requires <id1> [id2] [id3] ... OR a single comma-separated list");
Environment.Exit(1);
return;
}
Expand Down
8 changes: 6 additions & 2 deletions DotNET/Endpoint Examples/JSON Payload/encrypted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static async Task Execute(string[] args)
var redactedTextResult = await redactedTextResponse.Content.ReadAsStringAsync();
Console.WriteLine("Processing response received.");
Console.WriteLine(redactedTextResult);

JObject appliedResultJson = JObject.Parse(redactedTextResult);
var outputID = appliedResultJson["outputId"];

Expand All @@ -67,8 +67,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ public static async Task Execute(string[] args)
// IMPORTANT: Do not delete the previewId (the preview PDF) file until after the redaction is applied
// with the /pdf-with-redacted-text-applied endpoint.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
10 changes: 7 additions & 3 deletions DotNET/Endpoint Examples/JSON Payload/restricted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand All @@ -130,4 +134,4 @@ public static async Task Execute(string[] args)
}
}
}
}
}
10 changes: 7 additions & 3 deletions DotNET/Endpoint Examples/JSON Payload/unrestricted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand All @@ -126,4 +130,4 @@ public static async Task Execute(string[] args)
}
}
}
}
}
8 changes: 6 additions & 2 deletions DotNET/Endpoint Examples/JSON Payload/watermarked-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
8 changes: 6 additions & 2 deletions DotNET/Endpoint Examples/Multipart Payload/decrypted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
8 changes: 4 additions & 4 deletions DotNET/Endpoint Examples/Multipart Payload/delete.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* What this sample does:
* - Deletes multiple resources by ids.
* - Routed from Program.cs as: `dotnet run -- batch-delete-multipart <id1> [id2] [...]`.
* - Routed from Program.cs as: `dotnet run -- delete-multipart <id1> [id2] [...]`.
*
* Setup (environment):
* - Copy .env.example to .env
Expand All @@ -11,21 +11,21 @@
* For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
*
* Usage:
* dotnet run -- batch-delete-multipart id1 id2 id3
* dotnet run -- delete-multipart id1 id2 id3
*
* Output:
* - Prints the JSON response. Validation errors (args/env) exit non-zero.
*/

namespace Samples.EndpointExamples.MultipartPayload
{
public static class BatchDelete
public static class Delete
{
public static async Task Execute(string[] args)
{
if (args == null || args.Length < 1)
{
Console.Error.WriteLine("batch-delete-multipart requires <id1> [id2] [...]");
Console.Error.WriteLine("delete-multipart requires <id1> [id2] [...]");
Environment.Exit(1);
return;
}
Expand Down
8 changes: 6 additions & 2 deletions DotNET/Endpoint Examples/Multipart Payload/encrypted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
9 changes: 0 additions & 9 deletions DotNET/Endpoint Examples/Multipart Payload/get-resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ public static async Task Execute(string[] args)
var id = args[0];
var outPath = args.Length > 1 ? args[1] : "resource.bin";

var apiKey = Environment.GetEnvironmentVariable("PDFREST_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
Console.Error.WriteLine("Missing required environment variable: PDFREST_API_KEY");
Environment.Exit(1);
return;
}

var baseUrl = Environment.GetEnvironmentVariable("PDFREST_URL") ?? "https://api.pdfrest.com";
var resourceBase = baseUrl.TrimEnd('/') + "/resource/";

Expand All @@ -50,7 +42,6 @@ public static async Task Execute(string[] args)
{
using (var request = new HttpRequestMessage(HttpMethod.Get, id + "?format=file"))
{
request.Headers.TryAddWithoutValidation("Api-Key", apiKey);
using (var response = await httpClient.SendAsync(request))
{
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
8 changes: 6 additions & 2 deletions DotNET/Endpoint Examples/Multipart Payload/restricted-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
8 changes: 6 additions & 2 deletions DotNET/Endpoint Examples/Multipart Payload/watermarked-pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ public static async Task Execute(string[] args)
//
// Deletes all files in the workflow, including outputs. Save all desired files before enabling this step.

// Toggle deletion of sensitive files (default: false)
var deleteSensitiveFiles = false;
// Optional immediate deletion of sensitive files
// Default: false; override with PDFREST_DELETE_SENSITIVE_FILES=true
var deleteSensitiveFiles = string.Equals(
Environment.GetEnvironmentVariable("PDFREST_DELETE_SENSITIVE_FILES"),
"true",
StringComparison.OrdinalIgnoreCase);

if (deleteSensitiveFiles)
{
Expand Down
13 changes: 7 additions & 6 deletions DotNET/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void PrintUsage()
Console.Error.WriteLine(" upload <file> Upload file (resource id)");
Console.Error.WriteLine(" get-resource <id> [out] Download resource");
Console.Error.WriteLine(" delete-resource <id> Delete resource");
Console.Error.WriteLine(" batch-delete <id1> [id2] [...] Delete multiple resources");
Console.Error.WriteLine(" delete <id1> [id2] [...] Delete multiple resources");
Console.Error.WriteLine(" zip <file1> <file2> Zip two resources");
Console.Error.WriteLine(" unzip <zipFile> Unzip resource");
Console.Error.WriteLine(" signed-pdf <pdf> <pfx> <pass> <logo> Sign PDF with PFX");
Expand Down Expand Up @@ -101,7 +101,7 @@ static void PrintUsage()
Console.Error.WriteLine(" upload-multipart <file> Upload file (resource id)");
Console.Error.WriteLine(" get-resource-multipart <id> [out] Download resource");
Console.Error.WriteLine(" delete-resource-multipart <id> Delete resource");
Console.Error.WriteLine(" batch-delete-multipart <id1> [id2] [...] Delete multiple resources");
Console.Error.WriteLine(" delete-multipart <id1> [id2] [...] Delete multiple resources");
Console.Error.WriteLine(" zip-multipart <f1> <f2> Zip two files");
Console.Error.WriteLine(" unzip-multipart <zipFile> Unzip resource");
Console.Error.WriteLine(" signed-pdf-multipart <pdf> <pfx> <pass> <logo> Sign PDF with PFX");
Expand All @@ -121,6 +121,7 @@ static void PrintUsage()
Console.Error.WriteLine("Environment (.env supported):");
Console.Error.WriteLine(" PDFREST_API_KEY=... Required API key");
Console.Error.WriteLine(" PDFREST_URL=... Optional base URL (e.g., https://eu-api.pdfrest.com for EU/GDPR)");
Console.Error.WriteLine(" PDFREST_DELETE_SENSITIVE_FILES Optional immediate deletion (true|false; default false)\n");
}

// Entry point
Expand Down Expand Up @@ -258,11 +259,11 @@ static void PrintUsage()
case "delete-resource-multipart":
await Samples.EndpointExamples.MultipartPayload.DeleteResource.Execute(rest);
break;
case "batch-delete":
await Samples.EndpointExamples.JsonPayload.BatchDelete.Execute(rest);
case "delete":
await Samples.EndpointExamples.JsonPayload.Delete.Execute(rest);
break;
case "batch-delete-multipart":
await Samples.EndpointExamples.MultipartPayload.BatchDelete.Execute(rest);
case "delete-multipart":
await Samples.EndpointExamples.MultipartPayload.Delete.Execute(rest);
break;
case "png":
await Samples.EndpointExamples.JsonPayload.Png.Execute(rest);
Expand Down
Loading