PB11.5做的一个web应用,包括了dw的打印,用到了PDF虚拟打印机,问题是文件一旦创造建,当客户第二次点打印的时候就提示没有权限,关闭应用。我试着把服务器端的PDF缓存给删除了就好了。通过什么代码能让客户端在打印完PDF文件后就自动将期删除?我试了filedelete()不好用。。。等下上图
------解决方案--------------------
string ls_file, ls_url, ls_path
string ls_name = "mamis", ls_net = "mamis" //比方说你的虚拟目录为mamis
ls_file = "MyReport" + string(now(), "HHMMSS") + ".pdf"
if FileExists(ls_file) then
FileDelete(ls_file)
end if
if idw_data.SaveAs(ls_file, PDF!, TRUE) <> -1 then
#IF DEFINED PBWEBFORM THEN
ls_url = System.Web.HttpContext.Current.Request.Url.tostring()
ls_path = MapVirtualPath(ls_file)
long ll_pos, ll_next
ll_pos = pos(ls_url, "/" + ls_name + "/")
if ll_pos > 0 then
ls_url = left(ls_url, ll_pos - 1) + "/"
ll_next = pos(ls_path, ls_net + "_root")
if ll_next > 0 then
ls_url += mid(ls_path, ll_next)
ll_pos = pos(ls_url, '\')
do while ll_pos > 0
ls_url = left(ls_url, ll_pos - 1) + '/' + mid(ls_url, ll_pos + 1)
ll_pos = pos(ls_url, '\')
loop
shl_1.url = ls_url
end if
end if
ls_file = GetDownloadFileUrl(ls_file, false)
shl_2.url = ls_file
#END IF
else
close(this)
end if
return 1