CN103955401A - Method for optimizing on-line preview of electronic document - Google Patents

Method for optimizing on-line preview of electronic document Download PDF

Info

Publication number
CN103955401A
CN103955401A CN201410175058.XA CN201410175058A CN103955401A CN 103955401 A CN103955401 A CN 103955401A CN 201410175058 A CN201410175058 A CN 201410175058A CN 103955401 A CN103955401 A CN 103955401A
Authority
CN
China
Prior art keywords
thread
document
server
convert
soffice
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410175058.XA
Other languages
Chinese (zh)
Inventor
张晓东
毕永政
陈万江
王玉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NANJING CMODES SOFTWARE INTEGRATION CO Ltd
Original Assignee
NANJING CMODES SOFTWARE INTEGRATION CO Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NANJING CMODES SOFTWARE INTEGRATION CO Ltd filed Critical NANJING CMODES SOFTWARE INTEGRATION CO Ltd
Priority to CN201410175058.XA priority Critical patent/CN103955401A/en
Publication of CN103955401A publication Critical patent/CN103955401A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to on-line preview of an electronic document, in particular to a method for optimizing the on-line preview of the electronic document. The method comprises the following steps: using JodConverter to invoke OpenOffice.org service to convert the electronic document to be previewed into a PDF document, then using pdf2swf in SwfTools to convert the PDF document into a Flash document, setting the number of ports according to the number of server CPU cores, opening soffice.bin process according to a port number, and setting the maximum number of the executable tasks of each soffice. bin process according to the size of the actual available memory of the server. The method further comprises the steps of setting the maximum operational thread count in a thread pool according to the actual number of cores of the CPU of the server, creating a thread pool which can reuse a fixed thread count according to the maximum thread count, circularly executing the thread in the thread pool, and storing the thread in wait. Through the method provided by the invention, under the condition that a plurality of converting tasks are performed at the same time, CPU resources of the server can be effectively prevented from exhausting, and the memory of the server can be effectively prevented from overflowing.

Description

