Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7645033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:50:11+00:00 2026-05-31T09:50:11+00:00

I am using C# to generate reports in MS Word. I have a predefined

  • 0

I am using C# to generate reports in MS Word. I have a predefined .docx template and I use mail merge fields which are then updated by my app.

I retrieve small sections of HTML content from a database and insert them into the appropriate points in the MS Word document as follows:

  1. I retrieve the HTML content

  2. I wrap the content with tags:

    <HTML>
    <TITLE></TITLE>
    <BODY>
    ... content ...
    </BODY>
    </HTML>

  3. Save html content into a temporary file

  4. Use the Word._Application.Selection.InsertFile() method to insert the HTML file

Example of converted HTML code:

<html>
<title></title>
<body>
    <table border="0" cellpadding="0" cellspacing="0" style="width: 700px; ">
    <tbody>
    <tr>
        <td style="padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; text-align: center; vertical-align: middle; width: 150px; ">
            <img alt="see attached image: screenshot-3.jpg" src="XXXXX/screenshot-3.jpg" style="width: 60px; height: 84px; " />
        </td>
    </tr>
</tbody>
</table>
<br />
</body>
</html>

The above system works, but I find that tables and images are ‘auto-scaled’ by MS Word, with images being rendered with their original dimensions as opposed to the embedded style=”width, height” attributes.

My HTML is rendered 100% in a browser, but not in MS Word.

Any ideas on how to get my scaling right would be most appreciated.

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:50:12+00:00Added an answer on May 31, 2026 at 9:50 am

    In my experience HTML may be the easiest way of getting rich text into a Word document, but it’s also prone to get formatting wrong and you don’t have control over the finer details.

    Have you tried using the width and height attributes for the img element? Another option might be to try using RTF (which is on par with Word, feature-wise).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using nose and coverage to generate coverage reports. I only have one package
I'm trying to generate code coverage reports with EMMA using tests of which some
I'm using Rave to generate reports, but it's poor at generating Word docs. My
I have a Java class which uses Apache POI to generate reports in Excel.
I have a report which needs to be exported in pure word format(97-2003) using
I'm using Report Viewer Control (rdlc) to generate reports. One of my columns have
I'm using DOMPDF to generate about 500 reports from one script. It's running out
I infrequently (monthly/quarterly) generate hundreds of Crystal Reports reports using Microsoft SQL Server 2005
I'm developing a web application with asp.net and I have a file called Template.docx
We have a service that generates a report (using word templates and a 3rd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.