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

Free Support Forum - aspose.com

The Rupee symbol can't be displayed after merge

Hi Supports,

I am trying to use Rupee symbol in one of my template to generate PDF invoice. But the merged Rupee symbol can't be displayed.

The attached is the template as well as the merge result.
The following is the code I am using. Could you please have a look and give advice? Is it a bug of Aspose lib?

public class SimpleMerge {

public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    generateDoc("Rupee.doc");
}

private static void generateDoc(String template) throws Exception {
    Document doc = new Document(template);
    doc.getMailMerge().execute(getDatasourceOne());
    String fileName = template + ".doc";
    doc.save(fileName, SaveFormat.DOC);
    System.out.println(fileName);
}
public static IMailMergeDataSource getDatasourceOne() {
    return new IMailMergeDataSource() {
        boolean hasNext = true;
        public String getTableName() throws Exception {
            return "Invoice";
        }

        public boolean moveNext() throws Exception {
            if (hasNext) {
                hasNext = !hasNext;
                return true;
            } else {
                return false;
            }
        }

        public boolean getValue(String paramString, Object[] paramArrayOfObject) throws Exception {
            //System.out.println("mergefield:" + paramString);
            paramArrayOfObject[0] = 200;
            return true;
            
        }

        public IMailMergeDataSource getChildDataSource(String paramString) throws Exception {
            return null;
        }
        
    };
}

}

Thanks
TonyRupee.zip (35.0 KB)

@stlcn,

Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you’re converting documents to PDF. Please refer to the following article.

How Aspose.Words Uses True Type Fonts

Please install “Oriya Sangam MN” font to get the desired output. You may substitute this font using FontSettings.setFontSubstitutes method.

FontSettings.getDefaultInstance().setFontSubstitutes("Oriya Sangam MN", new String[] { "Arial" });
Document doc = new Document(MyDir + "input.docx");

We suggest you please read following article.
How to Receive Notification of Missing Fonts and Font Substitution during Rendering

Hi Tahir,

Thanks for the quick response.
I have the "Oriya Sangam MN" font installed in my machine. And you can find the font is embedded in the PDF generated.
I revisited the template and I found the font of the merge field is "Arial" except the Rupee symbol ₹, and I couldn't change the font of ₹ to Arial in template.
If I change the font of the merge field to "Oriya Sangam MN", then the symbol can be displayed. You can see that in the new attached document.

So the question is why the symbol ₹ in merge field with font "Arial" couldn't be displayed?

Archive.zip (32.9 KB)

Thanks
Tony Shen

@stlcn,

Thanks for your inquiry. Please ZIP and attach font “Oriya Sangam MN” here for testing. Please also share your working environment e.g. operating system, Java version etc. We will investigate the issue on our side and provide you more information.

@tahir.manzoor
The font was uploaded. I am working with MacBook Pro, OS X Yosemite version 10.10.5. Java is 1.8. Aspose lib is 17.4.
Oriya Sangam MN.ttc.zip (220.2 KB)

The following is the font list that support Rupee sign, but they can not be supported by Aspose.
http://www.fileformat.info/info/unicode/char/20b9/fontsupport.htm

Thanks

@stlcn,

Thanks for sharing the detail. We have tested the scenario using latest version of Aspose.Words for Java 17.10 and have not found the shared issue. Moreover, we have not found the shared issue in output PDF shared by you in Archive.zip. Please use Aspose.Words for Java 17.10. We have attached the output PDF with this post for your kind reference. 17.10.pdf (19.1 KB)

@tahir.manzoor

The issue is still there. I attached the template with issue again so that you can reproduce.template and pdf with issues.zip (32.6 KB)

With this template, I got two questions,

  1. The font of the merge field “Invoice.Tax” is “Arial”, while the font of “₹” in it is “Oriya Sangam MN”, then the “₹” can’t be displayed in the final PDF;
  2. I changed the font of “₹” in “Invoice.Tax” to “Arial”, but it still can not be displayed in the final PDF correctly. According to the following list, “Arial” supports “₹”.
    http://www.fileformat.info/info/unicode/char/20b9/fontsupport.htm

Thanks
Tony Shen

@stlcn,

Thanks for sharing the detail. We have tested the scenario at Windows 10 and Ubuntu. We have not found the shared issue. We will setup the same environment as of yours and test this scenario. We will get back to you soon.

@stlcn,

Thanks for your patience. We have tested the scenario on Mac operating system and have not found the shared issue. You can test this scenario using following code example. Please put “Arial” and “Oriya Sangam MN” fonts in a temp folder and test the scenario. If the fonts are not available, you will get missing font notifications.

Note : please replace “…font folder…” with font’s folder.

FontSettings.getDefaultInstance().setFontsFolder("...font folder...", true);        
Document document = new Document(MyDir + "Rupee_template.doc");
document.getMailMerge().execute(new String[] { "Invoice.Tax" }, new String[] { "3333" });
document.setWarningCallback(new com.aspose.words.IWarningCallback() {
    @Override
    public void warning(com.aspose.words.WarningInfo warningInfo) {
        if(warningInfo.getWarningType() == WarningType.FONT_SUBSTITUTION)
            System.out.println(warningInfo.getDescription());
    }
});
document.save(MyDir + "17.10.pdf");

