diff --git a/app/services/reports/docx/private_methods.rb b/app/services/reports/docx/private_methods.rb index 1f4c7048b..257d71e4b 100644 --- a/app/services/reports/docx/private_methods.rb +++ b/app/services/reports/docx/private_methods.rb @@ -19,12 +19,17 @@ module Reports::Docx::PrivateMethods tiny_mce_table(elem[:data]) elsif elem[:type] == 'newline' style = elem[:style] || {} - @docx.p elem[:value] do - align style[:align] - color style[:color] - bold style[:bold] - italic style[:italic] - style style[:style] if style[:style] + # print heading if its heading + # Mixing heading with other style setting causes problems for Word + if %w(h1 h2 h3 h4 h5).include?(style[:style]) + @docx.public_send(style[:style], elem[:value]) + else + @docx.p elem[:value] do + align style[:align] + color style[:color] + bold style[:bold] + italic style[:italic] + end end elsif elem[:type] == 'image' Reports::Docx.render_img_element(@docx, elem)