I'm having a problem where when I do a text replacement with extended characters in a loaded document template and then save the result as both Word (DOCX) and PDF, the Word document shows the extended character replacement, but the PDF version doesn't. The PDF does show normal replacement text however. See the attached template and the resulting Word and PDF files.
Here's my code:
- Code: Select all
using Spire.Doc;
using Spire.Doc.Interface;
namespace TemplateTester
{
internal class Program
{
private static readonly string checkMark = ((char)0x2611).ToString();
private static readonly string emptyMark = ((char)0x2610).ToString();
private static void Main()
{
var document = new Document("test.dotx", FileFormat.Dotx);
ReplaceMetaTag(document, "[Checked]", true);
ReplaceMetaTag(document, "[Unchecked]", false);
document.Replace("[Text]", "Replacement Text Test", false, true);
document.SaveToFile("test.docx", FileFormat.Docx);
document.SaveToFile("test.pdf", FileFormat.PDF);
}
private static void ReplaceMetaTag(IDocument document, string tag, bool value)
{
document.Replace(tag, value ? checkMark : emptyMark, false, true);
}
}
}