word中如何显示base64编码的图片 图片通过ajax传到后台再传到word中,再生成word,但...

\u5982\u4f55\u5c06base64\u7f16\u7801\u8f6c\u53d8\u4e3a\u56fe\u7247

\u5982\u679c\u5df2\u7ecf\u662fbase64\u683c\u5f0f\u7684\u56fe\u7247\uff0c\u90a3\u4e48\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4f7f\u7528\u3002

CSS\u4e2d\u4f7f\u7528\uff1abackground-image: url("data:image/png;base64,iVBORw0KGgo=...");
HTML\u4e2d\u4f7f\u7528\uff1asrc="data:image/png;base64,iVBORw0KGgo=..."\u3002

\u8be6\u7ec6\u7684\u4f7f\u7528\u548c\u539f\u7406\u53ef\u4ee5\u53c2\u8003\uff1a
http://www.it399.com/m/image/base64

\u8fd9\u4e2a\u6bd4\u8f83\u597d\u89e3\u51b3\uff0c\u6211\u89c9\u5f97\u8fd9\u79cd\u95ee\u9898PHPWord\u80af\u5b9a\u53ef\u4ee5\u5b8c\u6210
addSection(); $section->addImage($image); //\u751f\u6210\u6587\u4ef6 $name = "HelloWorld.docx"; $wordWriter = \PhpOffice\PhpWord\IOFactory::createWriter($word, "Word2007"); $wordWriter->save($name);

输出html 格式,放歌img 标签,1先把base64编码转为图片,再生成world.
/// <summary>  
        /// base64编码的文本转为图片  
        /// </summary>  
        /// <param name="txtFilePath">文件相对路径(存到服务器上)</param>  
        /// <param name="str">图片字符串</param>  
        private void Base64StringToImage(string txtFilePath, string str)
        {
            try
            {
                String inputStr = str;
                byte[] arr = Convert.FromBase64String(inputStr);
                MemoryStream ms = new MemoryStream(arr);
                Bitmap bmp = new Bitmap(ms);

                bmp.Save(System.Web.HttpContext.Current.Server.MapPath(txtFilePath) + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                //bmp.Save(txtFileName + ".bmp", ImageFormat.Bmp);  
                //bmp.Save(txtFileName + ".gif", ImageFormat.Gif);  
                //bmp.Save(txtFileName + ".png", ImageFormat.Png);  
                ms.Close();
                //imgPhoto.ImageUrl = txtFilePath + ".jpg";  
                //MessageBox.Show("转换成功!");  
            }
            catch (Exception ex)
            {

            }
        }
public void ExportControl(System.Web.UI.Control source, string DocumentType, string filename)  
   {  
       //设置Http的头信息,编码格式  
       HttpContext.Current.Response.Buffer = true;  
       HttpContext.Current.Response.Clear();  
       HttpContext.Current.Response.ClearContent();  
       HttpContext.Current.Response.ClearHeaders();  
       if (DocumentType.ToLower() == "excel")  
       {  
           //Excel              
           HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename + ".xls", System.Text.Encoding.UTF8));  
           HttpContext.Current.Response.ContentType = "application/ms-excel";  
       }  
       else if (DocumentType.ToLower() == "word")  
       {  
           //Word  
           HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename + ".doc", System.Text.Encoding.UTF8));  
           HttpContext.Current.Response.ContentType = "application/ms-word";  
       }  
       HttpContext.Current.Response.Charset = "UTF-8";  
       HttpContext.Current.Response.HeaderEncoding=System.Text.Encoding.UTF8;  
       HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;  
       //关闭控件的视图状态  
       source.Page.EnableViewState = false;  
       //初始化HtmlWriter  
       System.IO.StringWriter writer = new System.IO.StringWriter();  
       System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);  
       source.RenderControl(htmlWriter);  
       //输出  
       HttpContext.Current.Response.Write(writer.ToString());  
       HttpContext.Current.Response.End();  
   }


