diff --git a/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/sample.html b/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/sample.html new file mode 100644 index 00000000..9f965a72 --- /dev/null +++ b/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/sample.html @@ -0,0 +1,29 @@ + + +
+ +Error uploading file: " . $result . "
"; + } + } + } else { + echo "Status code: " . $status_code . "
"; + echo "Error retrieving presigned URL: " . $result . "
"; + } + + curl_close($curl); +} else { + echo "Error: " . curl_error($curl); +} + +function SplitPdf($apiKey, $fileUrl, $splitText) { + $url = "https://api.pdf.co/v1/pdf/split2"; + + $parameters = array( + "name" => "split.pdf", + "url" => $fileUrl, + "searchString" => $splitText, + "async" => true // Asynchronous mode + ); + + $data = json_encode($parameters); + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_HTTPHEADER, array("x-api-key: " . $apiKey, "Content-type: application/json")); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + + $result = curl_exec($curl); + + if (curl_errno($curl) == 0) { + $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($status_code == 200) { + $json = json_decode($result, true); + + if (!isset($json["error"]) || $json["error"] == false) { + $jobId = $json["jobId"]; + CheckJobStatus($jobId, $apiKey); + } else { + echo "Error: " . $json["message"] . "
"; + } + } else { + echo "Status code: " . $status_code . "
"; + echo "Error splitting PDF: " . $result . "
"; + } + } else { + echo "Error: " . curl_error($curl); + } + + curl_close($curl); +} + +function CheckJobStatus($jobId, $apiKey) { + $url = "https://api.pdf.co/v1/job/check"; + + do { + $parameters = array("jobid" => $jobId); + $data = json_encode($parameters); + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_HTTPHEADER, array("x-api-key: " . $apiKey, "Content-type: application/json")); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + + $result = curl_exec($curl); + + if (curl_errno($curl) == 0) { + $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($status_code == 200) { + $json = json_decode($result, true); + + if (!isset($json["error"]) || $json["error"] == false) { + $status = $json["status"]; + + if ($status == "success") { + // Handle JSON file with URLs + $resultFileUrl = $json["url"]; // This is the JSON file containing URLs + $jsonFileContents = file_get_contents($resultFileUrl); + + if ($jsonFileContents) { + $splitFiles = json_decode($jsonFileContents, true); + + echo "Part " . ($index + 1) . ": " . htmlspecialchars($pdfUrl) . "
"; + } + } else { + echo "Error: Invalid JSON structure in the result file.
"; + } + } else { + echo "Error: Unable to fetch the result JSON file.
"; + } + break; + } elseif ($status == "working") { + sleep(3); // Wait and retry + } else { + echo "Job status: " . htmlspecialchars($status) . "
"; + break; + } + } else { + echo "Error: " . htmlspecialchars($json["message"]) . "
"; + break; + } + } else { + echo "Status code: " . $status_code . "
"; + echo "Error checking job status: " . htmlspecialchars($result) . "
"; + break; + } + } else { + echo "Error: " . curl_error($curl); + break; + } + + curl_close($curl); + } while (true); +} + +?> + + + + \ No newline at end of file diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.gitignore b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.gitignore new file mode 100644 index 00000000..5ff6309b --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/.gitignore b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/encodings.xml b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/encodings.xml new file mode 100644 index 00000000..aa00ffab --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/encodings.xml @@ -0,0 +1,7 @@ + +