Replace Multiple Text in PDF Document in Aspose.PDF Cloud Has Text Alignment Issue

Hi there,

I am replacing some text in my pdf, but there are a few issues

1. The text replaced is always left aligned
2. The text replaced has character space of 0

This is the original text I am replacing, (original text alignment is center)

This is the outcome

Here is the API call I am calling for text replacement

{
“TextReplaces”: [
{
“OldValue”: “TEXT1”,
“NewValue”: “Sania”,
“Regex”: true,
“TextState”: {
“HorizontalAlignment”: “center”,
“FontFile”: “BADABB__.TTF”
}
},{
“OldValue”: “TEXT2”,
“NewValue”: “Dan”,
“Regex”: true,
“TextState”: {
“HorizontalAlignment”: “Center”,
“FontFile”: “BADABB__.TTF”,
“CharacterSpacing”: 2.0
}
}
]
}

I need your urgent help for this

@asad.ali

@codewarior
image.png (40.8 KB)
image.png (42.5 KB)

@saniaaspose

Are you using Aspose.PDF Cloud API? Can you please share the sample code and files as well? We will test the scenario and address it accordingly.

Thank you so much for replying.

Yes I am using Aspose.PDF Cloud API,

This is what I am using for testing text replace call link

This is the body
{
“TextReplaces”: [
{
“OldValue”: “TEXT1”,
“NewValue”: “Sania”,
“Regex”: true,
“TextState”: {
“HorizontalAlignment”: “center”,
“FontFile”: “BADABB__.TTF”
}
},{
“OldValue”: “TEXT2”,
“NewValue”: “Dan”,
“Regex”: true,
“TextState”: {
“HorizontalAlignment”: “Center”,
“FontFile”: “BADABB__.TTF”,
“CharacterSpacing”: 2.0
}
}
]
}

The file used name “centre_font.pdf”
centre_font.pdf (645.7 KB)

Looking forward to a solution
centre_font.pdf (646 KB)

@saniaaspose

I tried to search and replace multiple text in PDF with the default font using the latest release of Aspose.PDF Cloud and was unable to notice the alignment and character spacing issues. Please share your complete code along with the font file. We will further investigate the issue and guide you.

Thank you so much for replying

Here is the font file
BADABB__.zip (8.3 KB)

Here is the screenshot of the complete call

image.png (12.5 KB)

@tilal.ahmad

@saniaaspose

Thanks for sharing the font. I have noticed the text alignment issue after text alignment and logged a ticket(PDFCLOUD-3025 ) in our issue tracking system for further investigation and rectification.

However, character spacing problem is font related. Aspose.PDF Cloud does not support setting character spacing but preserves the font spacing.

Thank you so much @tilal.ahmad for all the support

can you give me an estimate how soon is this issue will be fixed?

Thanks again

@saniaaspose

I am afraid we cannot share any ETA at the moment as it is pending for investigation in the queue. We will keep you updated about the issue resolution progress within this forum thread.

@tilal.ahmad

Thanks but is there any way you can make it high priority? We are trying to get a product out and this is an essential part of it…

Thanks again

@saniaaspose

I have already requested our product team to investigate the issue as soon as possible and share an update. However, if you have a subscription to our paid support service , then you can escalate the issue using it yourself, as paid support has a different priority queue.

@saniaaspose

We have good news for you. Your above reported issue is resolved. The TextReplace object now has a Boolean field CenterTextHorizontally. You can center-align the replaced text by setting the field to true. We have released a new version of the PDF Cloud API, 22.11. Please check and confirm.

thanks so much @tilal.ahmad can you please keep me posted of the issue

@saniaaspose

Please note that your reported issue is resolved and closed. Kindly use the CenterTextHorizontally property for your text alignment issue.

hi there @tilal.ahmad the property you suggested in center aligning the text with respect to the page which results in the following
image.jpg (103.3 KB)

as you can clearly see this is not the solution we want.

@saniaaspose

We are investigating the issue and will update you soon.

thanks @tilal.ahmad

when can I expect something?

@saniaaspose

I am afraid the issue(PDFCLOUD-3272) is taking more time than expected. We will keep you posted about the update.

thanks @tilal.ahmad

is there anyway we can talk directly with the developers team?

@saniaaspose

I am afraid we only provide phone support for sales inquires. For technical queries, we use the forums. Please feel free to post any questions or concerns in this forum.

Thanks @tilal.ahmad I see the issue is closed, can you please let us know what is the solution you guys got?