以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  ftp 文件 另存 打开 报错.  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=145021)

--  作者:ljh29206
--  发布时间:2020/1/6 11:54:00
--  ftp 文件 另存 打开 报错.

BeforeOpenFile 事件


 If e.filename.Contains(".pdf") Then
    Dim ftp As New FTPClient
    ftp.host=vars("FTP_ip地址")
    ftp.Account =vars("FTP_账号")
    ftp.password =vars("FTP_密码")
    ftp.Port= vars("FTP_端口")
  \'  ftp.RootDir = "\\图片文件\\" & n \'设置根目录
    If ftp.Download(e.FileName,"e:\\downpdf.pdf") = True Then
        Dim fn As String = "e:\\downpdf1.pdf"
        e.FileName = fn
    End If
End If

路径报错   ,打开不了文件,   是不是 ftp文件列  不能用本来路径打开?


--  作者:有点蓝
--  发布时间:2020/1/6 12:00:00
--  
名称不一致呀

  If ftp.Download(e.FileName,"e:\\downpdf.pdf") = True Then
        Dim fn As String = "e:\\downpdf1.pdf"
        e.FileName = fn
    End If
End If

--  作者:ljh29206
--  发布时间:2020/1/6 12:06:00
--  
 篮板  我没把代码贴全!

If e.filename.Contains(".pdf") Then
    Dim ftp As New FTPClient
    ftp.host=vars("FTP_ip地址")
    ftp.Account =vars("FTP_账号")
    ftp.password =vars("FTP_密码")
    ftp.Port= vars("FTP_端口")
  \'  ftp.RootDir = "\\图片文件\\" & n \'设置根目录
    If ftp.Download(e.FileName,"e:\\downpdf.pdf") = True Then
        Dim fn As String = "e:\\downpdf1.pdf"
        
        Dim waterMarkName As String = "TBFC  "  & User_ReName  & " " & Date.now
        Dim reader As New iTextSharp.text.pdf.PdfReader("e:\\downpdf.pdf")
        
        Dim msWater As new io.FileStream(fn, io.FileMode.Create)
        
        Dim total  As Integer = reader.NumberOfPages
        Dim pdfStamper As new iTextSharp.text.pdf.PdfStamper(Reader, msWater)
        
        Dim psize = Reader.GetPageSize(1)
        Dim width = psize.Width
        Dim height = psize.Height
        Dim gs As new iTextSharp.text.pdf.PdfGState
        Dim basefont  As iTextSharp.text.pdf.BaseFont = iTextSharp.text.pdf.BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\SIMYOU.TTF", iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED)
        For i As Integer = 1 To total
            
            Dim waterContent = pdfStamper.GetOverContent(i)
            waterContent.SetGState(gs)
            waterContent.BeginText()
            waterContent.SetColorFill( iTextSharp.text.BaseColor.RED)
            waterContent.SetFontAndSize(basefont, 28)
            waterContent.SetTextMatrix(0, 0)
            waterContent.ShowTextAligned(iTextSharp.text.Element.ALIGN_CENTER, waterMarkName, width / 2, height / 2, 55)
            waterContent.EndText()
        Next
        
        pdfStamper.close
        reader.Close()    \'这里 加了水印 再另存的\'

        e.FileName = fn    \'但是来到这里  就报错了  ,说 路径 有问题
    End If
End If

图片点击可在新窗口打开查看此主题相关图片如下:捕获.jpg
图片点击可在新窗口打开查看


\'----------------------------------------------------\'
If e.filename.Contains(".pdf") Then
    Dim ftp As New FTPClient
    ftp.host=vars("FTP_ip地址")
    ftp.Account =vars("FTP_账号")
    ftp.password =vars("FTP_密码")
    ftp.Port= vars("FTP_端口")
  \'  ftp.RootDir = "\\图片文件\\" & n \'设置根目录
    If ftp.Download(e.FileName,"e:\\downpdf.pdf") = True Then
        Dim fn As String = "e:\\downpdf.pdf"
        e.FileName = fn
    End If
End If
\'----------------------------------------------------\'

直接这么写 也一样的错误
[此贴子已经被作者于2020/1/6 12:13:19编辑过]

--  作者:有点蓝
--  发布时间:2020/1/6 13:44:00
--  
如果是远程ftp的文件,e.FileName 也必须是远程文件,而不能是本机文件
--  作者:ljh29206
--  发布时间:2020/1/6 13:50:00
--  
 这样哇 , 我现在的需求 是

把 pdf  的 源文件  加入水印, 然后另存,

在打开另存为的文件.

像这种情况,该怎么处理好点呢?


难道要下载处理完,然后又上传上去,再读取?
[此贴子已经被作者于2020/1/6 14:02:21编辑过]

--  作者:有点蓝
--  发布时间:2020/1/6 14:24:00
--  
那就只能是做个按钮,自己下载文件,然后打开,不要使用文件管理器界面