Php Tutorial: Match and replace the text in the PDF

Source: Internet
Author: User
First of all, we need to use a very popular online PDF tool-saaspose: Speaking of its popularity, that's because saaspose currently supports GoogleAppEngine, GoogleAndroid, Facebook, Java, AmazonWebServices, and Node. js, PHP, Python, iOSDeveloper, Rails, and Micr

First of all, we need to use a very popular online PDF tool-saaspose: Speaking of its popularity, that's because saaspose currently supports Google App Engine, Google Android, Facebook, Java, Amazon Web Services, and Node. js, PHP, Python, iOS Developer, Rails, and Micr

First of all, we need to use a very popular online PDF tool-saaspose: Speaking of its popularity, that's because saaspose currently supports Google App Engine, Google Android, Facebook, Java, Amazon Web Services, and Node. js, PHP, Python, iOS Developer, Rails, Microsoft. NET, Microsoft Azure, Sinatra, and SalesForce. Is it swollen enough? Saaspose: saaspose is an online tool for document creation and conversion. Currently, the supported documents and formats include DOC, docx, HTML, XLS, XLSX, and PPT, PPTX, PDF, EML, MSG, RTF, ODT, TXT, XPS, EPUB, PNG, JPG, TIFF, CSV, MHT, Barcodes, and OCR. There is a lot of nonsense. Next, let's go directly to the Tutorial:

$ FilePath? =? Getcwd ()?.? "\ Input \ myfilepath"; // obtain the path of the PDF file under the working directory ?? $ FileName = basename ($ filePath); // obtain the file name: myfilepath ?? $ OldText = "www.itluren.com ";?? $ NewText? =? "Itluren.com ";?? $ AppSID? =? "77 ***************"; // APPSID? Need to be obtained after registration ?? $ AppKey? =? "89 *************"; // the retrieval path is the same as APPSID ?? // Create a common resource identifier ?? Echo? "Uploading? Pdf? File ...? ";?? $ StrURIRequest? =?" http://api.saaspose.com/v1.0 "?.? "/Storage/file /"?.? $ FileName ;?? $ SignedURI? =? Sign ($ strURIRequest );?? UploadFileBinary ($ signedURI ,? $ FilePath );? ?? Echo? "The PDF file has been successfully uploaded to the server ";?? Echo? "Replacing text ...";?? // JSON data submission ?? $ FieldsArray = array ('oldvalue '=> $ oldText ,? 'Newvalue' => $ newText ,? 'Regex' => "false ");?? $ Json = json_encode ($ fieldsArray); // convert the array to Json ?? // Create a new generic Resource Identifier to replace text ?? $ StrURI? =?" http://api.saaspose.com/v1.0 "?.? "/Pdf /"?.? $ FileName ?.? "/ReplaceText ";?? $ SignedURI? =? Sign ($ strURI );?? $ ResponseStream? =? ProcessCommand ($ signedURI ,? "POST ",? "Json ",? $ Json );?? $ V_output? =? ValidateOutput ($ responseStream );?? If? ($ V_output = ""){?? // Save the PDF ?? $ StrURI? =?" http://api.saaspose.com/v1.0 "?.? "/Storage/file /"?.? $ FileName ;?? // Sign? URI ?? $ SignedURI? =? Sign ($ strURI );?? $ ResponseStream? =? ProcessCommand ($ signedURI ,? "GET ",? "",? "");?? $ OutputPath? =? Getcwd ()?.? "\ Output \\"?.? $ FileName ;? SaveFile ($ responseStream ,? $ OutputPath );? Echo? "The text has been replaced. The new PDF address is :? "?.? $ OutputPath ;??} Else {?? Return? $ V_output ;??}??

You can try online creation or conversion between other formats.

Statement: This article uses BY-NC-SA protocol for authorization | IT passers-
Reprinted please note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.