Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jan 31, 2023 2:09 pm

Hello,

I am trying to Find and replace text on PDF document in VB.NET according to this tutorial:
Tutorials > .NET > Spire.PDF > Program Guide > Text > Find and replace text on PDF document in C#

I came across one problem: string I am replacing original text with contains characters witch are not interpreted well (like šřáĚŽÝ ...).
Could you help me with this issue?

Thank you so much!

kupka.vojtech
 
Posts: 2
Joined: Tue Jan 31, 2023 1:52 pm

Wed Feb 01, 2023 6:36 am

Hello,

Thanks for your inquiry.
Please kindly notice that if you use the Czech to replace, you need to set the font style to Czech font to avoid font garble. You can refer to the following code:
Code: Select all
' Defines a font
        Dim font As New PdfTrueTypeFont(New Font("Your Czech font", 12.0F, FontStyle.Regular))

If this solution does’t help you, please offer the following message to help us reproduce your issue and work out a solution for you. Thanks for your assistance in advance.
1) Your input PDF file and your font installation file, you can attach here or send it to us via email ([email protected]).
2) Your full test code.
3) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Wed Feb 01, 2023 9:32 am

Hi Abel,

thank you for your quick answer! Unfortunately, text replacement still does not work well.
Here is what I do:
Code: Select all
Dim font As New PdfTrueTypeFont(New Font("TimesRoman", 12.0F, FontStyle.Regular))
Dim lBrush As PdfBrush = PdfBrushes.Black
Dim x As Single = lPosition.X - lMarginX
Dim y As Single = lPosition.Y - lMarginY

lPage.Canvas.DrawRectangle(PdfBrushes.White, lFind.Bounds)
lPage.Canvas.DrawString(aNewText, font, lBrush, x, y - 2)

When I call function
Code: Select all
ReplaceText("__APPROVED_BY__", "Alžběta Řízečková")

the result of replacement will be "Alžb ta Xíze ková" as you can see at the screenshot from pdf:
Image
So it seems like some Czech characters work, but not all of them. Do you please have some idea what to try next?
I can´t send you the pdf, because it contains our customers data. But I could create some example pdf instead if necessary.

Thank you very much!
Vojta

kupka.vojtech
 
Posts: 2
Joined: Tue Jan 31, 2023 1:52 pm

Wed Feb 01, 2023 10:08 am

Hello,

Thanks for your feedback.
I did preliminary test and did notice the issue you mentioned, however, I need some time to investigate the reason of the issue. Don't worry, I'll give you feedback asap.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Fri Feb 03, 2023 7:38 am

Hello,

Thanks for your patiently waiting.
For this issue, I have logged it to our issue track system with the number SPIREPDF-5756 reported to our Dev team, they will investigate and fix it. Once the issue has been solved, I’ll inform you in time. Sorry for the inconvenience caused.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Tue Apr 11, 2023 3:20 am

Hello,

Thanks for your patiently waiting.
For the issue with the number SPIREPDF-5756, I have some information to inform you:
To solve this issue, you need to modify your original code
Code: Select all
Dim font As New PdfTrueTypeFont(New Font("TimesRoman", 12.0F, FontStyle.Regular))

To
Code: Select all
Dim font As New PdfTrueTypeFont(New Font("Arial", 12.0F, FontStyle.Regular), True).

If you have any issue, just feel free to contact us.
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF

cron