C # use bookmarks in Asp.net word to insert images for export

Source: Internet
Author: User

# Region obtains the signature image of each user and inserts the image into the file.
String struser = string. empty;
Arraylist lstuser = new arraylist ();
For (INT I = 0; I <users. length; I ++)
{
Struser = users [I];
If (struser! = NULL)
{
Lstuser = businessfacade. sys_userlistbyucname (struser );
If (lstuser = NULL)
Usersmark [I] = string. empty;
Else
{
For (int ii = 0; II <lstuser. Count; II ++)
{
Sys_usertable ST = lstuser [II] As sys_usertable;
Usersmark [I] + = ST. u_mark + ",";
}
}
}
}

// Add the corresponding bookmarks to the Word template first. // the following code uses the bookmarks to insert an image to confirm the image position
// User bookmarks
String [] BK = {"analyzer", "corrector", "verifier "};
// Root directory of the user Image
String basepic = httpcontext. Current. server. mappath ("~ /Public/usermark /");

Foreach (word. Bookmark BM in Doc. bookmarks)
{
For (INT I = 0; I <bk. length; I ++)
{
If (BM. Name. tolower () = BK [I]. tolower ())
{
BM. Select ();
If (usersmark [I]. endswith (","))
Usersmark [I] = usersmark [I]. substring (0, usersmark [I]. Length-1 );

String [] PIC = usersmark [I]. Split (',');
For (int ii = 0; II <PIC. length; II ++)
{
// -- Determines whether the logo image exists. If the logo image does not exist, it is skipped.
If (file. exists (basepic + PIC [II])
{
// The image file to be inserted
App. selection. inlineshapes. addpicture (basepic + PIC [II], ref omissing );
}
// Doc. application. activedocument. inlineshapes [1]. width = 100f; // Image Width

// Doc. application. activedocument. inlineshapes [1]. Height = 8f; // Image Height
} Break;
}
}
}
# Endregion

Related Article

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.