Revision: 66455
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 8, 2014 16:25 by johansonkatherine
Initial Code
use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Common\Product;
AsposeApp::$appSID = "77******-1***-4***-a***-80**********";
AsposeApp::$appKey = "********************************";
$filePath = getcwd() . "/Input/test.pdf";
$fileName = basename($filePath);
$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
$fieldsArray = array('TextReplaces'=>array(array('OldValue'=>$oldText1, 'NewValue'=>$newText1, 'Regex'=>'false'),
array('OldValue'=>$oldText2, 'NewValue'=>$newText2, 'Regex'=>'false'),
array('OldValue'=>$oldText3, 'NewValue'=>$newText3, 'Regex'=>'false')));
$json = json_encode($fieldsArray);
//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", "", "");
$outputPath = getcwd() . "/output/" . $fileName;
Utils::saveFile($responseStream, $outputPath);
echo "The text has been replaced and Pdf file has saved at: " . $outputPath;
Initial URL
http://www.aspose.com/docs/display/pdfcloud/Replace+Multiple+Texts+in+a+PDF
Initial Description
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.
Initial Title
PHP Code Sample to Replace Multiple Text in PDF File Using Cloud API
Initial Tags
php, replace, text, api, c#
Initial Language
PHP