CN113704187B - Method, apparatus, server and computer readable medium for generating file - Google Patents

Method, apparatus, server and computer readable medium for generating file Download PDF

Info

Publication number
CN113704187B
CN113704187B CN202010437917.3A CN202010437917A CN113704187B CN 113704187 B CN113704187 B CN 113704187B CN 202010437917 A CN202010437917 A CN 202010437917A CN 113704187 B CN113704187 B CN 113704187B
Authority
CN
China
Prior art keywords
page
file
generation request
tag
file generation
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.)
Active
Application number
CN202010437917.3A
Other languages
Chinese (zh)
Other versions
CN113704187A (en
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010437917.3A priority Critical patent/CN113704187B/en
Publication of CN113704187A publication Critical patent/CN113704187A/en
Application granted granted Critical
Publication of CN113704187B publication Critical patent/CN113704187B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

Embodiments of the present disclosure disclose methods, apparatuses, servers, and computer-readable media for generating files. One embodiment of the method comprises the following steps: determining a tag page corresponding to a file generation request in response to receiving the file generation request sent by the client, wherein the file generation request is used for requesting to generate a PDF file containing target contents; rendering the tag page according to the target content to generate the tag page containing the target content as a target tag page; and generating a PDF file corresponding to the target label page. The embodiment realizes the generation of the PDF file by the server.

Description

Method, apparatus, server and computer readable medium for generating file
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method, an apparatus, a server, and a computer readable medium for generating a file.
Background
A browser is one of applications that users often use when surfing the internet. With the rapid development of internet technology, browsers gradually begin to provide users with increasingly rich functional services. Currently, some browser kernels implement the function of converting a web page into a corresponding PDF file. Based on this, the user can also download or print PDF files as required.
Meanwhile, with the development of mobile terminal technology, some mobile terminal systems also provide a function of converting web pages into corresponding PDF files. For example, some mobile terminal systems are typically provided with a built-in browser. The user can convert the web page into a corresponding PDF file using a browser installed by the terminal system. As another example, some mobile terminal systems are provided with an application program interface API for enabling conversion of web pages into corresponding PDF files. These APIs may be used by a user to enable conversion of a web page into a corresponding PDF file.
Disclosure of Invention
Embodiments of the present disclosure propose methods, apparatuses, servers, and computer readable media for generating files.
In a first aspect, embodiments of the present disclosure provide a method for generating a file, the method comprising: determining a tag page corresponding to a file generation request in response to receiving the file generation request sent by the client, wherein the file generation request is used for requesting to generate a PDF file containing target contents; rendering the tag page according to the target content to generate the tag page containing the target content as a target tag page; and generating a PDF file corresponding to the target label page.
In some embodiments, the above method further comprises: storing the generated PDF file and acquiring a storage address of the PDF file; the storage address is returned to the client.
In some embodiments, determining a tab page to which the file generation request corresponds includes: and determining a preset tag page corresponding to the target content as a tag page corresponding to the file generation request according to the target content.
In some embodiments, according to the target content, determining a preset tab page corresponding to the target content as a tab page corresponding to the file generation request includes: determining a page style corresponding to the target content; and determining the tab page with the page style as the tab page corresponding to the target content.
In some embodiments, determining a tab page to which the file generation request corresponds includes: determining whether a resource pool comprises a tag page corresponding to a file generation request or not, wherein the resource pool comprises a pre-created tag page; in response to determining that the resource pool comprises the tag page corresponding to the file generation request, acquiring the tag page corresponding to the file generation request from the resource pool; and in response to determining that the tag page corresponding to the file generation request is not included in the resource pool, creating the tag page corresponding to the file generation request.
In some embodiments, the resource pool is constructed by: respectively acquiring resource configuration information of each page style in at least one preset page style, wherein the resource configuration information is used for indicating the number of tag pages with corresponding page styles in a resource pool; for a page style in the at least one page style, creating a corresponding number of tab pages with the page style according to the resource configuration information of the page style.
In some embodiments, the browser corresponding to the tab page corresponding to the file generation request is a headless browser.
In a second aspect, embodiments of the present disclosure provide an apparatus for generating a file, the apparatus comprising: a determining unit configured to determine a tab page corresponding to a file generation request in response to receiving the file generation request sent by the client, where the file generation request is used to request generation of a PDF file containing the target content; a rendering unit configured to render the tab page according to the target content to generate a tab page containing the target content as a target tab page; and the generating unit is configured to generate a PDF file corresponding to the target label page.
In some embodiments, the apparatus further comprises: a storage unit configured to store the generated PDF file and acquire a storage address of the PDF file; and the sending unit is configured to return the storage address to the client.
In some embodiments, the above-mentioned determining unit is further configured to: and determining a preset tag page corresponding to the target content as a tag page corresponding to the file generation request according to the target content.
In some embodiments, the above-mentioned determining unit is further configured to: determining a page style corresponding to the target content; and determining the tab page with the page style as the tab page corresponding to the target content.
In some embodiments, the above-mentioned determining unit is further configured to: determining whether a resource pool comprises a tag page corresponding to a file generation request or not, wherein the resource pool comprises a pre-created tag page; in response to determining that the resource pool comprises the tag page corresponding to the file generation request, acquiring the tag page corresponding to the file generation request from the resource pool; and in response to determining that the tag page corresponding to the file generation request is not included in the resource pool, creating the tag page corresponding to the file generation request.
In some embodiments, the resource pool is constructed by: respectively acquiring resource configuration information of each page style in at least one preset page style, wherein the resource configuration information is used for indicating the number of tag pages with corresponding page styles in a resource pool; for a page style in the at least one page style, creating a corresponding number of tab pages with the page style according to the resource configuration information of the page style.
In some embodiments, the browser corresponding to the tab page corresponding to the file generation request is a headless browser.
In a third aspect, embodiments of the present disclosure provide a server comprising: one or more processors; a storage means for storing one or more programs; the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the implementations of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the implementations of the first aspect.
The method, the device, the server and the computer readable medium for generating the file, which are provided by the embodiment of the disclosure, utilize the server to receive the file generation request which is sent by the client and is used for indicating to generate the PDF file containing the target content, and render the tag page of the server to obtain the tag page containing the target content, so as to generate the PDF file corresponding to the tag page containing the target content, thereby realizing the generation of the PDF file by the server. Compared with the prior art that PDF files are generated by utilizing functions and the like provided by a browser installed by a client, the method can avoid the situation that PDF files generated by different types of clients in the prior art are possibly inconsistent, and can also solve the problem that development quantity is overlarge because different clients need to be developed respectively in the prior art.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
FIG. 2 is a flow chart of one embodiment of a method for generating a file according to the present disclosure;
FIG. 3 is a schematic illustration of one application scenario of a method for generating a file according to an embodiment of the present disclosure;
FIG. 4 is a flow chart of yet another embodiment of a method for generating a file according to the present disclosure;
FIG. 5 is a schematic structural view of one embodiment of an apparatus for generating documents according to the present disclosure;
fig. 6 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
FIG. 1 illustrates an exemplary architecture 100 to which embodiments of the methods of the present disclosure for generating a file or apparatus for generating a file may be applied.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages or the like. Various client applications can be installed on the terminal devices 101, 102, 103. For example, search class applications, instant messaging class applications, browser class applications, shopping class applications, social platform software, and the like.
The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices including, but not limited to, smartphones, tablet computers, electronic book readers, laptop and desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. Which may be implemented as multiple software or software modules (e.g., multiple software or software modules for providing distributed services) or as a single software or software module. The present invention is not particularly limited herein.
The server 105 may be a server providing various services, such as a back-end server responding to file generation requests sent by the terminal devices 101, 102, 103. The server 105 may receive and process a file generation request sent by the client for requesting generation of a PDF file containing the target content, and generate a PDF file required by the client. Further, the server 1005 may return the generated storage address of the PDF file required by the client to the terminal device so that the terminal device may acquire the requested PDF file.
Various applications may also be installed on the server 105. Such as a search class application, an instant messaging class application, a browser class application, etc. The server 105 may complete rendering of the tab page according to the target content indicated by the file generation request sent by the client by using the browser installed therein, to obtain the tab page containing the target content.
It should be noted that, the method for generating a file provided by the embodiment of the present disclosure is generally performed by the server 105, and accordingly, the apparatus for generating a file is generally disposed in the server 105.
The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster formed by a plurality of servers, or as a single server. When server 105 is software, it may be implemented as multiple software or software modules (e.g., multiple software or software modules for providing distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for generating a file according to the present disclosure is shown. The method for generating a file comprises the steps of:
in step 201, in response to receiving a file generation request sent by a client, a tag page corresponding to the file generation request is determined.
In this embodiment, the execution subject (e.g., the server 105 shown in fig. 1) of the method for generating a file may receive a file generation request sent by a client (e.g., the terminal devices 101, 102, 103 shown in fig. 1), and determine a tab page corresponding to the question generation request according to the file generation request. The tab page may be a tab page of a browser installed on the execution body.
The file generation request may be used to request generation of a PDF (Portable Document Format ) file containing the target content. The target content can be set by a user of the client according to actual application requirements. For example, the target content may be a piece of text specified by the client, a web page, and so on.
According to different application scenes or actual application requirements, various modes can be flexibly adopted to determine the tag page corresponding to the file generation request.
For example, after receiving the file generation request, a tab page may be created using the browser as the tab page corresponding to the file generation request. For another example, after receiving the file generation request, it may be first determined whether the browser currently has a tab page created that is in an idle state. If so, the currently created tab page in the idle state can be used as the tab page corresponding to the file generation request. If not, a tab page can be created by using the browser as the tab page corresponding to the file generation request.
Step 202, rendering the tab page according to the target content to generate the tab page containing the target content as a target tab page.
In this embodiment, the execution body may render the tab page based on the target content to obtain the tab page for presenting the target content. According to different practical application requirements, different methods can be adopted to complete the rendering process of the label page.
For example, the execution body may complete the rendering of the tab page using the functions provided by the browser installed therein. For another example, the execution body may call a rendering interface corresponding to a preset tab page to complete rendering of the tab page. The rendering interface corresponding to the tab page may be developed and set in advance by a technician.
Step 203, a PDF file corresponding to the target tab page is generated.
In this embodiment, the execution body may generate the corresponding PDF file according to the generated tab page including the target content. According to different practical application requirements, PDF files corresponding to the target tag pages can be generated by different methods.
For example, the execution subject may generate a PDF file corresponding to the target tab page using a function provided by a browser installed therein. For another example, the executing body may generate a PDF file corresponding to the target tab page by using a conversion interface corresponding to the preset tab page. The conversion interface can be developed and set in advance by a technician.
In some optional implementations of the present embodiment, after generating the PDF file corresponding to the target tab page, the generated PDF file may be further stored and a storage address of the PDF file may be acquired. Then, the storage address of the PDF file may be returned to the client so that the client may acquire the generated PDF file according to the storage address.
Alternatively, the generated PDF file may be stored in a file memory.
In some optional implementations of this embodiment, the browser corresponding to the tab page corresponding to the file generation request may be a headless browser.
Since the headless browser does not launch the graphical user interface of the browser, all time to load page styles, render pages, etc. to render pages is saved. Therefore, compared with the tag page of the common browser, the tag page of the headless browser can save all time for presenting the tag page, so that the service efficiency of the tag page is improved, and the efficiency of generating PDF files is further improved.
In some optional implementations of the present embodiment, a preset tab page corresponding to the target content may be determined as a tab page corresponding to the file generation request according to the target content.
At this time, tag pages corresponding to different target contents, respectively, may be preset by a technician. The corresponding relation between the target content and the tab page can be flexibly set according to actual application requirements or different application scenes.
For example, the correspondence relationship between the attribute information of the target content and the tab page may be set in advance. As an example, the attribute information may include information indicating whether the target content includes an image. If the attribute information indicates that the target content includes an image, one tab page may be randomly selected from the tab pages that have been created at present as a tab page corresponding to the target content. If the attribute information indicates that the target content does not include an image, a new tab page can be created by using the browser as a tab page corresponding to the target content.
Alternatively, the page style corresponding to the target content may be determined first, and then a tab page having the page style corresponding to the target content may be determined as the tab page corresponding to the target content.
The page style may be used to indicate front-end design information such as style and layout of the tab page. At this time, the technician may design different page styles for the tab page in advance according to an actual application scenario or an actual application requirement.
The corresponding relation between the target content and the page style can be flexibly set. For example, a page style corresponding to the target content may be determined according to the type of the target content. It should be appreciated that different types of partitioning may be performed for the target content, depending on the application scenario. As an example, the type classification may be performed for the target content according to the domain to which the target content belongs.
At this time, the type of the target content may be determined first, and then the page style of the tab page corresponding to the type of the target content may be determined. A tab page having the determined page style may then be determined as a tab page corresponding to the target content.
With continued reference to fig. 3, fig. 3 is a schematic diagram 300 of an application scenario of the method for generating a file according to the present embodiment. In the application scenario of fig. 3, the user may send a PDF generation request to the server 302 by using the mobile phone 301 used by the user to request to generate a PDF file corresponding to the document. Meanwhile, the user can send the document required to generate the corresponding PDF file to the server 302 using the mobile phone 301 used by the user.
The server 302 may render the tab page in an idle state created in advance by the headless browser 3021 installed thereon to generate a tab page in which the document content is presented. Then, the server 302 may call the PDF conversion function of the headless browser 3021 to convert the generated tab page presenting the document content into a corresponding PDF file.
After that, the server 302 may store the generated PDF file and acquire the storage address 303. The server 302 may then return the storage address 303 to the handset 301 used by the user. Further, the user can acquire a PDF file corresponding to the document according to the storage address 303.
In the prior art, the generation of the PDF file is generally realized by a client. Therefore, functional development for generating PDF files needs to be performed separately for different clients (e.g., clients of different operating systems, etc.). Meanwhile, there may be some differences (e.g., differences in page styles, etc.) between PDF files generated by different clients for the same content. In addition, when updating the function of generating the PDF file provided by the client, a new client needs to be released so that the updated function can be used only by the user downloading and installing the new client.
The method for generating the file provided by the disclosure realizes the generation of the PDF file by using the server. Therefore, the workload of developing each client is eliminated, and the generated PDF files do not have differences for the same content. Meanwhile, the relevant updating of the function for generating the PDF file is also performed at the server side, so that the time for a user to wait for updating the client side can be saved. Thus, stability and efficiency of the entire process of generating the PDF file can be ensured.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for generating a file is shown. The process 400 of the method for generating a file comprises the steps of:
in step 401, in response to receiving the file generation request sent by the client, it is determined whether the resource pool includes a tab page corresponding to the file generation request.
In this embodiment, the resource pool may include several tab pages created in advance.
The specific execution process of the tag page corresponding to the file generation request in this step may refer to the related description in the corresponding embodiment of fig. 2, and will not be described herein.
In step 402, in response to determining that the resource pool includes a tab page corresponding to the file generation request, the tab page corresponding to the file generation request is obtained from the resource pool.
In this embodiment, if the resource pool includes the tag page corresponding to the file generation request, the tag page corresponding to the file generation request may be directly obtained from the resource pool, so that the process of creating and loading the tag page may be omitted.
In step 403, in response to determining that the tag page corresponding to the file generation request is not included in the resource pool, the tag page corresponding to the file generation request is created.
Step 404, rendering the tab page according to the target content to generate the tab page containing the target content as the target tab page.
Step 405, a PDF file corresponding to the target tab page is generated.
The specific implementation of steps 404 and 405 described above may refer to the relevant descriptions of steps 202 and 203 in the corresponding embodiment of fig. 2, and will not be repeated here.
In some alternative implementations of the present embodiment, the resource pool may be constructed by:
step one, resource configuration information of each page style in at least one preset page style is respectively obtained.
In this step, at least one page style may be designed and developed by a technician according to an actual application requirement or a specific application scenario. The resource configuration information of the page style may be used to indicate the number of tab pages in the resource pool having a corresponding page style.
And step two, for the page style in at least one page style, creating a corresponding number of tab pages with the page style according to the resource configuration information of the page style.
For example, the resource configuration information of the page pattern "a" indicates that the number of tab pages having the page pattern "a" in the resource pool is "N". At this time, the "N" tab pages may be created in advance, and each of the "N" tab pages is loaded with the page style "a".
Alternatively, the resource configuration information of each page style in the at least one page style may be stored in a dynamic configuration file.
Alternatively, the resource allocation values of the page styles may be used to indicate the minimum and maximum numbers of tab pages in the resource pool that have corresponding page styles. Wherein the minimum number may refer to the number of tab pages that the page style requires least occupancy at idle time. The maximum number may refer to the number of tab pages that the page style occupies most when the service is busy.
By setting the minimum number of tab pages corresponding to the page patterns, the instant response of the request of the client at the idle time can be ensured without waiting for the time of creating the tab pages and loading the page patterns by the tab pages. By setting the maximum number of tag pages corresponding to the page style, the file generation request for the same page style can be controlled not to occupy excessive computer resources (such as CPU resources of a central processing unit) of the whole server, so that response processing of file generation requests for other page styles is reserved.
Alternatively, overall total resource configuration information for the entirety of at least one page style may also be obtained. At this time, the total resource configuration information may be used to indicate a maximum total number of tab pages in the resource pool. Therefore, the upper limit of the number of the tag pages in the resource pool is controlled, the utilization rate of the PDF generation function to the computer resources of the server side can be effectively controlled, and the overall performance and service stability of the server side are ensured.
At this time, after the total number of the tag pages in the resource pool reaches the maximum total number, a prompt message may be returned to the client for the file generation request received again, so as to prompt that the current service is busy and the processing cannot be performed.
Optionally, after the total number of the tag pages in the resource pool reaches the maximum total number, the processing capability of the server can be further improved by expanding the computer resources of the server. For example, the number of processing terminals at the server side is increased, etc. At this time, the maximum total number corresponding to the resource pool can be raised.
Alternatively, the at least one page style developed in advance may be stored in the file memory. At this time, when the service of the server is started, the content of the configuration file storing the resource configuration information and the total resource configuration information corresponding to at least one page style may be read, and the configuration of the tag page may be completed according to the read content.
Optionally, the above configuration file may further store a file storage address of at least one page style, so as to facilitate processing of each page style.
As an example, at service start-up of the server, the server may read the content in the configuration file and then download each page style to the local. And then generating a corresponding number of tab pages according to the resource configuration information corresponding to each page style.
Optionally, when the service of the server is started, the server reads the content in the configuration file, downloads each page style to the local, and then can create the local page style file as the symbol link of the page style file in the corresponding file memory, so as to ensure the stability of the process of recording the page style.
Optionally, when the configuration file of the resource pool has an update, or when the page style has an update, each updated page style file may be downloaded again to the local, and then a corresponding number of tab pages are generated or the existing corresponding tab pages are refreshed according to the corresponding resource configuration information. At the same time, the corresponding symbol connection may be updated.
Thus, the real-time updating of various page styles can be realized without the need of upgrading the client. Therefore, the time that the user waits for the client to upgrade and then installs the new version of the client to use the updated page style is saved.
Optionally, after determining the tab page corresponding to the file generation request, the executing body may start a timer to control the total time of the process of rendering the tab page corresponding to the file generation request and generating the corresponding PDF file, so as to avoid congestion situations such as excessively long response time for the file generation request.
Alternatively, after the PDF file is generated, the tag page corresponding to the file generation request may be emptied through an operation such as refreshing the page, that is, the target content in the tag page may be emptied. The tag page after the flush process may then be returned to the resource pool.
Optionally, when the resource pool is utilized to perform management control on the tab pages, after receiving the file generation request, the page style of the corresponding tab page may be determined according to the target content, and then whether the tab page with the page style in an idle state exists is searched in the resource pool. If so, a tab page in an idle state with the page style may be used. If not, it may be determined whether the total number of tab pages in the current resource pool reaches a corresponding upper limit, and whether the number of tab pages having the page style reaches the upper limit. If the upper limit is reached, prompt information for prompting that the current service resources are insufficient and the like can be returned to the client. Otherwise a new tab page with the page style may be created in response to the file generation request.
Optionally, for each page style in the at least one page style, the number of tabbed pages having the page style in the resource pool may be monitored, and in response to determining that the idle time of the tabbed pages having the page style in the resource pool is greater than a preset idle threshold, the tabbed pages may be reclaimed. In response to determining that the total number of tab pages having the page style in the resource pool exceeds the minimum number of tab pages corresponding to the page style, recycling a portion of the tab pages to ensure that the number of tab pages having the page style in the resource pool is the corresponding minimum number.
Therefore, the response speed of the file generation request of the client and the overall performance of the server can be balanced better through controlling the tag pages in the resource pool.
The method for generating the file in the embodiment manages and maintains various tag pages by using the resource pool, so that when a file generation request of a client is received, the file generation request of the client can be responded quickly at idle time, the time for creating the tag page and loading the page style of the tag page is saved, the occupancy rate of the tag page in the resource pool to computer resources can be controlled, and the overall performance of the server and the stability of the service provided by the server are ensured.
With further reference to fig. 5, as an implementation of the method shown in the foregoing figures, the present disclosure provides an embodiment of an apparatus for generating a file, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus 500 for generating a file provided in the present embodiment includes a determination unit 501, a rendering unit 502, and a generation unit 503. Wherein the determining unit 501 is configured to determine, in response to receiving a file generation request sent by a client, a tab page corresponding to the file generation request, where the file generation request is used to request generation of a PDF file containing target content; the rendering unit 502 is configured to render the tab page according to the target content to generate a tab page containing the target content as a target tab page; the generating unit 503 is configured to generate a PDF file corresponding to the target tab page.
In this embodiment, in the apparatus 500 for generating a file: the specific processes of the determining unit 501, the rendering unit 502 and the generating unit 503 and the technical effects thereof may refer to the descriptions related to step 201, step 202 and step 203 in the corresponding embodiment of fig. 2, and are not repeated herein.
In some optional implementations of this embodiment, the apparatus 500 for generating a file further includes: a storage unit (not shown in the figure) configured to store the generated PDF file and acquire a storage address of the PDF file; the sending unit (not shown in the figure) is configured to return the storage address to the client.
In some optional implementations of this embodiment, the determining unit 501 is further configured to: and determining a preset tag page corresponding to the target content as a tag page corresponding to the file generation request according to the target content.
In some optional implementations of this embodiment, the determining unit 501 is further configured to: determining a page style corresponding to the target content; and determining the tab page with the page style as the tab page corresponding to the target content.
In some optional implementations of this embodiment, the determining unit 501 is further configured to: determining whether a resource pool comprises a tag page corresponding to a file generation request or not, wherein the resource pool comprises a pre-created tag page; in response to determining that the resource pool comprises the tag page corresponding to the file generation request, acquiring the tag page corresponding to the file generation request from the resource pool; and in response to determining that the tag page corresponding to the file generation request is not included in the resource pool, creating the tag page corresponding to the file generation request.
In some alternative implementations of the present embodiment, the resource pool is constructed by: respectively acquiring resource configuration information of each page style in at least one preset page style, wherein the resource configuration information is used for indicating the number of tag pages with corresponding page styles in a resource pool; for a page style in the at least one page style, creating a corresponding number of tab pages with the page style according to the resource configuration information of the page style.
In some optional implementations of this embodiment, the browser corresponding to the tab page corresponding to the file generation request is a headless browser.
The device provided by the embodiment of the disclosure is characterized in that a determining unit is used for determining a tag page corresponding to a file generation request in response to receiving the file generation request sent by a client, wherein the file generation request is used for requesting to generate a PDF file containing target content; the rendering unit renders the tag page according to the target content to generate the tag page containing the target content as a target tag page; the generating unit generates a PDF file corresponding to the target tag page, thereby realizing the generation of the PDF file by the server.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., server in fig. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The server illustrated in fig. 6 is merely an example, and should not be construed as limiting the functionality and scope of use of the embodiments of the present disclosure in any way.
As shown in fig. 6, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 6 may represent one device or a plurality of devices as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing means 601.
It should be noted that, the computer readable medium according to the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In an embodiment of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Whereas in embodiments of the present disclosure, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the server; or may exist alone without being assembled into the server. The computer readable medium carries one or more programs which, when executed by the server, cause the server to: determining a tag page corresponding to a file generation request in response to receiving the file generation request sent by the client, wherein the file generation request is used for requesting to generate a PDF file containing target contents; rendering the tag page according to the target content to generate the tag page containing the target content as a target tag page; and generating a PDF file corresponding to the target label page.
Computer program code for carrying out operations of embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments described in the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes a determination unit, a rendering unit, and a generation unit. The names of these units do not constitute a limitation on the unit itself in some cases, and for example, the determination unit may also be described as "a unit that determines a tab page to which a file generation request corresponds in response to receiving the file generation request sent by the client".
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.

Claims (8)

1. A method for generating a file, comprising:
determining a tag page corresponding to a file generation request sent by a client in response to the file generation request, wherein the file generation request is used for requesting to generate a portable document format PDF file containing target content, and the tag page corresponding to the file generation request is obtained by determining a page style corresponding to the target content and determining the tag page with the page style;
Rendering the tag page according to the target content to generate a tag page containing the target content as a target tag page;
And generating a PDF file corresponding to the target label page.
2. The method of claim 1, wherein the method further comprises:
storing the generated PDF file and acquiring a storage address of the PDF file;
And returning the storage address to the client.
3. The method of claim 1, wherein the determining the tab page to which the file generation request corresponds comprises:
Determining whether a resource pool comprises a tag page corresponding to the file generation request or not, wherein the resource pool comprises a pre-created tag page;
In response to determining that the resource pool comprises the tag page corresponding to the file generation request, acquiring the tag page corresponding to the file generation request from the resource pool;
And in response to determining that the tag page corresponding to the file generation request is not included in the resource pool, creating the tag page corresponding to the file generation request.
4. A method according to claim 3, wherein the resource pool is constructed by:
Respectively acquiring resource configuration information of each page style in at least one preset page style, wherein the resource configuration information is used for indicating the number of tag pages with corresponding page styles in a resource pool;
and for the page style in the at least one page style, creating a corresponding number of tab pages with the page style according to the resource configuration information of the page style.
5. The method according to one of claims 1 to 4, wherein the browser corresponding to the tab page corresponding to the file generation request is a headless browser.
6. An apparatus for generating a file, wherein the apparatus comprises:
A determining unit configured to determine a tab page corresponding to a file generation request sent by a client in response to receiving the file generation request, wherein the file generation request is used for requesting to generate a portable document format PDF file containing target content, and the tab page corresponding to the file generation request is obtained by determining a page style corresponding to the target content and determining a tab page with the page style;
a rendering unit configured to render the tab page according to the target content to generate a tab page containing the target content as a target tab page;
and the generating unit is configured to generate a PDF file corresponding to the target tag page.
7. A server, comprising:
one or more processors;
A storage device having one or more programs stored thereon;
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
8. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-5.
CN202010437917.3A 2020-05-21 2020-05-21 Method, apparatus, server and computer readable medium for generating file Active CN113704187B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010437917.3A CN113704187B (en) 2020-05-21 2020-05-21 Method, apparatus, server and computer readable medium for generating file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010437917.3A CN113704187B (en) 2020-05-21 2020-05-21 Method, apparatus, server and computer readable medium for generating file

Publications (2)

Publication Number Publication Date
CN113704187A CN113704187A (en) 2021-11-26
CN113704187B true CN113704187B (en) 2024-05-28

Family

ID=78646232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010437917.3A Active CN113704187B (en) 2020-05-21 2020-05-21 Method, apparatus, server and computer readable medium for generating file

Country Status (1)

Country Link
CN (1) CN113704187B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572594A (en) * 2015-01-27 2015-04-29 中復保有限公司 Real-time generation method of dynamic PDF (portable document format) documents
CN106528888A (en) * 2016-12-20 2017-03-22 北京小米移动软件有限公司 Processing method and device of browser tag page
CN109491744A (en) * 2018-11-06 2019-03-19 成都知道创宇信息技术有限公司 A kind of webpage capture system and method
CN110008195A (en) * 2019-04-11 2019-07-12 重庆猪八戒知识产权服务有限公司 A kind of dynamic configuration html turns the method, apparatus and system of pdf
CN110807158A (en) * 2018-07-18 2020-02-18 北京字节跳动网络技术有限公司 Label page control method, system, equipment and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572594A (en) * 2015-01-27 2015-04-29 中復保有限公司 Real-time generation method of dynamic PDF (portable document format) documents
CN106528888A (en) * 2016-12-20 2017-03-22 北京小米移动软件有限公司 Processing method and device of browser tag page
CN110807158A (en) * 2018-07-18 2020-02-18 北京字节跳动网络技术有限公司 Label page control method, system, equipment and computer readable storage medium
CN109491744A (en) * 2018-11-06 2019-03-19 成都知道创宇信息技术有限公司 A kind of webpage capture system and method
CN110008195A (en) * 2019-04-11 2019-07-12 重庆猪八戒知识产权服务有限公司 A kind of dynamic configuration html turns the method, apparatus and system of pdf

Also Published As

Publication number Publication date
CN113704187A (en) 2021-11-26

Similar Documents

Publication Publication Date Title
US11119812B2 (en) Method and device for processing application program page according to a common interface container
CN105740048B (en) A kind of mirror image management method, apparatus and system
WO2019201039A1 (en) Method and system for updating application and application server
CN110990075B (en) Method, device, equipment and storage medium for starting fast application
US9258357B2 (en) Method for accessing plural cloud storages, electronic apparatus and non-transitory computer readable medium
CN110391938B (en) Method and apparatus for deploying services
WO2019029451A1 (en) Method for publishing mobile applications and electronic apparatus
CN114385164A (en) Page generation and rendering method and device, electronic equipment and storage medium
CN115268949A (en) Mirror preheating method, device, equipment and storage medium
CN110647327B (en) Method and device for dynamic control of user interface based on card
CN113704187B (en) Method, apparatus, server and computer readable medium for generating file
CN110120963B (en) Data processing method, device, equipment and machine readable medium
CN113934437B (en) Method and system for installing application on cloud mobile phone and client cloud mobile phone
CN111142972B (en) Method, apparatus, system, and medium for extending functions of application program
WO2016107119A1 (en) Method and device for realizing unstructured supplementary service data menu
CN111970338A (en) Request processing method and device based on cloud function and computer readable medium
CN112784187A (en) Page display method and device
CN110858240A (en) Front-end module loading method and device
CN112988170B (en) Application display method and device
CN115080059A (en) Request processing method and device and electronic equipment
CN114500496A (en) Target data downloading method and device
CN118227220A (en) Application program running method and device, storage medium and electronic equipment
CN117971376A (en) Data processing method, device, cloud device and medium
CN115826981A (en) Real-time operating system driver adaptation method and device, electronic equipment and readable medium
CN117707369A (en) Display method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant