Format Java code in Word / RTF

I need to format java code to insert into Word document. Are there any programs that will do this with keyword highlighting etc.?

+2


source to share


3 answers


When I copy / paste from my IDE (Eclipse), the formatting happens to ride.



You will probably want to turn off Flag Incidents first.

+3


source


This is a late answer, but since this is a rather specific requirement, I'll post my comment anyway.

You can do this programmatically with Docmosis , assuming you want the program to run in Java (not just display java in docs) and can install OpenOffice where the program runs. This process will:



  • Create a doc or odt file that will act as a template (setting fonts, position, tables, etc.) and where you want to enter the code sample
  • Add docmosis to a java project and write the code to initialize Docmosis, register the template, then render the document using the selected Java code.
  • Currently Docmosis FieldRenderers can underline or italicize your data as it does, but rendering is currently being applied to the entire field. So it won't allow you to have one field for all your java text and individual word highlighting, but there are a few more tricks you could use to get useful / interesting results (like splitting your data into separate fields and allowing doxose fields in different ways).

The "java code" text that you specify as data will be inserted into your template using the font and layout properties in the template. The renderer will have the ability to override specific formatting.

+1


source


You can just copy and paste it into your word document. I am also using OS X. I just work fine. I am uploading a screenshot of what it looks like with a word.

enter image description here

+1


source







All Articles