IOException on PdfContent.ReplaceText(...) - Not found appropriate font for the text

Hi,


I’m trying to utilize Aspoe.Pdf.Kit to create a new PDF document out of an existing PDF document after replacing some text in it (not using fields-forms, but a simple ‘replaceText’ method).

I’ve used the PdfContentEditor ReplaceText method and it seems to be working fine when replacing English text. but when I try to replace the text with a difference langue (Hebrew in my case), I’m getting the following exception:

IOException
Not found appropriate font for the text

Based on the error, one might assume that the PDF file doesn’t contain any Hebrew fonts embedded into it, but this is not the case as the entire document is in Hebrew.

Please advise.

Hi Eli,

First of all, please make sure that you’re using the latest version at your end. You may download it from this link.

Secondly, if the latest version doesn’t resolve this issue either then please share the input PDF file along with the code snippet you’re using at your end, so we could test this issue over here. You’ll be updated with the status the earliest possible.

We’re sorry for the inconvenience.
Regards,

  1. I have the latest version, I’ve just downloaded the evaluation yesterday from your site-- 5100
    2. Attached the input PDF
    3. Code

    PdfContentEditor pdfContent = new PdfContentEditor();
    pdfContent.BindPdf(fileName);
    pdfContent.ReplaceTextStrategy.ReplaceScope = ReplaceTextStrategy.Scope.REPLACE_ALL;
    pdfContent.ReplaceTextStrategy.IsRegularExpressionUsed = false;
    pdfContent.ReplaceTextStrategy.NoCharacterBehavior = ReplaceTextStrategy.NoCharacterAction.UseStandardFont;
    // This is the line that throws the exception - it works fine with English text, but failed on hebrew letters:
    pdfContent.ReplaceText(“here”, “שלום”);



Note that when changing the line:

pdfContent.ReplaceTextStrategy.NoCharacterBehavior = ReplaceTextStrategy.NoCharacterAction.UseStandardFont;

Into:
pdfContent.ReplaceTextStrategy.NoCharacterBehavior = ReplaceTextStrategy.NoCharacterAction.ReplaceAnyway;

It will not throw exception, but the replace text in PDF isn’t the hebrew letters, but a weird set of invalid characters.


Hi Eli,

I have reproduced this issue at my end and logged it as PDFKITNET-22662 in our issue tracking system. Our team will investigate it in detail and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Thank you.

Do you have an estimated time-line for an answer? days, weeks, more?

I evaluating the PDF kit and this issue delay my purchase - I want to utilize the Xmas discount, but of course I can’t buy it without this issue resolved.

Hi Eli,

As you know, this issue is logged recently, our team still needs to investigate it in detail. However, I have asked our development team to share the ETA of this issue. You’ll be updated with the response the earliest possible.

We’re sorry for the inconvenience.
Regards,

Thank you. I would like to know as soon as possible, because another solution might be to use aspose.word to modify the file and than export to PDF, so I need to know which direction to take, PDF of course, is the preferred method.



Hi Eli,

I would like to share with you that this issue will be resolved in our upcoming monthly release, which will be published early next month. You’ll be notified via this forum thread once it is published.

If you find any further questions, please do let us know.
Regards,

Hi, any news on this issue?

When is the expected release date?

Hi Eli,

This issue is resolved in our upcoming release which will be published tomorrow. You’ll be notified via this forum thread once it is published.

If you have any further questions, please do let us know.
Regards,

The issues you have found earlier (filed as 22662) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

No, this doesn’t solve the bug.

I still get the same exception. however, in some cases, I’m getting another error:
'Object reference not set to an instance of an object.'
stack trace:
at xbf7edc673db7027c.xec43072f03597c9f…ctor(x5a81dbde091c07a0 font, String fontName)
at x30a678191d9b1780.x704c80db9a265cb6.x8336cd789c3cd400(x55e62b072b3e84dc xb6a159a84cb992d6, IList x16e564e02abb798b, xd7c4e1d53048f9ce x3733a99ccc7ac0a3, xf02a647e64e89cf4 x7b02c8d2e61629d1, IList x8b7742958874a39e)
at x30a678191d9b1780.x704c80db9a265cb6.xf75e8309d745ba07(Stream xdc4cce4a2fe6be69, Stream xf823f0edaa261f3b, String x924a9657c6c79ce8, String x789624ed6c0d9813, Int32 xd2f4645e5496d5ab)
at Aspose.Pdf.Kit.PdfContentEditor.ReplaceText(String srcString, Int32 thePage, String destString, TextProperties TextProperties)
at Aspose.Pdf.Kit.PdfContentEditor.ReplaceText(String srcString, Int32 thePage, String destString)
at Aspose.Pdf.Kit.PdfContentEditor.ReplaceText(String srcString, String descString)
at SaveTaxDocumentsGenerator.PdfWriter.Generate(CustomerFieldsObjectData fieldsObject, String templatesFolderPath, String outputFolderPath) in D:\Aspoe Writer\pdf.kit\WinForm\Aspose.Pdf.Kit.Demos2005\SaveTaxDocumentsGenerator\PdfWriter.cs:line 27


