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
}