Is there a way to display negative numbers in PDF template on aspose pdf version 16.1.10.
I have attached a sample code of generating template pdf using .xml file as input:
public void generatePDF(String xmlFile, String rtfFile, String pdfName) {
new RTFGeneratorHelper().setAsposeLicense();
InputStream rtfStream = null;
InputStream xmlStream = null;
DataSet ds = null;
try {
File file = new File(rtfFile);
if (file.exists()) {
rtfStream = new FileInputStream(file);
com.aspose.words.Document doc = new com.aspose.words.Document(rtfStream);
String fontFolder = System.getProperty("FONT_FOLDER");
if(fontFolder != null){
FontSettings fs = FontSettings.getDefaultInstance();
fs.setFontsFolder(fontFolder, false);
doc.setFontSettings(fs);
}
String localeCode= (String) RequestContext.getObject(RequestContext.LOCALE_ID);
if(null != localeCode && localeCode.equals("zh_CN"))
{
FontSettings fs = FontSettings.getDefaultInstance();
URL url = getClass().getClassLoader().getResource("fonts");
fs.setFontsFolder(url.toURI().getPath(), false);
fs.setDefaultFontName(arialUnicodeFont);
doc.setFontSettings(fs);
}
ds = new DataSet();
ds.readXml(xmlFile);
doc.getMailMerge().setUseNonMergeFields(true);
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS | MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
doc.getMailMerge().executeWithRegions(ds);
doc.updateFields();
doc.save(pdfName, com.aspose.words.SaveFormat.PDF);
}
}
catch (Exception e) {
logger.error("Error in generatePDF()");
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}