A multi-format electronic file intelligent preview method and device and equipment
By optimizing load balancing through Nginx reverse proxy and the Zunhaishao algorithm, the problems of long preview times for different file types and watermark anti-counterfeiting were solved, enabling efficient and secure online browsing of multi-format files and automatic watermark insertion, thus improving user experience and server performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, users need to process different file types through various software on the client, which results in long file preview times, high resource consumption, and affects the online preview experience, and makes it difficult to achieve watermark anti-counterfeiting.
By leveraging Nginx reverse proxy technology to optimize load balancing and combining it with the Zunhaishao algorithm, file format conversion and watermark insertion are achieved. A unified conversion format is used for previewing, reducing client dependency, supporting online browsing of multiple file formats, and achieving high-concurrency load balancing in the server cluster.
It improves the efficiency and security of file preview, reduces data distortion, enhances user experience, achieves load balancing under high concurrency, and supports online browsing of various file formats and automatic watermark anti-counterfeiting.
Smart Images

Figure CN115878572B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Nginx reverse proxy technology, and in particular to a method, apparatus, and device for intelligent previewing multi-format electronic documents. Background Technology
[0002] For most current file systems, if a user wants to preview the contents of a file, they generally need to open the file using various software on a client device. The client then performs display rendering processing based on different file types before the user can view the file's contents on the client's front-end page. Based on this file preview method, when a user wants to view different types of files, various software on the client device need to be invoked. Both file download and page rendering are often time-consuming, impacting the online preview experience and clearly failing to meet the user's expectations for file previewing.
[0003] Traditional methods of opening and rendering files of different types using various client-side software are resource-intensive, time-consuming, and complex, negatively impacting the online preview experience. Therefore, intelligent previewing and watermarking for multi-format electronic documents, adaptable to complex environments, has become a pressing issue in the industry. This system, however, can pre-decode and convert files during upload and cache the converted files. Subsequent users accessing the same format can directly preview the cached file without further conversion, significantly improving format conversion speed.
[0004] The IT technologies utilized by the system are highly mature, especially data transmission technology, Web, big data, and cloud services, which have made significant progress compared to the past. The performance of network equipment and servers has also been rapidly improved. All of these provide strong support for intelligent previewing of multi-format electronic documents and watermark anti-counterfeiting measures. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide a method, apparatus and device for intelligent previewing multi-format electronic archives, and to solve the shortcomings of the prior art in that it is difficult to directly preview different document types and prevent watermarking.
[0006] According to one aspect of the present invention, a method for intelligent previewing multi-format electronic documents is provided, comprising: obtaining a file URL and access control parameters; optimizing Nginx load balancing and allocating an Nginx reverse proxy based on the file URL and access control parameters; performing format conversion on the electronic document based on the Nginx reverse proxy; and previewing and inserting a watermark based on the format conversion result.
[0007] According to another aspect of the present invention, a multi-format electronic document intelligent preview device is provided, comprising: an acquisition module, a configuration module, a conversion module, and a preview module; the acquisition module is used to acquire a file URL and permission control parameters; the configuration module is used to match an Nginx reverse proxy based on the file URL and permission control parameters; the conversion module is used to perform format conversion on the electronic document based on the Nginx reverse proxy; and the prediction module is used to preview the format conversion result and insert a watermark.
[0008] According to another aspect of the present invention, a multi-format electronic document intelligent preview device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the multi-format electronic document intelligent preview method as described in any of the preceding claims.
[0009] According to another aspect of the present invention, a computer-readable storage medium is provided, storing a computer program, characterized in that, when the computer program is executed by a processor, it implements the intelligent preview method for multi-format electronic documents as described in any of the preceding claims.
[0010] As can be seen, the above solution, by pre-generating files with the same names as the original files in the file system, retaining the original content of each file, and then retrieving the corresponding file with the same name when the user needs to preview the files in the file system, eliminates the need to consider whether the client can directly recognize the file format of the file to be previewed. Instead, it uniformly converts the format, avoiding the time consumption caused by the inability to directly recognize the file format after receiving the preview command. This invention can realize online browsing of common file types without the need for front-end plugins, reducing the requirements for the client environment and the user's client configuration, making it convenient for users to directly use a browser to browse files online. This method is highly efficient, puts less pressure on the server, and only requires a single file conversion to achieve the preview effect. The probability of data distortion is lower because there is no conversion, resulting in higher data validity. Files do not need to be downloaded to the local machine, improving file security. Anti-counterfeiting watermarks are automatically added to files of different formats during the conversion process. By supporting previewing multiple file formats, the solution is improved, and the user experience is further enhanced. Furthermore, to better achieve load balancing of distributed server clusters under various high-concurrency scenarios during format conversion, this paper proposes a load balancing algorithm for format conversion servers based on the advantages of the *Slug-of-the-Sea* algorithm, which integrates node load performance metrics (throughput, memory, and disk) and the *Slug-of-the-Sea* algorithm. This algorithm can achieve load balancing under high-concurrency conditions during format conversion. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart illustrating an embodiment of the intelligent preview method for multi-format electronic archives of the present invention;
[0013] Figure 2 This is a schematic diagram of S103 of an embodiment of the intelligent preview method for multi-format electronic archives of the present invention, which illustrates the process of format conversion of electronic archives based on the Nginx reverse proxy.
[0014] Figure 3 This is a schematic diagram of the interface of an embodiment of the intelligent preview device for multi-format electronic archives of the present invention. Detailed Implementation
[0015] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be particularly noted that the following embodiments are for illustrative purposes only and do not limit the scope of the invention. Similarly, the following embodiments are only some, not all, embodiments of the present invention, and all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0016] This invention provides a method for intelligent previewing multi-format electronic archives, which solves the shortcomings of existing technologies in terms of difficulty in directly previewing different file types and watermark anti-counterfeiting.
[0017] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the intelligent preview method for multi-format electronic archives according to the present invention. It should be noted that if substantially the same result is achieved, the method of the present invention is not necessarily identical. Figure 1 The illustrated process sequence is limited. For example... Figure 1 As shown, the method includes the following steps:
[0018] S101: Obtain the file URL and permission control parameters.
[0019] In this embodiment, by adding a request matching location configuration to the Nginx.conf configuration file, first, the URL matching definition is configured: for example, ~.*.(gif|jpg)$ indicates that any URL with .gif or .jpg is processed by this location configuration. Then, the reverse proxy to the actual processing backend is configured: proxy_pass: http: / / static_pools. This enables the classification of preview requests and the reverse proxy to different types of backend preview services. The complete configuration code is: location ~.*.(gif|jpg)${proxy_pass http: / / static_pools;}.
[0020] In this embodiment, the file URL is used to obtain and download the corresponding file, and convert the file into a PDF or image before previewing; the permission control parameter is used to control whether the preview of the file can be downloaded or printed.
[0021] S102: Optimize Nginx load balancing and allocate Nginx reverse proxies based on file URLs and permission control parameters.
[0022] In this embodiment, N server clusters in the population are randomly initialized using Nginx. The fitness values of the N server clusters and the target location are calculated. Based on the obtained file URL, access control parameters, and access device type, it is determined whether the server cluster exceeds the fitness value of the target location. If not, the server cluster at the target location is used to match different Nginx reverse proxies using the file URL and access control parameters. Different resources are then resolved to their corresponding node servers through these different Nginx reverse proxies. If the fitness value exceeds the target location, the fitness values of the N server clusters are iteratively updated based on the leader and follower positions and compared with the fitness value of the target location. The optimal solution is updated with the position of the minimum fitness value. The optimal server cluster is obtained and output when the iteration stops. The optimal server cluster is then used to match different Nginx reverse proxies using the file URL and access control parameters. Different resources are then resolved to their corresponding node servers through these different Nginx reverse proxies.
[0023] Nginx, a high-performance web server, is commonly used for proxy services, load balancing, and web caching. Load balancing is a key application of Nginx's reverse proxy service. The format conversion preview method proposed in this case is built on top of an Nginx server, but in practice, it has encountered significant problems, particularly regarding load balancing. Increased traffic and the large memory consumption of different files place immense pressure on the backend server, especially in large-scale enterprise applications where numerous users lead to high concurrency demands, which a single server cannot handle. Currently, a common approach is to build a server cluster to improve system performance and cope with the massive traffic demands. A server cluster involves grouping many servers together to provide the same service, appearing to the client as a single server. Clusters can utilize multiple computers for parallel computing to achieve high processing speeds and can also use multiple computers for backup, ensuring the system continues to operate even if one machine fails. This increases the system's concurrency capabilities and redundancy in the event of a single machine failure, effectively preventing the cluster system from failing to provide services when a single server malfunctions, thus achieving high system reliability and high resource availability. In a cluster system, the most critical issues are how to rationally configure system resources and balance the load within the cluster. Load balancing technology, as a key technology in server clusters, typically employs load balancing distribution strategies to evenly distribute the load across backend servers, allowing the backend servers to process heavy load requests in parallel, thereby improving the processing efficiency of the cluster system.
[0024] In the field of load balancing technology for Nginx server clusters, many traditional static scheduling algorithms have emerged, such as the round-robin and weighted round-robin algorithms, least connections algorithm, and IP_Hash algorithm supported by Nginx itself. These algorithms can play a certain role in simple working scenarios, but they have revealed various problems in the increasingly complex modern network environment. Therefore, based on static algorithms, dynamic load balancing algorithms have emerged, which adjust the load distribution strategy in real time according to the actual load information fed back by the servers for load balancing scheduling. To a certain extent, this satisfies the requirement of real-time algorithm adjustment based on load conditions, but it also has its own problems: such as low load balancing efficiency under low load conditions, network resource occupation, and suboptimal overall allocation due to local peaks. Based on this, this paper proposes a solution to address the problems of format conversion requirements and high concurrency requirements. While solving the problems of dynamic and static algorithms, it introduces the "Umbralid Algorithm" to solve the server allocation problem.
[0025] The tunicate algorithm is an optimization algorithm proposed by simulating the aggregation and chain-like lifestyle of tunicates. The algorithm divides the group into leaders and followers. The leader searches for the global optimum, providing global search capability and ensuring population convergence. Followers follow the individual preceding them, providing local search capability and ensuring algorithm accuracy. The tunicate algorithm has a very simple model and a straightforward implementation, while also achieving good results and being less prone to getting trapped in local optima.
[0026] Specifically, the algorithm for bulk sales will be explained first.
[0027] ① Population initialization: The population size is represented by N, the spatial dimension by D, and the target space is represented by N×D. The position of the tunicate is represented by X. i Therefore, the position of each tunicate can be represented as Xi = [X i1 X i2 X i3 , ..., X iD ], i = 1, 2, 3, ..., N; where the virtual mobile food source, i.e., the target of the tunicate, is defined as F = [F1, F2, F3, ..., FD]; the upper and lower bounds of the search range for each dimension are Ub = [ub1, ub2, ub3, ..., ubD] and Lb = [lb1, lb2, lb3, ..., lbD].
[0028] The initial population position is represented by the following formula.
[0029] X N×D = rand(N,D)×(Ub-Lb)+Lb
[0030] ② Leadership position update
[0031] Leaders should update according to the following formula
[0032]
[0033] Where d represents the dimension. This represents the leader's value for each dimension. The values of the followers are represented by n = 2, 3, 4, ..., N; F d The target position is the value in d dimensions; c1, c2, and c3 represent control parameters, with c1 representing the convergence factor; l represents the number of iterations. max Let represent the maximum number of iterations. Then the convergence rate is shown in the following formula.
[0034]
[0035] Where c2 and c3 are random numbers generated in [0, 1], which determine the direction and step size of the leader position update.
[0036] ③ Tracker position update. During the iteration process, the coordinates of the nth tunicate in dimension d are represented as follows: Let the iteration time be l, the acceleration be a, and the initial velocity be v0. According to Newton's laws of motion, the position of the follower is defined as follows:
[0037]
[0038] Because the position of the previous tunicate affects the update of the follower's position, i.e., speed. This formula can then be expressed as follows:
[0039]
[0040] Secondly, explanations are provided regarding the requirements for format conversion and high concurrency.
[0041] S1, randomly initializes N server clusters in the population using Nginx.
[0042] S2, calculate the fitness values for N server clusters and the fitness value for the target location.
[0043] S3 iteratively calculates the fitness values of N server clusters based on the positions of leaders and followers, compares them with the fitness values of the target position, and updates the optimal solution with the position of the minimum fitness value.
[0044] S4 obtains the optimal server cluster and outputs it by continuously iterating and updating until the loop stops.
[0045] The model is designed based on the *Slug-Sea Algorithm*. This method, considering format conversion requirements and high concurrency needs, combined with literature reviews and experimental feedback, uses the throughput, memory, and disk space of each server as comprehensive performance evaluation indicators. Common server performance metrics include CPU (C), memory (M), disk I / O (I), and network bandwidth (N). However, in reality, the converted files are previewed as PDF, JPG, or H5 player-readable files, thus the requirements for CPU and network bandwidth are not high.
[0046] Assume there are N server clusters, N = {i1, i2, i3...i...} N}, n task indicators A = {a1, a2, a3…a n Each metric requires completing three tasks sequentially: calling the component, setting permissions, and previewing the format. A ={b 调用组件 b 设置权限 b 格式预览}, C A=3n, where n is the number of tasks. Assuming n ≠ m, the allocation aims to allow the N server clusters to complete C tasks at the lowest possible cost. A One task.
[0047] Assume u = 1, 2, 3, ..., N; v = 1, 2, 3, ..., n; w = 1, 2, 3, ..., C A Decision variables Represented as:
[0048]
[0049] The probability that server cluster u can continue to complete the next metric after executing task w for metric v. Represented as
[0050]
[0051] Where f uv The relative distance F between server cluster u and metric v represents the dominance probability. uv Represented as
[0052]
[0053] The relative speed V of server cluster u and metric v uv Represented as
[0054] V uv =|V u cosθ u + v cosθ v |
[0055] Task quantity constraint: The task quantity constraint ensures that every task for every metric is executed, which can be represented as...
[0056]
[0057] Task timing constraints: Task timing constraints ensure that target v is executed in the order of component invocation, permission setting, and format preview, which can be represented as follows:
[0058]
[0059] The objective function constructs an execution cost function I1 and a time cost function I2. The execution cost is the throughput, memory, and disk usage of the server cluster when completing the metric, and the time cost is the time required for the complete metric.
[0060]
[0061]
[0062] The overall objective function can be expressed as:
[0063] minI = I1 + 2
[0064] Obey
[0065]
[0066] Overall objective function constraint satisfaction formula
[0067]
[0068]
[0069]
[0070]
[0071] The objective function represents minimizing both execution cost and time cost, and the constraints are as follows:
[0072]
[0073] Ensure that a task is completed by only one server cluster.
[0074] After the model is established, N server clusters in the population are randomly initialized using Nginx. The fitness values of the N server clusters and the target position are calculated. The fitness values of the N server clusters are iteratively updated based on the positions of the leader and followers, and compared with the fitness value of the target position. The optimal solution is updated with the position of the minimum fitness value. The optimal server cluster is obtained and output when the loop stops iterating. The optimal server cluster is then used to match different Nginx reverse proxies through file URLs and permission control parameters. Different Nginx reverse proxies are used to resolve different resources to the corresponding node servers.
[0075] It should be further noted that parameters such as the humidity value and position update of the salps can be set according to actual needs, and will not be described in detail in this embodiment.
[0076] In this embodiment, when the server cluster does not exceed the appropriate value for the target location, in order to achieve separation of static and dynamic resources, dynamic resource servers, static resource servers, upload resource servers, default servers, etc., can be deployed. This way, when a front-end user accesses the server, different Nginx reverse proxies can be matched based on the URL address passed by the user, thus allowing different resources to be resolved to the corresponding node servers. The specific method is as follows:
[0077] Example: If you access the domain name WWW.....COM, then:
[0078] When a user visits WWW.....COM, the Nginx reverse proxy requests the default server. When a user visits WWW.....COM / UPLOAD / XXX, the Nginx reverse proxy requests the upload resource server; when a user visits WWW.....COM / MOVE / XXX, the Nginx reverse proxy requests the dynamic resource server; when a user visits...
[0079] When WWW.…….COM / STATIC / XXX is accessed via Nginx reverse proxy, the request is made to the static resource server.
[0080] In this embodiment, Nginx forwards requests based on the USER_AGENT device type. Besides URL-based proxy forwarding, Nginx can also implement different request forwarding based on the user's device type. To provide a better experience for different client users, different servers need to be set up on the backend. For example, mobile clients access the mobile website server, and PC clients access the PC server. In conventional Layer 4 load balancing, this is solved by manually assigning different domain names to clients, such as mobile users accessing WAP....COM and PC users accessing PC....COM. The biggest problem with this is that users need to remember different domain names. To solve this problem, Layer 7 load balancing eliminates the need for manual domain name splitting; it only provides one WWW....COM to the user. The principle behind this is based on obtaining the user's device type.
[0081] $HTTP_USER_AGENT is used to forward requests to the appropriate server.
[0082] S103: Perform format conversion on electronic files based on this Nginx reverse proxy.
[0083] In this embodiment,
[0084] i. For PDF files, use the PDFJS service component to set print and download permissions, and render and preview them directly in the browser;
[0085] ii. If it's a CAD file, use the ASPOSE CAD component to convert the DWG document to PDF.
[0086] The PDFJS service component sets print and download permissions and renders and previews the document directly in the browser; iii. For Office files, it calls LIBREOFFICE to convert the document into an image, calls the image preview component to set print and download parameters, and previews the image in the browser;
[0087] iv. If the document is in OFD national standard format, use the OFD READER&WRITER component to convert the document into an image, use the image preview component to set print download parameters, and preview the image in the browser; v. If the file is in image format, use the image preview component to set print download parameters and preview the image in the browser;
[0088] vi. If it is a video file, call FFMPEG video file group video transcoding and call the browser's H5 player.
[0089] Specifically,
[0090] 1. For PDF files, use the PDFJS service component to set print and download permissions, and then render and preview them directly in the browser. Print parameters are passed along with the file when the preview API is called.
[0091] &print=1, and the preview component itself automatically controls whether printing is allowed.
[0092] 2. For CAD files, the ASPOSE CAD component is used to convert the DWG document to PDF. The PDFJS service component is then used to set print and download permissions, and the file is directly rendered and previewed in the browser. The print parameter is passed along with the file when the preview interface is called: &print=1, and the preview component itself automatically controls whether printing is allowed.
[0093] 3. For Office files (DOC, DOCX, etc.), use LIBREOFFICE to convert the document into an image, call the image preview component to set print download parameters, and preview the image in the browser. The print parameters are passed when the file is called via the preview interface: &print=1, and the preview component itself automatically controls whether printing is allowed.
[0094] 4. If the document is in OFD national standard format, use the OFD READER&WRITER component to convert the document into an image, then use the image preview component to set print download parameters and preview it in the browser. The print parameters are passed to the preview interface when the file is called: &print=1, and the preview component itself automatically controls whether printing is allowed.
[0095] 5. For image files, call the image preview component to set print download parameters and preview in the browser. The print parameters are passed when the file is called via the preview interface: &print=1, and the preview component itself automatically controls whether printing is allowed.
[0096] 6. For video files, use FFMPEG video file group transcoding to convert the video and then use the browser's HTML5 player. FFMPEG converts other video formats to H.256 MP4 format files for playback in the HTML5 browser using the new video tag. H.265 can significantly reduce video file size.
[0097] The above implementation method can be referred to Figure 2 As shown.
[0098] S104: Preview the result of the format conversion and insert a watermark.
[0099] In this embodiment, it includes:
[0100] i. Electronic files that can be converted to PDF, with a base watermark inserted when generating the PDF using spose.Pdf.BackgroundArtifact;
[0101] ii. Electronic files that can be converted into images, with watermarks added via CSS overlay when generating the images;
[0102] iii. Add watermarks to electronic files that can be converted into video files during FFMPEG video transcoding.
[0103] Specifically,
[0104] 1. Watermarking is controlled via a request URL: &watermarkTxt = (watermark). Details are as follows:
[0105] 2. For documents that can be converted to PDF, Aspose.Pdf allows you to insert a base watermark using spose.Pdf.BackgroundArtifact when generating the PDF.
[0106] 3. For images converted to images, a watermark can be added using a CSS overlay.
[0107] 4. Add watermarks to video files when they are transcoded using FFMPEG.
[0108] As can be seen in this embodiment, the present invention pre-generates files with the same names as the original files in the file system, preserving the content of each file. Then, when a user needs to preview a file in the file system, the corresponding file with the same name is obtained. This eliminates the need to consider whether the client can directly recognize the file format of the file to be previewed; instead, the format is uniformly converted, avoiding the time consumption caused by the inability to directly recognize the file format after receiving the preview command. The present invention enables online browsing of common file types without requiring front-end plugins, reducing the requirements for the client environment and the user's client configuration, allowing users to directly browse files online using a browser. This method is highly efficient, puts less pressure on the server, and only requires a single file conversion to achieve the preview effect. The probability of data distortion is lower because there is one less conversion step, resulting in higher data validity. Files do not need to be downloaded locally, improving file security. Anti-counterfeiting watermarks are automatically added to files of different formats during the conversion process. By supporting previewing multiple file formats, the completeness of the solution is enhanced, and the user experience is further improved. Furthermore, to better achieve load balancing of distributed server clusters under various high-concurrency scenarios during format conversion, this paper proposes a load balancing algorithm for format conversion servers based on the advantages of the *Slug-of-the-Sea* algorithm, which integrates node load performance metrics (throughput, memory, and disk) and the *Slug-of-the-Sea* algorithm. This algorithm can achieve load balancing under high-concurrency conditions during format conversion.
[0109] Please see Figure 3 , Figure 3 This is a schematic diagram of the interface of a multi-format electronic document intelligent preview device according to the present invention. The present invention also provides a multi-format electronic document intelligent preview device, which solves the shortcomings of existing technologies in directly previewing different document types and implementing watermark anti-counterfeiting. In this embodiment, the multi-format electronic document intelligent preview device includes an acquisition module, a configuration module, a conversion module, and a preview module;
[0110] The acquisition module is used to acquire the file URL and permission control parameters;
[0111] The configuration module is used to match Nginx reverse proxy based on the file URL and permission control parameters;
[0112] The conversion module is used to perform format conversion on electronic files based on the Nginx reverse proxy;
[0113] The prediction module is used to preview the format conversion result and insert a watermark.
[0114] Optionally, this configuration module can be specifically used for:
[0115] The algorithm randomly initializes N server clusters in the population using Nginx, calculates the fitness values of the N server clusters and the target location, and determines whether the server cluster exceeds the fitness value of the target location based on the obtained file URL, access control parameters, and access device type. If it does not exceed the fitness value, it uses the server cluster at the target location to match different Nginx reverse proxies using the file URL and access control parameters, and uses different Nginx reverse proxies to resolve different resources to the corresponding node servers. If it exceeds the fitness value, it iteratively calculates the fitness value of the N server clusters based on the positions of the leader and followers, compares it with the fitness value of the target location, updates the optimal solution with the position of the minimum fitness value, and obtains the optimal server cluster by continuously iterating until the loop stops and outputs it. Finally, it uses the optimal server cluster to match different Nginx reverse proxies using the file URL and access control parameters, and uses different Nginx reverse proxies to resolve different resources to the corresponding node servers.
[0116] Optionally, this conversion module can be specifically used for:
[0117] i. For PDF files, use the PDFJS service component to set print and download permissions, and render and preview them directly in the browser;
[0118] ii. If it's a CAD file, use the ASPOSE CAD component to convert the DWG document to PDF.
[0119] The PDFJS service component sets print and download permissions and renders and previews the document directly in the browser; iii. For Office files, it calls LIBREOFFICE to convert the document into an image, calls the image preview component to set print and download parameters, and previews the image in the browser;
[0120] iv. If the document is in OFD national standard format, use the OFD READER&WRITER component to convert the document into an image, use the image preview component to set print download parameters, and preview the image in the browser; v. If the file is in image format, use the image preview component to set print download parameters and preview the image in the browser;
[0121] vi. If it is a video file, call FFMPEG video file group video transcoding and call the browser's H5 player.
[0122] Optionally, this conversion module can be specifically used for:
[0123] iv. Electronic files that can be converted to PDF, with a base watermark inserted when generating the PDF using spose.Pdf.BackgroundArtifact;
[0124] v. An electronic file that can be converted into an image, with a watermark added via a CSS overlay when generating the image;
[0125] vi. Add watermarks to electronic files that can be converted into video files during FFMPEG video transcoding.
[0126] Each unit module of the multi-format electronic document intelligent preview device can execute the corresponding steps in the above method embodiment. Therefore, the details of each unit module will not be elaborated here. Please refer to the description of the corresponding steps above for details.
[0127] The present invention also provides a multi-format electronic document intelligent preview device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the above-described multi-format electronic document intelligent preview method.
[0128] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.
[0129] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.
[0130] The present invention further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the above-described method embodiments.
[0131] As can be seen, the above solution, by pre-generating files with the same names as the original files in the file system, retaining the original content of each file, and then retrieving the corresponding file with the same name when the user needs to preview the files in the file system, eliminates the need to consider whether the client can directly recognize the file format of the file to be previewed. Instead, it uniformly converts the format, avoiding the time consumption caused by the inability to directly recognize the file format after receiving the preview command. This invention can realize online browsing of common file types without the need for front-end plugins, reducing the requirements for the client environment and the user's client configuration, making it convenient for users to directly use a browser to browse files online. This method is highly efficient, puts less pressure on the server, and only requires a single file conversion to achieve the preview effect. The probability of data distortion is lower because there is no conversion, resulting in higher data validity. Files do not need to be downloaded to the local machine, improving file security. Anti-counterfeiting watermarks are automatically added to files of different formats during the conversion process. By supporting previewing multiple file formats, the solution is improved, and the user experience is further enhanced. Furthermore, to better achieve load balancing of distributed server clusters under various high-concurrency scenarios during format conversion, this paper proposes a load balancing algorithm for format conversion servers based on the advantages of the *Slug-of-the-Sea* algorithm, which integrates node load performance metrics (throughput, memory, and disk) and the *Slug-of-the-Sea* algorithm. This algorithm can achieve load balancing under high-concurrency conditions during format conversion.
[0132] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection of apparatuses or units, and may be electrical, mechanical, or other forms.
[0133] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0134] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0135] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0136] The above description is only a part of the embodiments of the present invention and does not limit the scope of protection of the present invention. Any equivalent device or equivalent process transformation made based on the content of the present invention specification and drawings, or direct or indirect application in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for intelligent previewing of multi-format electronic files, characterized in that, include: Retrieve the file URL and permission control parameters; The permission control parameters are used to control whether the preview of the file can be downloaded or printed; Based on the performance metrics of throughput, memory, and disk format conversion, the Zunhaishao algorithm is used to optimize Nginx load balancing and Nginx reverse proxy is allocated based on file URL and permission control parameters. This Nginx reverse proxy is used to convert the format of electronic files, including PDF, CAD / DWG, OFFICE, OFD national standard, image, and video formats. Preview the format conversion result and insert a watermark; The optimization of Nginx load balancing and the allocation of Nginx reverse proxies based on file URLs and access control parameters include: The system randomly initializes N server clusters in the population using Nginx, calculates the fitness values of the N server clusters and the fitness value of the target location, determines whether the server cluster exceeds the fitness value of the target location based on the obtained file URL, permission control parameters and access device type, and if it does not exceed the fitness value, it uses the server cluster of the target location to match different Nginx reverse proxies through the file URL and permission control parameters, and uses different Nginx reverse proxies to resolve different resources to the corresponding node servers. If the optimal value exceeds the target value, the optimal server cluster is calculated iteratively based on the positions of the leader and followers, and compared with the optimal value of the target position. The optimal solution is updated with the position of the minimum optimal value. The optimal server cluster is obtained and output when the loop stops iterating. The optimal server cluster is used to match different Nginx reverse proxies through file URLs and permission control parameters. Different resources are resolved to the corresponding node servers through different Nginx reverse proxies.
2. The multi-format electronic portfolio intelligent preview method of claim 1, wherein, The format conversion of electronic files based on the Nginx reverse proxy includes: i. For PDF files, use the PDFJS service component to set print and download permissions, and render and preview them directly in the browser; ii. If it is a CAD file, call the ASPOSE CAD component to convert the DWG document to PDF, use the PDFJS service component to set printing and download permissions, and render and preview it directly in the browser; iii. If it is an Office file, use LIBREOFFICE to convert the document into an image, use the image preview component to set the print and download parameters, and preview it in the browser; iv. If the document is in OFD national standard format, use the OFD READER & WRITER component to convert the document into an image, use the image preview component to set the print download parameters, and preview the image in the browser; v. If it is an image file, call the image preview component to set the print download parameters and preview it in the browser; vi. If it is a video file, call FFMPEG video file group video transcoding and call the browser's H5 player.
3. The multi-format electronic portfolio intelligent preview method of claim 1, wherein, The process of previewing and inserting a watermark based on the format conversion result includes: i. Electronic files that can be converted to PDF, with a base watermark inserted using spose.Pdf.BackgroundArtifact when generating the PDF; ii. Electronic files that can be converted into images, with watermarks added via CSS overlay when generating the images; iii. Add watermarks to electronic files that can be converted into video files during FFMPEG video transcoding.
4. A multi-format electronic file intelligent preview apparatus, characterized by, To implement the method according to any one of claims 1 to 3, comprising: The module includes a data acquisition module, a configuration module, a conversion module, and a preview module. The acquisition module is used to acquire the file URL and permission control parameters; The configuration module is used to match Nginx reverse proxy based on the file URL and permission control parameters; The conversion module is used to perform format conversion on electronic files based on the Nginx reverse proxy; The preview module is used to preview the format conversion result and insert a watermark. The configuration module is specifically used for: The algorithm randomly initializes N server clusters in the population using Nginx, calculates the fitness values of the N server clusters and the target location, and determines whether the server cluster exceeds the fitness value of the target location based on the obtained file URL, access control parameters, and access device type. If it does not exceed the fitness value, it uses the server cluster at the target location to match different Nginx reverse proxies using the file URL and access control parameters, and uses different Nginx reverse proxies to resolve different resources to the corresponding node servers. If it exceeds the fitness value, it iteratively calculates the fitness value of the N server clusters based on the positions of the leader and followers, compares it with the fitness value of the target location, updates the optimal solution with the position of the minimum fitness value, and obtains the optimal server cluster by continuously iterating until the loop stops and outputs it. Finally, it uses the optimal server cluster to match different Nginx reverse proxies using the file URL and access control parameters, and uses different Nginx reverse proxies to resolve different resources to the corresponding node servers.
5. The multi-format electronic portfolio intelligent preview apparatus of claim 4, wherein, The conversion module is specifically used for: i. For PDF files, use the PDFJS service component to set print and download permissions, and render and preview them directly in the browser; ii. If it is a CAD file, call the ASPOSE CAD component to convert the DWG document to PDF, use the PDFJS service component to set printing and download permissions, and render and preview it directly in the browser; iii. If it is an Office file, use LIBREOFFICE to convert the document into an image, use the image preview component to set the print and download parameters, and preview it in the browser; iv. If the document is in OFD national standard format, use the OFD READER & WRITER component to convert the document into an image, use the image preview component to set the print download parameters, and preview the image in the browser; v. If it is an image file, call the image preview component to set the print download parameters and preview it in the browser; vi. If it is a video file, call FFMPEG video file group video transcoding and call the browser's H5 player.
6. The multi-format electronic portfolio intelligent preview apparatus of claim 4, wherein, The preview module is specifically used for: i. Electronic files that can be converted to PDF, with a base watermark inserted using spose.Pdf.BackgroundArtifact when generating the PDF; ii. Electronic files that can be converted into images, with watermarks added via CSS overlay when generating the images; iii. Add watermarks to electronic files that can be converted into video files during FFMPEG video transcoding.
7. A multi-format electronic document intelligent preview apparatus, characterized by comprising: include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the multi-format electronic document intelligent preview method as described in any one of claims 1 to 3.
8. A computer readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the intelligent preview method for multi-format electronic archives as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Document storage clustering method and device, equipment and medium
CN114185484A
File previewing method and device, server, terminal and storage medium
CN115114234A