This doesn’t occur when replacing English text, only Hebrew.
Please fix the issue ASAP.

Hi Eli,

I have again tested this issue, with the file you shared earlier – 1test.pdf, but couldn’t reproduce it at my end; it works fine with Aspose.Pdf.Kit for .NET 5.2.0.

Are you having the problem with some other file or the same file with different contents? If so, please share the file you’re having problem with; we need to test that particular scenario at our end. Also, please share the file which is throwing ‘object reference not set to an instance of an object’ exception.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hi.

I’ve just spend half-a-day trying to understand why the exception occurs on some cases, but not always, and I think I’ve managed to narrow the problem, here are my conclusion:

  1. object ref’ exception - this occurs when you try to replace a word and a number together (‘word 123’) and the word is in Hebrew.
  2. IOException - this occurs only when trying to replace a word with a certain Hebrew letters (4 out of the 27 letters).
    I hope the work I did will help you solve this issue ASAP, this is very urgent for me.
    Thanks.
Attached a PDF example (although you can get the error on any PDF file).
Also, here is the code showing the first issue:
PdfContentEditor pdfContent = new PdfContentEditor();
pdfContent.BindPdf(fileName);
pdfContent.ReplaceTextStrategy.ReplaceScope = ReplaceTextStrategy.Scope.REPLACE_ALL;
pdfContent.ReplaceTextStrategy.IsRegularExpressionUsed = false;
// This line throws exception: ‘Object reference not set to an instance of an object’.
// looks like related to a word with space and a number (word space word works):
// pdfContent.ReplaceText(“Field3a”, “123 מילה”);

Here is the code showing the second issue:

// These are all the hebrew letters:
// Works:
//pdfContent.ReplaceText(“Field3a”, “א”);
//pdfContent.ReplaceText(“Field3a”, “ב”);
// ERROR ‘Not found appropriate font for the text’
// pdfContent.ReplaceText(“Field3a”, “ג”);
// Works:
//pdfContent.ReplaceText(“Field3a”, “ד”);
//pdfContent.ReplaceText(“Field3a”, “ה”);
//pdfContent.ReplaceText(“Field3a”, “ו”);
//pdfContent.ReplaceText(“Field3a”, “ז”);
//pdfContent.ReplaceText(“Field3a”, “ח”);
// ERROR
// pdfContent.ReplaceText(“Field3a”, “ט”);
// Works:
//pdfContent.ReplaceText(“Field3a”, “י”);
//pdfContent.ReplaceText(“Field3a”, “כ”);
//pdfContent.ReplaceText(“Field3a”, “ל”);
//pdfContent.ReplaceText(“Field3a”, “מ”);
//pdfContent.ReplaceText(“Field3a”, “נ”);
//pdfContent.ReplaceText(“Field3a”, “ס”);
//pdfContent.ReplaceText(“Field3a”, “ע”);
//pdfContent.ReplaceText(“Field3a”, “פ”);
//pdfContent.ReplaceText(“Field3a”, “צ”);
//pdfContent.ReplaceText(“Field3a”, “ק”);
//pdfContent.ReplaceText(“Field3a”, “ר”);
//pdfContent.ReplaceText(“Field3a”, “ש”);
//pdfContent.ReplaceText(“Field3a”, “ת”);
//pdfContent.ReplaceText(“Field3a”, “ך”);
//pdfContent.ReplaceText(“Field3a”, “ם”);
//pdfContent.ReplaceText(“Field3a”, “ן”);
// ERROR
// pdfContent.ReplaceText(“Field3a”, “ץ”);
// ERROR
// pdfContent.ReplaceText(“Field3a”, “ף”);

Hi Eli,

I have reproduced both of these issues and logged them as shown below:

PDFKITNET-23531 - Object reference not set exception
PDFKITNET-23532 - IOException

Our team will investigate these issues in detail and you’ll be notified via this forum thread once they’re resolved.

We’re sorry for the inconvenience.
Regards,

Any news on this issue? I’ve provided a very detailed information to reproduce it (and hopefully to solve it), as I need this functionality very urgent.


Hi Eli,

I’m sorry to inform you that this issue is not yet resolved. However, I have asked our development team to share the ETA. You’ll be updated as soon as we get a clear idea of the ETA.

We’re sorry for the inconvenience.
Regards,

Hi Eli,

Our team has looked into this issue in detail and I would like to inform you that the fix for these two issues will be available in our monthly release due at the end of March or early April 2011. You’ll be notified via this forum thread as soon as it is published.

We’re sorry for the inconvenience.
Regards,