fontMapper.getFontMappings().put("Times New Roman", null);
PhysicalFonts.setRegex(regex);
PhysicalFont font
= PhysicalFonts.getPhysicalFonts().get("Arial Unicode MS");
// make sure this font is allowed by your regex (if any)!!!
fontMapper.getFontMappings().put("Times New Roman", font ); // oops!
String inputfilepath = "c:\\users\\malik\\desktop\\test2.docx";// args[0];
// Document loading (required)
WordprocessingMLPackage wordMLPackage;
wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
Mapper fontMapper = new IdentityPlusMapper();
PhysicalFont font = PhysicalFonts.getPhysicalFonts().get("Arial Unicode MS");
fontMapper.getFontMappings().put("Times New Roman", font );
wordMLPackage.setFontMapper(fontMapper);
FOSettings foSettings = Docx4J.createFOSettings();
if (saveFO)
{
foSettings.setFoDumpFile(new java.io.File(inputfilepath + ".fo"));
}
foSettings.setWmlPackage(wordMLPackage);
// exporter writes to an OutputStream.
String outputfilepath;
outputfilepath = "test.pdf";
OutputStream os = new java.io.FileOutputStream(outputfilepath);
Docx4J.toFO(foSettings, os, Docx4J.FLAG_NONE);
<?xml version="1.0" encoding="utf-8"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"><layout-master-set xmlns="http://www.w3.org/1999/XSL/Format"><simple-page-master margin-bottom="0.25in" margin-left="1in" margin-right="1in" margin-top="0.25in" master-name="s1-simple" page-height="11in" page-width="8.5in"><region-body margin-bottom="19mm" margin-left="0mm" margin-right="0mm" margin-top="19mm"/><region-before extent="12mm" region-name="xsl-region-before-simple"/><region-after extent="12mm" region-name="xsl-region-after-simple"/></simple-page-master><page-sequence-master master-name="s1"><repeatable-page-master-alternatives><conditional-page-master-reference master-reference="s1-simple"/></repeatable-page-master-alternatives></page-sequence-master></layout-master-set><fo:page-sequence id="section_s1" format="" master-reference="s1"><fo:flow flow-name="xsl-region-body">
<fo:block break-before="auto" font-size="16.0pt" line-height="100%" space-after="0in" space-before="0in"><inline xmlns="http://www.w3.org/1999/XSL/Format" font-size="16.0pt" writing-mode="rl-tb"><inline font-family="Arial">وثيقة تجربة : 123456789</inline></inline></fo:block>
</fo:flow></fo:page-sequence></fo:root>
PhysicalFont font = PhysicalFonts.getPhysicalFonts().get("Arial Unicode MS");
fontMapper.getFontMappings().put("Times New Roman", font );
malik wrote: I tried by changing the digit substitution to be Arabic digits.
Something you should bear in mind when using these options is that they are Word options. They aren't stored in the document at all. If you save and close your document, modify the options, and re-open, the new options will be in force. If you send the document to another user, their options will be in force. Since this isn't something I do, it's difficult to know whether this is what Word users writing in Arabic/English (say) expect (or perhaps even "have become resigned to") or whether they woud be surprised that their numbers might appear differently to a recipient.
The point is that docx4j does not and should not automatically convert to Eastern Arabic (Hindi)
malik wrote:By the way I tried all possible settings for the Numeral option in word (i.e. Arabic, Hindi, Context, System) but in all cases the output PDF stayed same.
Users browsing this forum: No registered users and 15 guests