Free Support Forum - aspose.com

Special character ® losing font information

I am trying to replace the text of form fields in a pdf using the aspose.pdf​ library.

The problem I am running into is the PDF that gets generated loses its rich text font informatio​n on special characters​ such as: ®

We have arial font embedded in the PDF, and all the other text is in arial, however the ® shows up in what I believe is Times New Roman.


Below is some sample code that will reproduce this issue. I am using aspose.pdf.dll version 7.7.0.0


FileStream fs = new FileStream(this.selectedFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

Document doc = new Document(fs);

Stream ret = new MemoryStream();

Aspose.Pdf.InteractiveFeatures.Forms.RichTextBoxField currentTextbox = formField as Aspose.Pdf.InteractiveFeatures.Forms.RichTextBoxField;

string newValue = "Some Text(®)";
currentTextbox.Value = newValue;
doc.Flatten();
doc.Save();

The PDF that gets generated has a form field named TestForm and its value ends up being "Some Text(®)" but Some is in arial and Text(®) is in Times New Roman. If I get rid of the ® character, then all of it stays in Arial.

Thanks.

Hi there,


Please accept my apology for the delayed response. While using Aspose.Pdf for .NET 7.7.0, I’ve test the scenario but I’m unable to reproduce the issue. Whole value is being generated in Arial font. Can you please share your sample input and output document here? So we will investigate it at our end and provide your more information.

Sorry for the inconvenience faced.

Best Regards,

Hi there,


Please ignore my previous reply. I’ve manged to reproduce the issue with RichTextBox control. I’m further investigating the issue and will update you soon.

Sorry for the inconvenience faced.

Best Regards,



P.S: I’ve logged the issue as PDFNEWNET-34899 in our issue tracking system for further investigation and resolution. We will notify you via this forum thread as soon as it is resolved.

To work-around this issue we are using regular textbox fields as opposed to rich textbox fields. With the latest aspose.pdf release is there a way to manipulate text format in textbox fields?


For example:
We have a PDF with a textbox field named: FilenameField1. Then in code we create that field as a TextBoxField. Then we replace that textbox field value with a generated value. Then we flatten and save the document. We’d like to replace some of the FilenameField1 generated value with formatted text (bold and superscript).

So FilenameField1 text currently is:
MyDocument (description ®)

And we’d like it to show up as:
MyDocument (description ®)


Our current code -

Aspose.Pdf.Document doc;
doc = new Aspose.Pdf.Document(stream);

List<Aspose.Pdf.InteractiveFeatures.Forms.Field> listFields = new List<Aspose.Pdf.InteractiveFeatures.Forms.Field>();

// In case there are fields inside forms, we need to check several layers deep to make sure we get all the fields.
foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in doc.Form)
{
getField(formField, ref listFields);
}

foreach (var formField in listFields)
{
string fieldName = formField.AlternateName;
if (String.IsNullOrWhiteSpace(fieldName))
fieldName = formField.PartialName;
Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField currentTextbox = formField as Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField;
// The formfield wasn’t a textfield
if (currentTextbox == null)
continue;

string newValue = GetNewValue();
currentTextbox.Value = newValue;
}




Hi,


Thanks for your patience.

I am pleased to share that the issue PDFNEWNET-34899 reported earlier has been resolved and its hotfix will be included in next release version of Aspose.Pdf for .NET 7.8.0 (expected to release in early March-2013). Please be patient and wait for the new release version.

Your patience and comprehension is greatly appreciated in this regard.

The issues you have found earlier (filed as PDFNEWNET-34899) have been fixed in Aspose.Pdf for .NET 7.8.0update.


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