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 @@ + + + + + PDF Splitting Cloud API Example + + + + +
+

+ +
+ +

+

+ + + +

+

+ + +

+ +
+ + + \ No newline at end of file diff --git a/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/sample.pdf b/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/sample.pdf new file mode 100644 index 00000000..69ba80e4 Binary files /dev/null and b/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/sample.pdf differ diff --git a/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/split-pdf-async.php b/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/split-pdf-async.php new file mode 100644 index 00000000..338f698c --- /dev/null +++ b/PDF Splitting API/PHP/Split PDF By Text From Uploaded File Asynchronously/split-pdf-async.php @@ -0,0 +1,188 @@ + + + + + PDF Splitting Results + + + + +Status code: " . $status_code . "

"; + echo "

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 "

Split PDF Results:

"; + if (is_array($splitFiles)) { + foreach ($splitFiles as $index => $pdfUrl) { + 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 @@ + + + + + + + \ No newline at end of file diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/misc.xml b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/misc.xml new file mode 100644 index 00000000..463551f3 --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/pom.xml b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/pom.xml new file mode 100644 index 00000000..6e69e4cb --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + org.example + Henry-Test1 + 1.0-SNAPSHOT + + + + com.google.code.gson + gson + 2.8.6 + + + + com.squareup.okhttp3 + okhttp + 4.9.1 + + + + Archetype - Henry-Test1 + http://maven.apache.org + diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/META-INF/maven/archetype.xml b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 00000000..0745621f --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,9 @@ + + Henry-Test1 + + src/main/java/App.java + + + src/test/java/AppTest.java + + diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/pom.xml b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000..132275ef --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + $org.example + $Henry-Test1 + $1.0-SNAPSHOT + + + junit + junit + 3.8.1 + test + + + diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/src/main/java/App.java b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/src/main/java/App.java new file mode 100644 index 00000000..1fa6a956 --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/src/main/java/App.java @@ -0,0 +1,13 @@ +package $org.example; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/src/test/java/AppTest.java b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/src/test/java/AppTest.java new file mode 100644 index 00000000..65be417e --- /dev/null +++ b/PDF To CSV API/Java/Convert PDF to CSV From URL Asynchronously/src/main/resources/archetype-resources/src/test/java/AppTest.java @@ -0,0 +1,38 @@ +package $org.example; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}