The method that the online preview of a kind of electronic document is optimized
Technical field
The present invention relates to the online preview of electronic document, relate in particular to the method that the online preview of a kind of electronic document is optimized, belong to computer information management technical field.
Background technology
The online preview of document can be user's reading experience efficiently of providing convenience, and user, without downloading original, without the needed software environment of reading documents is installed, only need to use web browser can realize online rapid preview.In addition, for document information provider, the online preview of document can prevent that original is tampered and steals to a certain extent, has improved the security of information sharing.
The solution that the at present online preview of document is mainly taked is, first converts Office file or text to PDF file, then pdf document converted to after SWF file, uses Flash player to represent to user at browser end.
The solution that original is transferred to pdf document has three kinds at present.The first is to call virtual printer, and original is printed as to pdf document.This scheme need to be installed Office software and virtual printer at server end, and transfer process is wayward, uses inconvenience.The second is with Jacob or JCom, to call MS Office or WPS Office API to realize pdf document conversion, this scheme needs server end that the MicroSoft Office software that needs are paid and used is installed, and can only be deployed in windows platform, professional platform independence is bad.The third scheme is with JodConverter, to call OpenOffice.org to serve to carry out pdf document conversion, is a kind of many methods of using at present.OpenOffice.org is a free Office software, and it can install under Windows and Linux platform, has good professional platform independence.
Convert pdf document to Flash file, mainly with the pdf2swf instrument in SwfTools, realize at present, adopt the mode of Java fill order row to carry out file layout conversion.The shortcoming of this scheme is convert task of every unlatching, and system will be opened a process, may make server performance sharply decline when convert task amount increases.This also becomes the performance bottleneck running into while realizing the online preview function of document.
And, when solution is before made mistakes in document transfer process, abandoning again carrying out document conversion, user or service provider can only again be uploaded document and again carry out document conversion, have reduced user's experience.
Therefore, how, for user's online preview service of electronic document efficiently of providing convenience, solve the performance bottleneck producing when generating preview file simultaneously, and the processing of document conversion after makeing mistakes, a problem demanding prompt solution become.
Summary of the invention
The invention discloses the method that the online preview of a kind of electronic document is optimized, solved the problem that in multitask situation, server performance declines in the document converting process that generates preview file.
For achieving the above object, the technical scheme that the present invention takes is: the method that the online preview of a kind of electronic document is optimized, described method is used JodConverter to call OpenOffice service and is converted the e-file of wanted preview to pdf document, then use the pdf2swf in SwfTools to convert pdf document to Flash file, it is characterized in that comprising the following steps:
The first step: set port number according to server CPU core quantity, the port number setting is not more than server CPU core quantity;
Second step: JodConverter opens soffice.bin process according to port numbers when starting OpenOffice service, and each soffice.bin process is used different port numbers.
For further Optimized Service device performance, said method also comprises:
The first step: can use memory size that the executable maximum number of tasks of each soffice.bin process is set according to server reality;
Second step: when the performed number of tasks of soffice.bin process surpasses the maximum number of tasks of JodConverter setting, JodConverter closes and re-create new process by this process.
In order further to solve the problem that in document converting process, in multitask situation, server performance declines, said method can also comprise: the method for using the pdf2swf in SwfTools to convert pdf document to Flash file comprises the following steps:
The first step: the maximum thread that can move in thread pool is set according to check figure in the CPU reality of server;
Second step: the thread pool that creates a reusable static line number of passes according to maximum thread;
The 3rd step: with the thread in the unbounded queue mode active thread pond of sharing;
The 4th step: the thread of storage in waiting for, to guarantee that all convert task can both be carried out.
In order to solve when conversion makes mistakes because the error message that output process produces not in time causes process blocking, thereby the problem that causes the follow-up convert task of waiting in line normally to carry out, aforesaid way also can comprise: create a thread, this thread is used for exporting the issuable error message of transfer process, prevents the thread block problem of makeing mistakes and causing because of conversion.
In order to solve when document conversion makes mistakes, need user or server again to upload the problem that document is changed again, said method also can comprise the following steps:
The first step: the maximal value that document convert failed number of times is set.
The first step: state variable identification transition status is set, when task starts, by variable set up for just at transition status; After task finishes, by variable set up for converting; In document transfer process, system gives user feedback according to state variable.
The 3rd step: accumulative total convert failed number of times in document transfer process, when the frequency of failure does not surpass the maximal value arranging, when document convert failed, system is initiatively changed again; When the frequency of failure surpasses the maximal value arranging, prompting user contact management person.
In the situation that server adopts multi-core CPU, each soffice.bin process can wolfishly be used up the resource of a CPU core when carrying out convert task, the inventive method is controlled the soffice.bin number of processes of opening and is surpassed CPU core quantity to prevent soffice.bin number of processes according to the number of cores of server CPU, thereby prevents from causing because server resource exhausts paralysis.The internal memory shared due to soffice.bin process can increase along with the increase of the quantity of executing the task, when the number of tasks of having carried out surpasses the maximum number of tasks of JodConverter setting, JodConverter closes and re-creates by this process the internal memory that new process can discharge process accumulation before, thus the generation of avoiding internal memory to overflow.Use the pdf2swf in SwfTools as pdf document, to turn the instrument of SWF file, while starting convert task in the mode of action command row, convert task of every execution, capital creates a pdf2swf.exe process, this process also can wolfishly be used a kernel of CPU, the inventive method is configured the maximum thread amount that can move in thread pool according to check figure in the reality of the CPU of server, can make full use of under the prerequisite of server resource in assurance, pdf2swf number of processes is controlled, prevented from causing paralysis because server resource exhausts.The maximal value of document convert failed number of times is set and records document convert failed number of times, when the frequency of failure reaches maximal value, system is not initiatively changed again, and again uploads document without user or server, has improved user's experience.
Embodiment
This method is carried out pdf2swf instrument in pdf document conversion and use SwfTools and pdf document is converted on the basis of the online method for previewing of electronic document of Flash file, proposed the method that its document conversion performance is optimized using JodConverter to call OpenOffice.org service.According to embodiment, the present invention is described in further detail below.
Server CPU core quantity is 4 cores, and while inside saving as 8G, it is 8100 and 8101 that configuration OpenOffice serves spendable port numbers, and the executable maximum number of tasks of configuration JodConverter is 50.The set basis server of maximum number of tasks can be used memory size, file size to be converted and the complexity of file content to make a decision.The memory size using due to soffice.bin can increase along with several increase of executing the task, its instantaneous maximum memory use amount when carrying out convert task also significantly increases, if what maximum number of tasks was arranged is excessive, may cause soffice.bin to take too many internal memory.When reality is used, should the internal memory service condition of soffice.bin be monitored and be added up according to the actual service condition of system, then change the setting of maximum number of tasks.
When startup of server loading system, number configuration of JodConverter read port, opens corresponding soffice.bin process for each port numbers, and this process is completed automatically by JodConverter.Soffice.bin process is the about 12M of committed memory under initial idle condition.Use the file of different sizes to carry out a plurality of convert task, two soffice.bin processes are carried out convert task simultaneously simultaneously, and each process takes the kernel of a CPU, and CPU usage is 25%, and memory usage is relevant with document content and document size.Along with the increase of the quantity of executing the task, the internal memory use amount under soffice.bin process idle condition is also increasing by a small margin.
The number of tasks of carrying out when soffice.bin process surpasses 50, when carrying out the 51st task, JodConverter finishes current soffice.bin process, creates new process and continue to carry out convert task, newly creates memory usage under process idle condition and returns to again 12M left and right.This process is completed automatically by JodConverter.
Server CPU core quantity is 4 cores, and while inside saving as 8G, it is 2 that the maximum thread that can move in thread pool is set.Maximum thread is set to 2, is because distributed two port numbers to soffice.bin, and when soffice.bin and pdf2swf move simultaneously, CPU has approached 100%.If maximum thread be set to 4 or more than, when have when surpassing 4 convert task and moving simultaneously, CPU usage can reach 100%, will make like this cpu resource exhaust, and has a strong impact on the normal use of other functions in system.
When system is moved, the thread pool that establishment maximum thread is 2.The thread that completes pdf and turn swf task is passed to thread pool as parameter, by thread pool, start this thread.The thread pool administrative class java.util.concurrent.Executors that uses Java JDK to provide, such can create the thread pool of difference in functionality characteristic; Use Executors.newFixedThreadPool (int nThreads) to create the thread pool of a reusable static line number of passes, in the unbounded queue mode of sharing, move these threads, nThreads parameter is used for controlling the quantity of running status thread in thread pool.Its inner LinkedBlockingQueue<Runnable> that adopts deposits the thread of wait, can guarantee as much as possible that so all convert task can be carried out.
In Pdf2SwfThread thread, carry out convert task, DealWithOutputThread is responsible for exporting the normal output content in transfer process, and DealWithErrorThread is responsible for exporting the error message producing in transfer process.
When conversion makes mistakes for document, need user or server again to upload the problem that document is changed again, embodiment is as follows:
(1), for document A to be converted, it is 3 times that the maximum frequency of failure is set;
(2) document information of A is encapsulated in an object, dress is set and changes state variable isConverting, convert failed time number variable failureTimes(is set and is defaulted as 0), object information should be to leave buffer memory in, or in can the storer of persistence, with the value of Guarantee Status variable, do not lose;
(3) when document starts to change, isConverting is set to true, represents to change, if now user asks preview A document, to user's prompting " preparing can preview resource, please wait a moment ";
(4) if made a mistake in transfer process, variable failureTimes cumulative 1, and be false by isConverting variable set up, if now user asks preview A document, system judges that in the object of depositing A document information, isConverting is false, and failureTimes is greater than 0, and prompting user " is attempting again obtaining preview resource, just a moment,please ", now, system is opened document convert task again, again A document is carried out to format conversion, if failureTimes is more than or equal to 3, abandon again changing, prompting user " obtain can preview resource failure, please contact management person ",
(5) when user asks preview A document, system judges that in the object of depositing A document information, isConverting is false, and failureTimes is less than 3, can to user, check by preview Resource Supply.

