/ Published in: PHP
The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
use Aspose\Cloud\Common\AsposeApp; use Aspose\Cloud\Common\Utils; use Aspose\Cloud\Common\Product; AsposeApp::$appSID = "77******-1***-4***-a***-80**********"; AsposeApp::$appKey = "********************************"; $oldText1 = "[!firm!]"; $newText1 = "Aspose"; $oldText2 = "[!client!]"; $newText2 = "Mark"; $oldText3 = "[!transaction_date!]"; $newText3 = "01-01-2014"; //build URI echo "Uploading pdf file... <br/>"; $strURIRequest = "http://api.aspose.com/v1.1/storage/file/" . $fileName; $signedURI = Utils::sign($strURIRequest); echoUtils::uploadFileBinary($signedURI, $filePath); echo "Pdf file has been uploaded successully<br/>"; echo "Replacing text...<br/>"; //Build JSON to post //Build URI to replace text $strURI = "http://api.aspose.com/v1.1/pdf/" . $fileName . "/replaceTextList"; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, "POST", "json", $json); //Save PDF file on server //build URI $strURI = "http://api.aspose.com/v1.1/storage/file/" . $fileName; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, "GET", "", ""); Utils::saveFile($responseStream, $outputPath); echo "The text has been replaced and Pdf file has saved at: " . $outputPath;
URL: http://www.aspose.com/docs/display/pdfcloud/Replace+Multiple+Texts+in+a+PDF