Hello,
I'm working on converting a .docx document to a .pdf document. The docx will have checkboxes (not necessarily controls) that I need to convert.
Currently I have a form that merges XML data to create a final form. The XML data determines whether a checkbox is checked or not. For my first try, I returned an 'X' or an 'O' to my binding. This has worked well.
I next tried to use Wingdings2 to return something that actually looks like a checkbox. I have another post about that on the forums, and it is being looked into.
Looking on the forums, I saw a post that suggested using unicode characters. ( docx-java-f6/bind-checkbox-in-docx-t1847.html ) So, I tried returning unicode characters into my bindings (☐,☑ and ☒), which worked fine for creating a .docx. I used the Arial Unicode MS font to display the unicode characters (however, they also displayed in calibri).
So, I made a little .docx that contained the three unicode ballot boxes (empty, checked, x'ed) and wrote a couple of small programs to convert the docx to pdf. I used PhysicalFonts.setRegex(regex) to set my list of appropriate fonts (including ARIALUNI to cover the use of Arial Unicode MS) and also used
PhysicalFont font
= PhysicalFonts.getPhysicalFonts().get("Arial Unicode MS");
// make sure this is in your regex (if any)!!!
if (font!=null) {
fontMapper.getFontMappings().put("Helvetica", font);
}
wordMLPackage.setFontMapper(fontMapper);
to make sure Helvetica was being converted to Arial Unicode, as I saw messages when I ran my programs that said my unicode characters were somehow using Helvetica:
Jul 9, 2014 7:31:36 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "?" (0x2610) not available in font "Helvetica".
Jul 9, 2014 7:31:36 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "?" (0x2611) not available in font "Helvetica".
Jul 9, 2014 7:31:36 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "?" (0x2612) not available in font "Helvetica".
Jul 9, 2014 7:31:36 AM org.apache.fop.events.LoggingEventListener processEvent
I've used both XSLFO and Docx4j.toFO to convert from docx to pdf and both end up placing a # in the pdf where the unicode character should be. I don't know where to go from here....
I've attached the .docx with the unicode characters, the .pdf I get as output, and both java programs I've tried for conversion. If someone could look at these and let me know what I'm doing wrong, I would be most appreciative.
Thanks
Mike Hudak