We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text replacement not functioning within application servers

Hi, thanks for fixing the problem we had with regional characters (Norwegian and Swedish).

However, this is still not working from within our web application. When we run the simple code attached as a normal java file through the main method, it is functioning as it should, but when we run it from inside a servlet container (tested and confirmed with Tomcat 6.x and Jetty) we get the following exception:

Caused by: java.io.IOException: InputStream cannot be null
at com.aspose.pdf.kit.gt.a(Unknown Source)
at com.aspose.pdf.kit.PdfContentEditor.replaceText(Unknown Source)
at com.aspose.pdf.kit.PdfContentEditor.replaceText(Unknown Source)
at com.skagenfondene.common.utils.PDFUtils.merge(PDFUtils.java:102)
at com.skagenfondene.common.utils.PDFUtils.merge(PDFUtils.java:85)
… 18 more

This only happens when using the regional characters however and it is functioning when we try to replace with empty strings or strings without the regional characters. I find this very curious and we cannot use your solution unless we can have it working within an application server.

Could you please take a look at this as soon as possible as people are getting impatient? Thanks

Attached is the complete, simple web application with the important source included. When run from within the an application server the exception will be cast.

Hi Egil,

We’ll investigate this issue at our end. Please spare us some time and you’ll be updated with the results the earliest possible.

We’re sorry for the inconvenience.
Regards,

I’ve done a little more research on this, and it seems to be a problem with replacing to characters not already in the pdf document. I’ve checked the file --> properties and it does say that the entire font is there, not an embedded subset though.

When i created an empty PDF file with the following contents, it worked just fine:
ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅabcdefghijklmnopqrstuvwxyzæøå1234567890. Is there some problem with reading the font when the character is not present in the document? Needless to say, this is not a viable solution for us…

Correction, I finally tried using Adobe Acrobat 9 to create the PDF file instead of using MS Office’s Save to PDF function. Seems to work perfectly now, so this might just be a problem with MS Office PDF’s (even if fonts are embedded)

Hi Egil,

I have noticed from the file you shared earlier that the fonts are the ‘embedded subset’, not the complete font. In case the font is embedded as a subset, you might have problems replacing the new characters; because in such situations the font is only available for the characters already present in the file. In order to avoid this problem, you need to embed the whole font using any tool you’re trying to create the PDF file with. You might consult MS Office help or Microsoft forums to find out how to embed the complete font and not the subset of it.

Regards,