如何将pdf文件合并到一个文件中 [英] how to combine pdf files into one file

查看:110
本文介绍了如何将pdf文件合并到一个文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将pdf文件合并到一个文件中,在一个目录中我有一些我想要合并成1个文件的pdf文件



我使用以下代码:



 私人  Sub  Button1_Click( ByVal  sender  As  System。 Object  ByVal  e  As  System.EventArgs)句柄 Button1.Click 
Dim filePaths As String ()= System.IO.Directory.GetFiles(path)

For 每个 fileName 作为 [字符串] filePaths $中b $ b Dim targetFolder As String = path
Dim fi As System.IO.FileInfo(fileName)
' fi.CopyTo(System.IO.Path.Combine(路径,(fi.Name)& .pdf),True)
Label1.Text = filePaths.Length
alList.Add(fileName)
Next
CombineReport(alList,path)
结束 Sub

公开 共享 功能 CombineReport ( ByVal pdfFiles 作为 IList, ByVal pdfFile 作为 字符串作为 字符串
尝试
Dim sb 作为 System.Text.StringBuilder()
对于 每个 o 作为 对象 pdfFiles
sb.Append(o.ToString())
sb.Append(
下一步
sb.AppendFormat( cat output {0}允许打印dont_ask,pdfFile)
System.Diagnostics.Process.Start( C:\ WINDOWS \system32 \pdftk,sb.ToString())。WaitForExit()

返回 pdfFile
Catch ex 作为例外
投掷 ex
结束 尝试
结束 功能
结束





但是源代码没有什么变化,如果有人知道我出于这个问题请帮忙

解决方案

< blockquote>查看此代码



http://stackoverflow.com/questions/7157544/how-to-merge-multi-pdf-pages-into-single-page-can -be-using-itextsharp-or-net [ ^ ]


how to combine pdf files into one file, in a directory I have some pdf files that I want to combine into 1 file

I use the following code:

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim filePaths As String() = System.IO.Directory.GetFiles(path)
     
        For Each fileName As [String] In filePaths
            Dim targetFolder As String = path
            Dim fi As New System.IO.FileInfo(fileName)
            'fi.CopyTo(System.IO.Path.Combine(path, (fi.Name) & ".pdf"), True)
            Label1.Text = filePaths.Length
            alList.Add(fileName)
        Next
        CombineReport(alList, path)
    End Sub

    Public Shared Function CombineReport(ByVal pdfFiles As IList, ByVal pdfFile As String) As String
        Try
            Dim sb As New System.Text.StringBuilder()
            For Each o As Object In pdfFiles
                sb.Append(o.ToString())
                sb.Append(" ")
            Next
            sb.AppendFormat("cat output {0} allow printing dont_ask", pdfFile)
            System.Diagnostics.Process.Start("C:\WINDOWS\system32\pdftk", sb.ToString()).WaitForExit()
                        
            Return pdfFile
        Catch ex As Exception
            Throw ex
        End Try
    End Function
End Class



but the source code is not nothing changed, please help if anyone knows me out of this problem

解决方案

check this code

http://stackoverflow.com/questions/7157544/how-to-merge-multi-pdf-pages-into-single-page-can-be-using-itextsharp-or-net[^]


这篇关于如何将pdf文件合并到一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