@tahir.manzoor Thank you for the continuous support. I tried your code, but it didn’t work in my environment. The Rupee sign wasn’t displayed, and I only got the warning “Font ‘Cambria’ has not been found. Using ‘Oriya Sangam MN’ font instead. Reason: closest match according to font info from the document.”
I uploaded the template as well as the PDF again. Could you try the template in this zip package?Rupee_template_with_issue.zip (25.3 KB)

The following is the code of mine,
    FontSettings.getDefaultInstance().setFontsFolder("font", true);   
    Document doc = new Document(template);
    doc.setWarningCallback(new com.aspose.words.IWarningCallback() {
        public void warning(com.aspose.words.WarningInfo warningInfo) {
            if(warningInfo.getWarningType() == WarningType.FONT_SUBSTITUTION)
                System.out.println(warningInfo.getDescription());
        }
    });
    doc.getMailMerge().execute(new String[] { "Invoice.Tax" }, new String[] { "3333" });
    String fileName = template + ".pdf";
    doc.save(fileName, SaveFormat.PDF);
    System.out.println(fileName);

If you still cannot reproduce it, can we schedule a meeting so I can show you my problem?

Thanks
Tony Shen

@stlcn,

Thanks for your inquiry. We are investigating this issue and will get back to you soon.

@stlcn,

Thanks for your patience. We have tested the scenario using same code example at MAC operating system, Java 8. We have not found the shared issue. Please check the attached output PDF.
17.10.pdf (18.9 KB)

@tahir.manzoor

Did you use the template from Rupee_template_with_issue.zip?

Thanks
Tony Shen

@stlcn,

Thanks for your inquiry. Yes, we used both input documents shared in this forum thread to test your scenario. Here is output of Rupee_template_with_issue.doc.
Rupee_template_with_issue 17.10.zip (17.2 KB)

@tahir.manzoor

I tried many times and different ways, but it didn’t work for me still. The attached is a new template as well as the PDF file generated. Could you please have a look?
Rupee_template_with_issue_3.zip (18.7 KB)

I schedule a meeting via zoom, if it is available for you, could you join this meeting so I can demo to you.

Thanks
Tony Shen

Tony Shen is inviting you to a scheduled Zoom meeting.

Join from PC, Mac, Linux, iOS or Android: https://zuora.zoom.us/j/5945844927

Or iPhone one-tap :
    US: +16699006833,,5945844927#  or +16465588656,,5945844927# 
Or Telephone:
    Dial(for higher quality, dial a number based on your current location):
        US: +1 669 900 6833  or +1 646 558 8656 
        New Zealand: +64 (0) 9 801 1188  or +64 (0) 4 831 8959 
        India: +91 22 62 192 563 
        Singapore: +65 3158 7288 
        South Korea: +82 (0) 2 6022 2322 
        Taiwan: +886 277 417 473 
        Hong Kong: +852 5808 6088 
        Japan: +81 (0) 3 4578 1488 
        China: (010) 87833177 
    Meeting ID: 594 584 4927
    International numbers available: https://zuora.zoom.us/zoomconference?m=OAS9NqY1eqjiHOLQegfTIVvST71qiZQ4

Or an H.323/SIP room system:
    H.323: 
        162.255.37.11 (US West)
        162.255.36.11 (US East)
        221.122.88.195 (China)
        115.114.131.7 (India)
        213.19.144.110 (EMEA)
        202.177.207.158 (Australia)
        209.9.211.110 (Hong Kong)
        64.211.144.160 (Brazil)
        69.174.57.160 (Canada)
    Meeting ID: 594 584 4927

    SIP: 5945844927@zoomcrc.com

@stlcn,

Thanks for your inquiry.

Please note that we only provide support via forum.

It seems that you are using different fonts that we are using. We copied the “Arial” font from the Windows 10 into Mac operating system. Could you please download the attached fonts, put them into your font’s folder, and execute the application? Please let us know if you still face the same issue.
fonts.png (262.0 KB)
font.zip (2.3 MB)

We used the following line of code to set the font’s folder.
FontSettings.getDefaultInstance().setFontsFolder("/users/tahir/desktop/fonts/", true);

@tahir.manzoor
I think I found the root cause. I am using a lower version of Arial font. I uploaded it and you can test with it. So I think you can reproduce my issue.

Thanks a lot for your help.

Tony Shenarial.ttf.zip (193.2 KB)

@stlcn,

Thanks for your inquiry. In your document (Rupee_template_with_issue_3.doc), the mail merge fields have font “Arial Bold”. So, please use “Arial Bold” font to get the correct output. If you only use “Arial” font, the rupee symbol will not be displayed in output PDF.

@tahir.manzoor

I tried with the Arial Bold too, it didn’t work. The Rupee symbol was designed in 2010, but my font version is 2006. While your font version is 2015. I think that is why the template works in your env while not in mine.

The attached is the Arial bold font I used, you can try it too.arialbd.ttf.zip (187.9 KB)

Thanks
Tony Shen

@stlcn,

Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you’re converting documents to PDF.

It seems that this is not a bug in Aspose.Words. However, we have logged this issue as WORDSNET-16068 in our issue tracking system. We will inform you via this forum thread once there is any update available on this issue. We apologize for your inconvenience.