word中不能直接显示base64编码的字符串为图片哦,可以先base64编码的字符串转为图片,然后把图片插word文档即可。http://www.it399.com/m/image/base64
,使用这个在线工具可以进行base64转图片,望采纳,谢谢!

  • word涓浣曟樉绀篵ase64缂栫爜鐨勫浘鐗
    绛旓細杈撳嚭html 鏍煎紡锛屾斁姝宨mg 鏍囩锛1鍏堟妸base64缂栫爜杞负鍥剧墖锛屽啀鐢熸垚world./// <summary> /// base64缂栫爜鐨勬枃鏈浆涓哄浘鐗 /// </summary> /// <param name="txtFilePath">鏂囦欢鐩稿璺緞(瀛樺埌鏈嶅姟鍣ㄤ笂)</param> /// <param name="str">鍥剧墖瀛楃涓</param> private void Base64...
  • word鍥剧墖濡備綍鏇挎崲涓轰唬鐮
    绛旓細word鍥剧墖鏇挎崲涓轰唬鐮佺殑鏂规硶濡備笅锛1銆佹墦寮word鏂囨。锛岄変腑闇瑕佹浛鎹负浠g爜鐨勫浘鐗囷紝骞跺鍒跺浘鐗囥2銆佹墦寮涓涓base64缂栫爜宸ュ叿锛堝https锛//www.base64-image.de/锛夛紝灏嗗鍒剁殑鍥剧墖绮樿创鍒板伐鍏蜂腑銆3銆佺偣鍑烩淐onvert鈥濇寜閽紝绛夊緟宸ュ叿灏嗗浘鐗囪浆鎹负base64缂栫爜鏍煎紡銆4銆佸鍒禸ase64缂栫爜鏍煎紡鐨勫唴瀹广5銆佹墦寮浠g爜缂栬緫鍣紝...
  • 甯歌base64鏂囦欢鍓嶇紑
    绛旓細.doc鈥斺攄ata:application/msword;base64,.docx鈥斺攄ata:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,.xls鈥斺攄ata:application/vnd.ms-excel;base64,.xlsx鈥斺攄ata:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,.pdf鈥斺攄ata:application/pd...
  • 鐜版湁涓涓word鏂囦欢澶у皬涓1026瀛楄妭,浣跨敤base64缂栫爜,姣80瀛楄妭鎴栬呮渶鍚庝竴琛...
    绛旓細base64鍏24byte锛3涓8浣嶈浆鎹4涓6浣嶏級缂栫爜鏂囦欢澶у皬锛1026/3*4=1368B锛1368/80=17.1锛堥渶瑕佹彃鍏18娆″洖杞︼級棰濆鏀嚭瀛楄妭18*2=36B 瀹為檯鍙戦佸瓧鑺傛暟1368+36=1404B
  • 鐢ㄩ偖绠变紶閫word鏂囦欢,瀵规柟鐪嬪埌鐨勬槸涔辩爜,鎬庝箞鍥炰簨
    绛旓細瑙g爜鍔炴硶:鐢‥-mail杞綋,閫夋嫨缂栫爜涓Base64 閫夐」灏卞彲瑙g爜,瑙g爜鍚庝細娑堥櫎涔辩爜銆 QpencodeQP:鍏ㄧО鈥淨uoted-Printable Content-Transfer-Encoding鈥濄傚洜涓鸿繖绉嶆牸寮忛偖浠剁殑鍐呭閮芥槸ASCII瀛楃闆嗕腑鍙互鍒楀嵃鐨勫瓧鍏,鎵浠ュ悕绉颁腑鍚湁Printable銆傚ぇ浣撴牸寮忎负: =A1A=B1z=A6n=A1I=A7=DA=A6b=BA=F4=B8=F4=A4W =B1o... =E5==...
  • 鐢ㄩ偖绠卞彂閫word鏂囨。,瀵规柟鐪嬪埌鐨勬槸涔辩爜,鎬庝箞鍥炰簨?
    绛旓細瑙g爜鍔炴硶:鐢‥-mail杞欢,閫夋嫨缂栫爜涓Base64 閫夐」灏卞彲瑙g爜,瑙g爜鍚庝細娑堥櫎涔辩爜銆 QpencodeQP:鍏ㄧО鈥淨uoted-Printable Content-Transfer-Encoding鈥濄傚洜涓鸿繖绉嶆牸寮忛偖浠剁殑鍐呭閮芥槸ASCII瀛楃闆嗕腑鍙互鎵撳嵃鐨勫瓧绗,鎵浠ュ悕绉颁腑鍚湁Printable銆傚ぇ浣撴牸寮忎负: =A1A=B1z=A6n=A1I=A7=DA=A6b=BA=F4=B8=F4=A4W =B1o... =E5==...
  • java base64decoder
    绛旓細void main(String[] args) throws Exception {         String str = "hello word";         BASE64Encoder base64Encoder&...
  • 鍚勪綅楂樻墜,鏁戞晳灏忓コ瀛愭垜鐨勬枃浠跺惂!~~~鏈夋偓璧忓垎鍝~~
    绛旓細瑙g爜鍔炴硶:鐢‥-mail杞欢,閫夋嫨缂栫爜涓Base64 閫夐」灏卞彲瑙g爜,瑙g爜鍚庝細娑堥櫎涔辩爜銆 QpencodeQp:鍏ㄧО鈥淨uoted-Printable Content-Transfer-Encoding鈥濄傚洜涓鸿繖绉嶆牸寮忛偖浠剁殑鍐呭閮芥槸 ASCII瀛楃闆嗕腑鍙互鎵撳嵃鐨勫瓧绗,鎵浠ュ悕绉颁腑鍚湁Printable銆傚ぇ浣撴牸寮忎负: =A1A=B1z=A6n=A1I=A7=DA=A6b=BA=F4=B8=F4=A4W =B1o... =E5==...
  • 鐢佃剳涔辩爜
    绛旓細閭欢鐨勭紪鐮佹柟寮忎富瑕佹湁:Uuencode銆Base64 encode銆丵P-encode銆丅INHEX绛夈傚鏋淓mail杞欢涓嶈兘璇嗗埆閭欢鐨勭紪鐮佹柟娉,灏变細鏄剧ず閭欢鏃跺嚭鐜颁贡鐮併傚洜姝,浣犺兘鏍规嵁閭欢涓殑鍏抽敭瀛楃鍒ゆ柇缂栫爜鏂规硶,閫夊彇鍚堥傜殑瑙g爜杞欢杩涜瑙g爜銆 (1)銆丵pencodeQP缂栫爜 璇ョ紪鐮佸叏绉扳淨uoted-Printable Content-Transfer-Encoding鈥,鍥犱负杩欑鏍煎紡閭欢鐨勫唴瀹归兘...
  • Postgresql+Access鐨勯棶棰
    绛旓細鏂规涓锛氬鏋 base64 杞崲鍓嶇殑澶у皬, 灏忎簬 澶囨敞瀛楁 涓婇檺鐨勮瘽.閭d箞杩樻槸鍙互鐩存帴鎻掑叆鐨.鍥犱负鏂囨湰涔嬩腑鐨勨樺緢澶, 鍙互閫氳繃 涓や釜 ' 涔熷氨鏄 '' 鏉ヨ浆涔夛紝浣夸箣鎴愬姛鐨勯氳繃 SQL 璇彞锛屾彃鍏ュ埌琛ㄤ腑銆傛柟妗堜簩锛氬鏋 base64 杞崲鍓嶇殑澶у皬锛 灏卞ぇ浜 澶囨敞瀛楁鐨勪笂闄愪簡锛岄偅涔堝皾璇曚娇鐢ㄤ笅闈㈡暟鎹被鍨嬬殑涓绉嶏細...
  • 扩展阅读:base64怎样转成图片 ... apk1.1.1文件怎么打开 ... base64在线解码网站 ... base64在线转换器 ... base64官网 ... 怎么把图片转成base64 ... base apk 1.1.1怎么打开 ... java文件转base64 ... base解密网站 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网