asp.net打印功能上传到服务器后不能实现

hello_web1 2012-05-24 10:27:46
在本地IIS发布后测试没有问题,上传到服务器 一到打印那 就一直处于加载中,不动弹了,百度了很多方法 都不管用,请大家帮吗一下啦。
...全文
156 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
琰盏 2012-11-15
  • 打赏
  • 举报
回复
亲,我也出现同样的问题了,VS08下调试一点问题都没有,但是发布后点击了打印按钮后没有反应,进度条一直在走,解决了两天了。。。。各种说法,有人说是IIS调用外部接口需要往系统文件夹下写日志,但是IIS没有访问系统文件夹权限所以卡在那里,关键是现在也不知道在哪个系统文件夹下写。
phoebuswei 2012-11-12
  • 打赏
  • 举报
回复
虚拟空间吧?
loveyi419 2012-11-12
  • 打赏
  • 举报
回复
我也出现这个问题了,怎么解决啊
hello_web1 2012-05-24
  • 打赏
  • 举报
回复
saveAs方法那还没问题 能够保存文档成功,就是到了打印那 出不来了。呃 来个高手拯救一下把
hello_web1 2012-05-24
  • 打赏
  • 举报
回复
int id =Convert.ToInt32(Request.QueryString["id"]);
MOrder order = new OrderManage().SelectById(id);
string gdsNum = new GDSManage().SelectById(order.GdsId).GdsNum;
_Document wDoc = null; //--word文档
_Application wApp = null; //--word进程
Application thisApplication = new ApplicationClass();
wApp = thisApplication;

string tmpDocFile = Server.MapPath("~/Tem/") + "\\"+gdsNum+".doc"; //模板路径
object templatefile = tmpDocFile;
object missing = Type.Missing;
wDoc = wApp.Documents.Add(ref templatefile, ref missing, ref missing, ref missing); //在现有进程内打开文档
wDoc.Activate(); //当前文档置前

List<string> findText = new List<string>();
List<string> replaceText = new List<string>();

findText.Add("{Num}");
findText.Add("{gdsName}");
findText.Add("{createTime}");
findText.Add("{userName}");
findText.Add("{jianhuName}");
findText.Add("{task}");

replaceText.Add(order.Num);
replaceText.Add(GetGDSNameById(order.GdsId));
replaceText.Add(order.CreateTime.ToString());
replaceText.Add(GetUserNamesByIds(order.UserIds));
replaceText.Add(GetUserNameById(order.JianhuId));
replaceText.Add(order.Task);
for (int k = 0; k < findText.Count; k++) {
//替换模版中的字符开始
object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; //替换所有
wApp.Selection.Find.ClearFormatting();
wApp.Selection.Find.Text = findText[k]; //替换的字符为#old#
wApp.Selection.Find.Format = false;
wApp.Selection.Find.Forward = true; //向前查找
wApp.Selection.Find.MatchByte = true;
wApp.Selection.Find.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindAsk;
wApp.Selection.Find.Replacement.ClearFormatting();
wApp.Selection.Find.Replacement.Text = replaceText[k]; //替换后新字符
wApp.Selection.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref replaceAll, ref missing, ref missing, ref missing, ref missing);
}

//一般我们要在模版内插入图片,这个位置是事先定好的,我们在模版内使用字符串“#Image#”来代替

string FileName = Server.MapPath("~/upload/") + "\\" + GetUserPicById(order.PdUserId); //另存为的路径
object LinkToFile = false;
object SaveWithDocument = true;

wApp.Selection.Find.ClearFormatting();
wApp.Selection.Find.Text = "{pic}";
wApp.Selection.Find.Format = false;
wApp.Selection.Find.Forward = true;
wApp.Selection.Find.MatchByte = true;
wApp.Selection.Find.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindAsk;

if (wApp.Selection.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing))
{
wApp.Selection.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref missing);
}
wApp.Selection.Find.ClearFormatting();
wApp.Selection.Find.Text = "{pic2}";
wApp.Selection.Find.Format = false;
wApp.Selection.Find.Forward = true;
wApp.Selection.Find.MatchByte = true;
wApp.Selection.Find.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindAsk;

if (wApp.Selection.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing))
{
wApp.Selection.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref missing);
}
//插入图片结束 , 如果有多个图片需要替换,循环该模块即可

object background = false; //这个很重要,否则关闭的时候会提示请等待Word打印完毕后再退出,加上这个后可以使Word所有
object filename = Server.MapPath("upload") + "\\" + order.Num + ".doc"; //另存为的路径
wDoc.SaveAs(ref filename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref

missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
wDoc.PrintOut(ref background, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref

missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,

ref missing);
object saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges;
wDoc.Close(ref saveOption, ref missing, ref missing); //关闭当前文档,如果有多个模版文件进行操作,则执行完这一步后接着执行打开Word文档的方法即可
saveOption = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
wApp.Quit(ref saveOption, ref missing, ref missing); //关闭Word进程
DelFile(order.Num);
Response.Redirect("pdy/OrderManage.aspx");
hello_web1 2012-05-24
  • 打赏
  • 举报
回复
呃,这么冷清啊。我的问题啊 折磨死了。

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