Skip to content

Commit

Permalink
Merge pull request #44 from datalogics-tsmith/rename-extract
Browse files Browse the repository at this point in the history
Rename extract-text samples to extractED-text
  • Loading branch information
datalogics-jacksonm authored Oct 12, 2023
2 parents c623bf6 + 2c63036 commit b996802
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using (var httpClient = new HttpClient { BaseAddress = new Uri("https://api.pdfrest.com") })
{
using (var request = new HttpRequestMessage(HttpMethod.Post, "extract-text"))
using (var request = new HttpRequestMessage(HttpMethod.Post, "extracted-text"))
{
request.Headers.TryAddWithoutValidation("Api-Key", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
request.Headers.Accept.Add(new("application/json"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import okhttp3.Response;
import org.json.JSONObject;

public class ExtractText {
public class ExtractedText {

// Specify the path to your file here, or as the first argument when running the program.
private static final String DEFAULT_FILE_PATH = "/path/to/file.pdf";
Expand Down Expand Up @@ -38,7 +38,7 @@ public static void main(String[] args) {
Request request =
new Request.Builder()
.header("Api-Key", dotenv.get("PDFREST_API_KEY", DEFAULT_API_KEY))
.url("https://api.pdfrest.com/extract-text")
.url("https://api.pdfrest.com/extracted-text")
.post(requestBody)
.build();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data.append("file", fs.createReadStream("/path/to/file"));
var config = {
method: "post",
maxBodyLength: Infinity, // set maximum length of the request body
url: "https://api.pdfrest.com/extract-text",
url: "https://api.pdfrest.com/extracted-text",
headers: {
"Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key
...data.getHeaders(), // set headers for the request
Expand All @@ -27,5 +27,3 @@ axios(config)
.catch(function (error) {
console.log(error);
});

// If you would like to download the file instead of getting the JSON response, please see the 'get-resource-id-endpoint.js' sample.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
]
];

$request = new Request('POST', 'https://api.pdfrest.com/extract-text', $headers); // Create a new HTTP POST request with the API endpoint and headers.
$request = new Request('POST', 'https://api.pdfrest.com/extracted-text', $headers); // Create a new HTTP POST request with the API endpoint and headers.

$res = $client->sendAsync($request, $options)->wait(); // Send the asynchronous request and wait for the response.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
import requests
import json

extract_text_endpoint_url = 'https://api.pdfrest.com/extract-text'
extract_text_endpoint_url = 'https://api.pdfrest.com/extracted-text'

# The /extract-text endpoint can take a single PDF file or id as input.
#This sample demonstrates querying the title, page count, document language and author
# The /extracted-text endpoint can take a single PDF file or id as input.
#This sample demonstrates extracting the text from a document to return as JSON
mp_encoder_extractText = MultipartEncoder(
fields={
'file': ('file_name', open('/path/to/file', 'rb'), 'application/pdf'),
}
)

# Let's set the headers that the extract-text endpoint expects.
# Let's set the headers that the extracted-text endpoint expects.
# Since MultipartEncoder is used, the 'Content-Type' header gets set to 'multipart/form-data' via the content_type attribute below.
headers = {
'Accept': 'application/json',
'Content-Type': mp_encoder_extractText.content_type,
'Api-Key': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # place your api key here
}

print("Sending POST request to extract-text endpoint...")
print("Sending POST request to extracted-text endpoint...")
response = requests.post(extract_text_endpoint_url, data=mp_encoder_extractText, headers=headers)

print("Response status code: " + str(response.status_code))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
curl -X POST "https://api.pdfrest.com/extract-text" \
curl -X POST "https://api.pdfrest.com/extracted-text" \
-H "Accept: application/json" \
-H "Content-Type: multipart/form-data" \
-H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
-F "file=@/path/to/file"
-F "file=@/path/to/file"

0 comments on commit b996802

Please sign in to comment.