Sejda合并CSV文件列表名称中的PDF

时间:2017-04-04 09:25:05

标签: pdf batch-processing pdf-manipulation sejda

我最近安装了PlaygroundPage.current.needsIndefiniteExecution = true let cq = DispatchQueue(label: "concurrent.queue", attributes: .concurrent) let cq2 = DispatchQueue(label: "concurent.queue2", attributes: .concurrent) let sq = DispatchQueue(label: "serial.queue") func codeFragment() { print("code Fragment begin") print("Task Thread:\(Thread.current.description)") let imgURL = URL(string: "http://stackoverflow.com/questions/24058336/how-do-i-run-asynchronous-callbacks-in-playground")! let _ = try! Data(contentsOf: imgURL) print("code Fragment completed") } func serialQueueSync() { sq.sync { codeFragment() } } func serialQueueAsync() { sq.async { codeFragment() } } func concurrentQueueSync() { cq2.sync { codeFragment() } } func concurrentQueueAsync() { cq2.async { codeFragment() } } func tasksExecution() { (1...5).forEach { (_) in /// Using an concurrent queue to simulate concurent task executions. cq.async { print("Caller Thread:\(Thread.current.description)") /// Serial Queue Async, tasks run serially, because only one thread that can be used by serial queue, the underlying thread of serial queue. //serialQueueAsync() /// Serial Queue Sync, tasks run serially, because only one thread that can be used by serial queue,one by one of the callers' threads. //serialQueueSync() /// Concurrent Queue Async, tasks run concurrently, because tasks can run on different underlying threads //concurrentQueueAsync() /// Concurrent Queue Sync, tasks run concurrently, because tasks can run on different callers' thread //concurrentQueueSync() } } } tasksExecution() 来从命令行合并pdf文件。

输入pdf文件的名称位于名为sedja-console的CSV文件中,如下所示:

filelist-inputs.csv

我需要一个输出pdf文件用于CSV文件列表名称的第一行,其他输出pdf文件用于第二行的第二行,其他输出用于第三行,等等......

我尝试了这样的命令行:

./Temp/source/046032.pdf,./Temp/source/048155.pdf
./Temp/source/049278.pdf,./Temp/source/050818.pdf,./Temp/source/052962.pdf
./Temp/source/052962.pdf,./Temp/source/054117.pdf

但是当我需要3个文件时,它只会创建一个名为字面~$ sejda-console merge -l filelist-inputs.csv -o ./Temp/target/merged[FILENUMBER####].pdf 的唯一文件:

merged[FILENUMBER####].pdf

我已经简化了问题,因为我需要在700个输出文件中合并超过3500个pdf文件。

1 个答案:

答案 0 :(得分:2)

Sejda获取CSV中的所有值并生成单个合并的PDF,Sejda中没有任何选项或设置来实现您的要求,您需要一些脚本来循环CSV行,创建一个CSV并将其送到Sejda。

输出文件名merged[FILENUMBER####].pdf实际上是使用的,因为PDF合并任务会生成一个输出文件,并且它需要一个显式的输出文件名。在生成多个输出PDF文件(拆分任务等)的任务中用作[CURRENTPAGE]参数时,[FILENUMBER]-p等前缀有效。