0

I have a web page which need to export into Microsoft Word document. And this page contains picture which is too large after exporting into .doc file. Here is my code:

         StringBuilder strHTMLContent = new StringBuilder();
    //appending the style sheet 
    strHTMLContent.Append("<style>.labelalign {float: right !important;}.imgDiv{height: 83px; width: 90px; float: right;}.design {font-size: 16px;}.design1 {font-size: 15px;}.td {background-color: #A4A4A4;}</style>".ToString());

    Response.Clear();
    Response.AddHeader("content-disposition", "attachment; filename=" + txtcandidatename.Text.Trim() + ".doc");
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.ms-word ";
    StringWriter stringWrite = new StringWriter();
    HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    mydiv.RenderControl(htmlWrite); 
    Response.Write(strHTMLContent.Append(stringWrite).ToString());   // send the stringWrite          
    Response.End();
    Response.Flush();
}

I want to resize the image inside the mydiv. This image is already fixed in size inside the TD but still when exporting it is taking the original size of the image.

Here is the table code:

            <table style="width: 899px;" align="center" cellpadding="4" cellspacing="3">
            <tr>
                <td style="width: 50%">
                </td>

                <td style="width: 90px; float: right; height: 83px;" class="imgDiv">

                    <asp:Image ID="candidateimg" runat="server" CssClass="imgDiv" ImageUrl="http://localhost:59055/ExportPDF/Image/photo.jpg" ImageAlign="Right" Width="90px" Height="83px" /></td>

            </tr>
        </table>

Please help me by suggesting how do I resize the image. Thanks.

barsan
  • 2,431
  • 16
  • 45
  • 62
  • Simple idea is to resize the source image. If you only display it on the page and don't need it to be larger for any reason this will do the trick. Otherwise you'll have to work out your code so you can get a handle to the object and resize it using the Image library before sending it to Word. – Adam Heeg Mar 24 '16 at 15:25
  • I know this but my client has handed over this project to me. And I don't have any access to the images as the images are uploaded by the user as their profile image. And I need to print the CV using that image. Do you have any idea how do I handle the object to resize it using the image library? – barsan Mar 24 '16 at 15:55
  • Once you get the image (i cannot help you with that if there are any problems) you can use this link for some ideas on modifying it. http://stackoverflow.com/questions/1195064/fastest-image-resizing-in-net – Adam Heeg Mar 24 '16 at 17:47

0 Answers0