Claims (5)

1. the method that the online preview of an electronic document is optimized, described method is used JodConverter to call OpenOffice service and is converted the e-file of wanted preview to pdf document, use the pdf2swf in SwfTools to convert pdf document to Flash file, it is characterized in that comprising the following steps:
(1) according to server CPU core quantity, set port number, the port number setting is not more than server CPU core quantity;
(2) JodConverter opens soffice.bin process according to port numbers when starting OpenOffice service, and each soffice.bin process is used different port numbers.
2. the method that the online preview of electronic document according to claim 1 is optimized, characterized by further comprising following steps:
(1) according to server reality, can use memory size that the executable maximum number of tasks of each soffice.bin process is set;
(2) when the performed number of tasks of soffice.bin process surpasses the maximum number of tasks of JodConverter setting, JodConverter closes and re-creates new process by this process.
3. the method that the online preview of electronic document according to claim 1 is optimized, characterized by further comprising: the method for using the pdf2swf in SwfTools to convert pdf document to Flash file comprises the following steps:
(1) according to check figure in the CPU reality of server, the maximum thread that can move in thread pool is set;
(2) according to maximum thread, create the thread pool of a reusable static line number of passes;
(3) with the thread in the unbounded queue mode active thread pond of sharing;
(4) thread of storage in waiting for, to guarantee that all convert task can both be carried out.
4. the method that the online preview of electronic document according to claim 3 is optimized, its spy is also to comprise: create a thread, this thread is used for exporting the issuable error message of transfer process.
5. the method that online preview is optimized according to the electronic document described in claim 1,2,3 or 4, characterized by further comprising:
(1) maximal value of document convert failed number of times is set;
(2) state variable identification transition status is set, when task starts, by variable set up for just at transition status; After task finishes, by variable set up for converting; In document transfer process, system gives user feedback according to state variable;
(3) accumulative total convert failed number of times in document transfer process, when the frequency of failure does not surpass the maximal value arranging, when document convert failed, system is initiatively changed again; When the frequency of failure surpasses the maximal value arranging, prompting user contact management person.
CN201410175058.XA 2014-04-29 2014-04-29 Method for optimizing on-line preview of electronic document Pending CN103955401A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410175058.XA CN103955401A (en) 2014-04-29 2014-04-29 Method for optimizing on-line preview of electronic document

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410175058.XA CN103955401A (en) 2014-04-29 2014-04-29 Method for optimizing on-line preview of electronic document

