简体   繁体   English

如何同时将文件转换为PDF?

[英]How to convert files to PDF simultaneously?

I have a node.js web application and I want to be able to convert many documents (in the same time) to PDF . 我有一个node.js Web应用程序,我希望能够(同时)将许多文档转换为PDF In this moment I use libreoffice with a queue (The purpose of queue is to avoid infinite conversion for a file - if libreoffice cannot convert the file in a specific period of time then I kill the process). 在这一刻,我将libreoffice与一个队列一起使用(队列的目的是避免文件的无限转换-如果libreoffice无法在特定时间段内转换文件,则将libreoffice该进程)。 The problem is that if I have two users which upload files and both of them upload big files the second user must wait for the first one to finish. 问题是,如果我有两个上载文件的用户,而他们两个都上载大文件,则第二个用户必须等待第一个用户完成。

Is there any way to convert the files simultaneously? 有什么办法可以同时转换文件?

I am willing to replace libreoffice with another PDF converter. 我愿意用另一个PDF转换器替换libreoffice

Thank you in advance. 先感谢您。

One way to do multiple conversions at the same time is to just fire up multiple processes that are doing conversions. 同时进行多次转换的一种方法是仅启动正在进行转换的多个进程。 Then, whenever something is added to the queue, it would be handed off to the next available external process that is working on conversions. 然后,无论何时将任何内容添加到队列中,都会将其移交给正在进行转换的下一个可用外部流程。 Since the file conversion is likely a mix of CPU and disk I/O, you could experiment with the best number of conversion processes to maintain. 由于文件转换可能是CPU和磁盘I / O的混合,因此您可以尝试使用最佳数量的转换过程来维护。

There are a number of ways to manage the queue. 有多种方法可以管理队列。 If your node.js app was maintaining the queue, then it would be managing the process of handing off an item from the queue to the external process and keeping track of which external processes were free and ready for a new job. 如果您的node.js应用程序正在维护队列,那么它将管理将项目从队列移交给外部流程的过程,并跟踪哪些外部流程是空闲的并准备进行新工作。 If the queue was in a database or in the file system that all the external processes could read, then the external processes themselves could watch the queue. 如果队列位于所有外部进程都可以读取的数据库或文件系统中,则外部进程本身可以监视队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM