Skip to content
Open
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
54 changes: 37 additions & 17 deletions Document-Processing/Web-apis/consume-apis/compress-pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To compress a PDF document, send a request to the /v1/edit-pdf/compress endpoint
{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/edit-pdf/compress' \
--form 'file=@"4mb.pdf"' \
--form 'file=@"Input.pdf"' \
--form 'settings="{
\"File\": \"file\",
\"Password\": null,
Expand All @@ -36,15 +36,27 @@ curl --location 'http://localhost:8003/v1/edit-pdf/compress' \

const formdata = new FormData();
formdata.append("file", fileInput.files[0], "4mb.pdf");
formdata.append("settings", "{\n \"File\": \"file\",\n \"Password\": null,\n \"ImageQuality\": 50,\n \"OptimizeFont\": true,\n \"RemoveMetadata\": false,\n \"OptimizePageContents\": true,\n \"FlattenFormFields\": true,\n \"FlattenAnnotations\": true\n}");
formdata.append(
"settings",
JSON.stringify({
File: "file",
Password: null,
ImageQuality: 50,
OptimizeFont: true,
RemoveMetadata: false,
OptimizePageContents: true,
FlattenFormFields: true,
FlattenAnnotations: true
})
);

const requestOptions = {
method: "POST",
body: formdata,
redirect: "follow"
};

fetch("http://localhost:4000/v1/edit-pdf/compress", requestOptions)
fetch("http://localhost:8003/v1/edit-pdf/compress", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand All @@ -56,19 +68,26 @@ fetch("http://localhost:4000/v1/edit-pdf/compress", requestOptions)
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:8003/v1/edit-pdf/compress");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("4mb.pdf")), "file", "4mb.pdf");
content.Add(new StringContent("{
\"File\": \"file\",
\"Password\": null,
\"ImageQuality\": 50,
\"OptimizeFont\": true,
\"RemoveMetadata\": false,
\"OptimizePageContents\": true,
\"FlattenFormFields\": true,
\"FlattenAnnotations\": true
}"), "settings");
content.Add(new StreamContent(File.OpenRead("Sample.pdf")), "file1", "Sample.pdf");

var settings = new
{
File = "file",
Password = (string?)null,
ImageQuality = 50,
OptimizeFont = true,
RemoveMetadata = false,
OptimizePageContents = true,
FlattenFormFields = true,
FlattenAnnotations = true
};

var json = JsonSerializer.Serialize(settings);
var settingsContent = new StringContent(json, Encoding.UTF8, "application/json");
content.Add(settingsContent, "settings");
request.Content = content;
var response = await client.SendAsync(request);

using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Expand All @@ -94,7 +113,8 @@ Next, you can retrieve the job status by sending a request to the /v1/edit-pdf/s

{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/conversion/status/ef0766ab-bc74-456c-8143-782e730a89df'
curl --location 'http://localhost:8003/v1/conversion/status/9b131bfe-d4eb-4f1d-b946-46443a363eb5' \
--output Output.pdf

{% endhighlight %}

Expand All @@ -104,7 +124,7 @@ const requestOptions = {
method: "GET",
redirect: "follow"
};
fetch("http://localhost:4000/v1/edit-pdf/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
fetch("http://localhost:8003/v1/edit-pdf/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand Down
73 changes: 38 additions & 35 deletions Document-Processing/Web-apis/consume-apis/delete-pdf-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,40 @@ To delete PDF pages, send a request to the /v1/edit-pdf/delete-pages endpoint wi
{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/edit-pdf/delete-pages' \
--form 'file=@"merge/example.pdf"' \
--form 'settings="{
\"RotationAngle\": \"90\",
\"File\": \"file\",
\"Password\": null,
\"PageRanges\": [
--form 'file=@"Input.pdf"' \
--form 'settings={
"File": "file",
"Password": null,
"PageRanges": [
{
\"Start\": 1,
\"End\": 5
},
{
\"Start\": 6,
\"End\": 10
}
]
}"'
"Start": 1,
"End": 2
}]
}'

{% endhighlight %}

{% highlight javaScript tabtitle="JavaScript" %}

const formdata = new FormData();
formdata.append("file", fileInput.files[0], "merge/example.pdf");
formdata.append("settings", "{\n \"RotationAngle\": \"90\",\n \"File\": \"file\",\n \"Password\": null,\n \"PageRanges\": [\n {\n \"Start\": 1,\n \"End\": 5\n },\n {\n \"Start\": 6,\n \"End\": 10\n }\n ]\n}");
formdata.append("file", fileInput.files[0], "Input.pdf");
formdata.append(
"settings",
JSON.stringify({
File: "file",
Password: null,
PageRanges: [
{ Start: 1, End: 2 } ]
})
);

const requestOptions = {
method: "POST",
body: formdata,
redirect: "follow"
};

fetch("http://localhost:4000/v1/edit-pdf/delete-pages", requestOptions)
fetch("http://localhost:8003/v1/edit-pdf/delete-pages", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand All @@ -61,24 +63,24 @@ fetch("http://localhost:4000/v1/edit-pdf/delete-pages", requestOptions)
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:8003/v1/edit-pdf/delete-pages");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("merge/example.pdf")), "file", "merge/example.pdf");
content.Add(new StringContent("{
\"RotationAngle\": \"90\",
\"File\": \"file\",
\"Password\": null,
\"PageRanges\": [
{
\"Start\": 1,
\"End\": 5
},
content.Add(new StreamContent(File.OpenRead("Input.pdf")), "file1", "Input.pdf");

var settings = new
{
File = "file",
Password = (string?)null,
PageRanges = new[]
{
\"Start\": 6,
\"End\": 10
(Start: 1, End: 2)
}
]
}"), "settings");
};

var json = JsonSerializer.Serialize(settings);
var settingsContent = new StringContent(json, Encoding.UTF8, "application/json");
content.Add(settingsContent, "settings");
request.Content = content;
var response = await client.SendAsync(request);

using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Expand All @@ -104,7 +106,8 @@ Next, you can retrieve the job status by sending a request to the /v1/edit-pdf/s

{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/conversion/status/ef0766ab-bc74-456c-8143-782e730a89df' \
curl --location 'http://localhost:8003/v1/conversion/status/9b131bfe-d4eb-4f1d-b946-46443a363eb5' \
--output Output.pdf

{% endhighlight %}

Expand All @@ -115,7 +118,7 @@ const requestOptions = {
redirect: "follow"
};

fetch("http://localhost:4000/v1/edit-pdf/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
fetch("http://localhost:8003/v1/edit-pdf/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand Down
30 changes: 19 additions & 11 deletions Document-Processing/Web-apis/consume-apis/excel-to-pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,35 @@ To convert an Excel document to PDF, send a request to the /v1/conversion/excel-
{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/conversion/excel-to-pdf' \
--form 'file=@"ExpenseReport.xlsx"' \
--form 'settings="{
\"File\": \"file\",
\"Password\": null,
\"PdfComplaince\": \"PDF/A-1B\"
}"'
--form 'file=@"Sample.xlsx"' \
--form 'settings={
"File": "file",
"Password": null,
"PdfCompliance": "PDF/A-1B"
}'

{% endhighlight %}

{% highlight javaScript tabtitle="JavaScript" %}

const formdata = new FormData();
formdata.append("file", fileInput.files[0], "ExpenseReport.xlsx");
formdata.append("settings", "{\n \"File\": \"file\",\n \"Password\": null,\n \"PdfComplaince\": \"PDF/A-1B\"\n}");
formdata.append("file", fileInput.files[0], "Input.xlsx");
formdata.append(
"settings",
JSON.stringify({
File: "file",
Password: null,
PdfCompliance: "PDF/A-1B",
})
);

const requestOptions = {
method: "POST",
body: formdata,
redirect: "follow"
};

fetch("http://localhost:4000/v1/conversion/excel-to-pdf", requestOptions)
fetch("http://localhost:8003/v1/conversion/excel-to-pdf", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand Down Expand Up @@ -83,7 +90,8 @@ Next, you can retrieve the job status by sending a request to the /v1/conversion

{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/conversion/status/ef0766ab-bc74-456c-8143-782e730a89df' \
curl --location 'http://localhost:8003/v1/conversion/status/7d0b62cd-c5a1-4035-9728-50c4efd1f0e1' \
--output Output.pdf

{% endhighlight %}

Expand All @@ -94,7 +102,7 @@ const requestOptions = {
redirect: "follow"
};

fetch("http://localhost:4000/v1/conversion/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
fetch("http://localhost:8003/v1/conversion/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand Down
53 changes: 35 additions & 18 deletions Document-Processing/Web-apis/consume-apis/flatten-pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,37 @@ To flatten a PDF document, send a request to the /v1/edit-pdf/flatten endpoint w
{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/edit-pdf/flatten' \
--form 'file=@"Form.pdf"' \
--form 'settings="{
\"File\": \"file\",
\"Password\": null,
\"FlattenFormFields\": true,
\"FlattenAnnotations\": true
}"'
--form 'file=@Input.pdf' \
--form 'settings={
"File": "file",
"Password": null,
"FlattenFormFields": true,
"FlattenAnnotations": true
}'

{% endhighlight %}

{% highlight javaScript tabtitle="JavaScript" %}

const formdata = new FormData();
formdata.append("file", fileInput.files[0], "Form.pdf");
formdata.append("settings", "{\n \"File\": \"file\",\n \"Password\": null,\n \"FlattenFormFields\": true,\n \"FlattenAnnotations\": true\n}");
formdata.append(
"settings",
JSON.stringify({
File: "file",
Password: null,
FlattenFormFields: true,
FlattenAnnotations: true
})
);

const requestOptions = {
method: "POST",
body: formdata,
redirect: "follow"
};

fetch("http://localhost:4000/v1/edit-pdf/flatten", requestOptions)
fetch("http://localhost:8003/v1/edit-pdf/flatten", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand All @@ -52,14 +60,22 @@ fetch("http://localhost:4000/v1/edit-pdf/flatten", requestOptions)
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:8003/v1/edit-pdf/flatten");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("Form.pdf")), "file", "Form.pdf");
content.Add(new StringContent("{
\"File\": \"file\",
\"Password\": null,
\"FlattenFormFields\": true,
\"FlattenAnnotations\": true
}"), "settings");
content.Add(new StreamContent(File.OpenRead("Input.pdf")), "file1", "Input.pdf");

var settings = new
{
File = "file",
Password = (string?)null,
FlattenFormFields = true,
FlattenAnnotations = true
};

var json = JsonSerializer.Serialize(settings);
var settingsContent = new StringContent(json, Encoding.UTF8, "application/json");
// When sending JSON as a field inside multipart, you can still name the part:
content.Add(settingsContent, "settings");
request.Content = content;

var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Expand All @@ -86,7 +102,8 @@ Next, you can retrieve the job status by sending a request to the /v1/edit-pdf/s

{% highlight c# tabtitle="Curl" %}

curl --location 'http://localhost:8003/v1/conversion/status/ef0766ab-bc74-456c-8143-782e730a89df' \
curl --location 'http://localhost:8003/v1/conversion/status/f58c9739-622e-41d4-9dd2-57a901dc13c3' \
--output Output.pdf
--header 'Authorization: Bearer {{Placeholder for token}}'

{% endhighlight %}
Expand All @@ -98,7 +115,7 @@ const requestOptions = {
redirect: "follow"
};

fetch("http://localhost:4000/v1/edit-pdf/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
fetch("http://localhost:8003/v1/edit-pdf/status/4413bbb5-6b26-4c07-9af2-c26cd2c42fe3", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
Expand Down
Loading