Processing of Image Fields in Mail Merge

Source: Internet
Author: User

I found aspose. words on the Internet to meet the requirements for exporting and printing. The template also contains images. In the past, we used DOM adjustment. In fact, we found that the mail export method is the most economical. I studied the processing of images.

Public class wordhelper
{
Public static void mailmerge (Dataset datasource, page, string tempdocname, string filenmae)
{
Document Doc = new document (tempdocname );
Doc. mailmerge. mergeimagefield + = new aspose. Words. Reporting. mergeimagefieldeventhandler (mailmerge_mergeimagefield );
Doc. mailmerge. executewithregions (datasource );
Doc. Save (filenmae, saveformat. Doc, savetype. openinword, page. Response );
}
/// <Summary>
/// Process the image field. You need to insert a domain where a photo or image is added to the template, but the domain name is set to image: name of the data table field, where the data table field can be string (that is, the image address ), it can also be a binary image.
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Static void mailmerge_mergeimagefield (Object sender, aspose. Words. Reporting. mergeimagefieldeventargs E)
{
If (E. fieldvalue! = System. dbnull. value)
{
Image IMG = image. fromstream (new system. Io. memorystream (byte []) E. fieldvalue ));
IMG = IMG. getthumbnailimage (120,140, null, intptr. Zero); // generate an image in the format
E. Image = IMG;
}
 }
When the template is set. Image: myimg

 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.