Publications (1)

Publication Number Publication Date
CN103955401A true CN103955401A (en) 2014-07-30

Family

ID=51332677

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410175058.XA Pending CN103955401A (en) 2014-04-29 2014-04-29 Method for optimizing on-line preview of electronic document

Country Status (1)

Country Link
CN (1) CN103955401A (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105488169A (en) * 2015-11-30 2016-04-13 福建亿榕信息技术有限公司 Multi-process file conversion method and apparatus
CN105630754A (en) * 2015-12-31 2016-06-01 上海精学锐信息科技有限公司 Method and device for controlling document conversion
CN105930217A (en) * 2016-04-15 2016-09-07 上海斐讯数据通信技术有限公司 Thread optimization system and method
CN107168935A (en) * 2017-05-25 2017-09-15 山大鲁能信息科技有限公司 The online code-transferring method of document and system
CN107885735A (en) * 2017-11-21 2018-04-06 语联网(武汉)信息技术有限公司 A kind of unrelated document translation method and system of form
CN104391742B (en) * 2014-11-11 2019-03-01 小米科技有限责任公司 Optimizing application method and apparatus
CN109710900A (en) * 2018-12-25 2019-05-03 中电福富信息科技有限公司 A kind of system and method for realizing document unified management in server end
CN111159099A (en) * 2019-11-15 2020-05-15 杭州数梦工场科技有限公司 Online data generation method and device, electronic equipment and storage medium
CN111625332A (en) * 2020-05-21 2020-09-04 杭州安恒信息技术股份有限公司 Java thread pool rejection policy execution method and device and computer equipment
US10901607B2 (en) 2016-06-24 2021-01-26 Microsoft Technology Licensing, Llc Carouseling between documents and pictures
CN116089362A (en) * 2023-03-06 2023-05-09 北京微吼时代科技有限公司 Document conversion method and system, live broadcast system, storage medium and electronic device
CN116861847A (en) * 2023-06-21 2023-10-10 三峡高科信息技术有限责任公司 Online Office file previewing method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110257941A1 (en) * 2010-04-19 2011-10-20 Sebastian Magro System and automated method for creating drawings online for product manufacturing
CN102254005A (en) * 2011-07-15 2011-11-23 苏州阔地网络科技有限公司 Method for transforming and displaying document on webpage
CN102662985A (en) * 2012-03-14 2012-09-12 南京新与力文化传播有限公司 A method for previewing OFFICE files on a remote server
CN102750391A (en) * 2012-07-06 2012-10-24 深圳市远行科技有限公司 File previewing method and system based on Hadoop distribution type

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110257941A1 (en) * 2010-04-19 2011-10-20 Sebastian Magro System and automated method for creating drawings online for product manufacturing
CN102254005A (en) * 2011-07-15 2011-11-23 苏州阔地网络科技有限公司 Method for transforming and displaying document on webpage
CN102662985A (en) * 2012-03-14 2012-09-12 南京新与力文化传播有限公司 A method for previewing OFFICE files on a remote server
CN102750391A (en) * 2012-07-06 2012-10-24 深圳市远行科技有限公司 File previewing method and system based on Hadoop distribution type

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
DOUBLESPOUT: "让node.js充分利用多核服务器的性能", 《HTTPS://CNODEJS.ORG/TOPIC/4F16442CCAE1F4AA270010AB》 *
SWOOLE文档中心: "swoole_server->set-Swoole扩展", 《HTTP://WIKI.SWOOLE.COM/WIKI/PAGE/13.HTML》 *
冯琦峰,罗付军: "基于Flash技术的文档浏览和音视频播放的设计原理及实现", 《网络与信息》 *
方腾飞: "聊聊并发(三)-Java线程池的分析和使用", 《HTTP://WWW.INFOQ.COM/CN/ARTICLES/JAVA-THREADPOOL》 *

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104391742B (en) * 2014-11-11 2019-03-01 小米科技有限责任公司 Optimizing application method and apparatus
CN105488169A (en) * 2015-11-30 2016-04-13 福建亿榕信息技术有限公司 Multi-process file conversion method and apparatus
CN105630754A (en) * 2015-12-31 2016-06-01 上海精学锐信息科技有限公司 Method and device for controlling document conversion
CN105930217A (en) * 2016-04-15 2016-09-07 上海斐讯数据通信技术有限公司 Thread optimization system and method
US10901607B2 (en) 2016-06-24 2021-01-26 Microsoft Technology Licensing, Llc Carouseling between documents and pictures
CN107168935A (en) * 2017-05-25 2017-09-15 山大鲁能信息科技有限公司 The online code-transferring method of document and system
CN107885735A (en) * 2017-11-21 2018-04-06 语联网(武汉)信息技术有限公司 A kind of unrelated document translation method and system of form
CN107885735B (en) * 2017-11-21 2021-05-04 语联网(武汉)信息技术有限公司 Format-independent document translation method and system
CN109710900A (en) * 2018-12-25 2019-05-03 中电福富信息科技有限公司 A kind of system and method for realizing document unified management in server end
CN111159099A (en) * 2019-11-15 2020-05-15 杭州数梦工场科技有限公司 Online data generation method and device, electronic equipment and storage medium
CN111159099B (en) * 2019-11-15 2023-08-22 杭州数梦工场科技有限公司 Online data generation method and device, electronic equipment and storage medium
CN111625332A (en) * 2020-05-21 2020-09-04 杭州安恒信息技术股份有限公司 Java thread pool rejection policy execution method and device and computer equipment
CN116089362A (en) * 2023-03-06 2023-05-09 北京微吼时代科技有限公司 Document conversion method and system, live broadcast system, storage medium and electronic device
CN116861847A (en) * 2023-06-21 2023-10-10 三峡高科信息技术有限责任公司 Online Office file previewing method and system
CN116861847B (en) * 2023-06-21 2024-02-13 三峡高科信息技术有限责任公司 Online Office file previewing method and system

Similar Documents

Publication Publication Date Title
CN103955401A (en) Method for optimizing on-line preview of electronic document
US9092230B2 (en) Configuration of componentized software applications
JP4834566B2 (en) Apparatus and method for forcibly terminating a thread blocked by I / O work
WO2021022713A1 (en) Distributed module update method, device, and storage medium
CN111414256B (en) Application program process derivation method, system and medium based on kylin mobile operating system
CN103761474B (en) A kind of method and device for monitoring the execution time of a monitoring method
US10803413B1 (en) Workflow service with translator
JP6464288B2 (en) Program, apparatus, server, and storage medium for deleting a cloud host in a cloud computing environment
US20110205588A1 (en) Network system, network system control method, and storage medium
JP2014021953A (en) Information processor, image processor, start-up control method and start-up control program
US20210334118A1 (en) Opening local files in remote applications
JP7159887B2 (en) Virtualization base and scaling management method of the virtualization base
CN103294485A (en) Web service packaging method and Web service packaging system both used for ABINIT parallel computing system
JP4696151B2 (en) Information processing apparatus and memory management method
JP2021153331A (en) Method, device, apparatus, and medium for smart contract implementation of block chain
JP7102216B2 (en) program
JP2024045498A (en) Application program, storage medium, control method, and information processor
CN105701406A (en) Method of Android platform for running traditional payment application
JP2015005097A (en) Electronic equipment, control device, and program
US11782881B2 (en) Recommending remotely executed applications for opening files
WO2021139113A1 (en) Method and apparatus for signing transaction data, computer device, and storage medium
CN112564979B (en) Execution method and device of construction task, computer equipment and storage medium
JP2009116618A (en) Information processing apparatus
TW201500937A (en) Method and system of intelligent cloud migration
CN114816662A (en) Container arrangement method and system applied to Kubernetes

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20140730