Hello, I would like to know if with the PDF SDK I can replace text with links, or links with other links, in an existing PDF document.
Thanks
Jaber
Hello, I would like to know if with the PDF SDK I can replace text with links, or links with other links, in an existing PDF document.
Thanks
Jaber
@jaber.it
Thank you for contacting Aspose Support.
At present, there is no Aspose.PDF REST API that let you replace text with link or link with another link. We have logged the request PDFCLOUD-425 for the implementation of this API and will update you here once the API is implemented.
Please use POST /pdf/{name}/text/replace API if you just want to replace text in an existing PDF File.
Please install aspose/pdf-sdk-php package using following command:
composer require aspose/pdf-sdk-php
and use following example to replace text in a PDF file:
<?php
require_once realpath(__DIR__ . '/..') . '/vendor/autoload.php';
use Aspose\PDF\Api\PdfApi;
use Aspose\PDF\Configuration;
class Text {
protected $pdfApi;
protected $config;
public function __construct() {
// Get App key and App SID from https://cloud.aspose.com
$appSid = 'xxxxxxxxxx';
$appKey = 'xxxxxxxxxx';
$host = 'https://api.aspose.cloud/v1.1';
$this->config = new Configuration();
$this->config->setAppKey($appKey);
$this->config->setAppSid($appSid);
$this->config->setHost($host);
$this->pdfApi = new PdfApi(null, $this->config);
}
private function uploadFile($fileName, $subFolder = null) {
$file = realpath(__DIR__ . '/..') . '/Data/' . $fileName;
$result = $this->pdfApi->PutCreate($Path=$fileName, $file);
}
public function postDocumentReplaceText() {
$name = 'Sample.pdf';
$this->uploadFile($name);
$textReplaceRequest = new Aspose\PDF\Model\TextReplaceRequest();
$textReplaceRequest->setOldValue('brown');
$textReplaceRequest->setNewValue('b_r_o_w_n');
$textReplaceRequest->setRegex(false);
$response = $this->pdfApi->postDocumentReplaceText($name, $textReplaceRequest, $storage = null, $folder = null);
}
}
$text = new Text();
$text->postDocumentReplaceText();
?>
Input Document: Sample.pdf (360.7 KB)
Output Document: Sample_Out.pdf (413.7 KB)
Hi.
Currently in this page,
I see that there is op which allows to replace text or links.
Cant we use that to get this done? Buying SDK is a huge cost and cloud/credit based is quite easy for me. Kindly Advice on this.
As mentioned above, we are providing REST API to replace text in a PDF file. Please spare us some time for the implementation of REST API that let you replace a link with another link or text in a PDF file. After an initial analysis, we will share with you the approximate time we are going to take for the implementation of the requested API.
Thanks, I’m also interested to that ASAP. à bien tot
ok, thanks —
We are working on the API and it is going to be ready by 30th August. But SDKs will support this feature in the first half of September. By then you may use cURL or Postman to directly call the API methods.
Thank you.
The REST API for links replacement will be available by next week. We would like to know which Platform SDK are you using to call Aspose.PDF APIs so that we update it first with the new API.
Our Cloud SDKs are available at following GitHub account:
hello we would like to use the REST api interface rather than the SDK because the first solution is more affordable. We want to replace links within the pdf document through it. Would it be possible now ? thanks
(the platform we use is currently php / javascript, in the future could be node, but the API should be agnostic of that, right?)
hello we would like to use the REST api interface rather than the SDK because the first solution is more affordable.
Cloud SDKs are free. Aspose REST APIs are only charged based on this Pricing policy.
We want to replace links within the pdf document through it. Would it be possible now?
Yes, and the API will be live this week.
(the platform we use is currently php / javascript, in the future could be node, but the API should be agnostic of that, right?)
Yes, REST APIs are independent of the platform.
As an update, the latest Aspose.PDF Cloud API supports working with links in the PDF document. Please check the available APIs for this purpose. Please feel free to contact us with any questions/suggestions.