Summary of the invention
The shortcoming of prior art in view of the above the object of the present invention is to provide a kind of document with multiple format to be presented at method in the webpage, is used for solving prior art owing to be subjected to the restriction of browser, the arbitrarily problem of reading instruction document.
Reach for achieving the above object other relevant purposes, the invention provides a kind of document with multiple format and be presented at method in the webpage, it comprises at least: 1) obtain document that the user uploads and the type of the employed browser of user; 2) form of the described document of identification, and based on the type of the form of identifying and described browser determine described document whether can be directly by web displaying in described browser, if, then directly be loaded in the described webpage, otherwise, can not be directly, the form of described document is changed, and the document after will changing be written in the webpage in described browser the time by web displaying at the document of the form of determining to identify; Wherein, the form of described document belongs to video format, format slide, picture format or text formatting.
Preferably, when the form that identifies described document belongs to video format or format slide, described step 2) comprising: if the type of described browser is not supported the various video form, or the various video form supported by described browser but the form of described document does not belong to the video format that described browser is supported, then the format conversion with described document becomes the Flash form, described document after will changing again is written in the webpage, if the type of described browser supports the form of various video form and described document to belong to the video format that described browser is supported, then described document is written in the webpage, in order to play by described webpage.
Preferably, when the form that identifies described document belongs to format slide, described step 2) comprising: the format conversion of described document is become the Flash form, and the described document after will changing again is written in the webpage, in order to play by described webpage.
Preferably, when the form that identifies described document belongs to picture format, described step 2) comprising: the format conversion of described document is become the png form, and the described document after will changing again is written in the webpage, in order to shown by described webpage.
Preferably, when the form that identifies described document belongs to text formatting, described step 2) comprising: described document is resolved and determine that described document belongs to streaming document or format document, if belong to the streaming document, then according to the position relationship between each information in the described document each described information is written in the webpage, if belong to format document, then according to the position relationship between each described information of the location positioning of each information in the page in the described document, and based on the position relationship between each described information each described information is written in the webpage; Wherein, described information comprises at least a in literal, symbol, the picture.
Preferably, when described document belongs to the streaming document, described step 2) according to the position relationship between each information in the described document mode that each described information is written in the webpage is comprised: the type according to described information in document splits at least one object with described document, and the type of the information that comprises based on each object is written into each object in the webpage successively.Wherein, the type of described information comprises: literal type or picture/mb-type.
Preferably, when described document belongs to format document, described step 2) according to the position relationship between each described information of the location positioning of each information in the page in the described document, and based on the position relationship between each described information the mode that each described information is written in the webpage is comprised: extract the type of each information in the described document and each information in the absolute position of affiliated page or leaf, and according to the absolute position of each described information in the described page or leaf, determine in the ranks the position relationship with intersegmental information, again based on converting described document to the streaming document with the position relationship of intersegmental information in the ranks, and according to the processing mode of streaming document described document is written in the webpage.
Preferably, when the form that identifies described document belongs to text formatting, described step 2) also comprise: extract the attribute information of described document Chinese word, and the attribute information of described literal is written in the webpage, shown with corresponding attribute for described literal.
Preferably, described attribute information comprises: at least a in font size, font-weight, text color, literal highlight color, the literal underscore.
As mentioned above, document with multiple format of the present invention is presented at the method in the webpage, have following beneficial effect: the document that belongs to different-format can be converted to can be viewed the webpage format of device identification, need not browser plug-in unit be installed, be user-friendly to; In addition, document to text formatting, by the parsing of document is determined that document is to belong to streaming document or format document, for the streaming document, the present invention is loaded into each information in the document in the webpage according to the order that provides in the document, so document can be converted to pure words and picture, again pure words and picture are loaded in the webpage, the problem that can avoid the user installation plug-in unit or can't read the streaming document because browser version is not supported plug-in unit; Also have, to format document, the present invention obtains the literal in the document, the absolute position of picture, and according to the absolute position determine in the ranks, intersegmental literal, and the relativeness between literal and the picture, thus, convert document to the constant pure words of sequence of positions and picture, solve thus format document and can't directly be presented at problem in the browser.
Embodiment
Below by specific instantiation explanation embodiments of the present invention, those skilled in the art can understand other advantages of the present invention and effect easily by the disclosed content of this instructions.The present invention can also be implemented or be used by other different embodiment, and the every details in this instructions also can be based on different viewpoints and application, carries out various modifications or change under the spirit of the present invention not deviating from.
As shown in Figure 1, the invention provides a kind of document with multiple format and be presented at method in the webpage.Described display packing is mainly carried out by display system, and wherein, described display system is to be installed in application in the network equipment etc.This network equipment be a kind of can be according to the program of prior storage, automatically, carry out at high speed the modernized intelligent electronic device of massive values computation and various information processings, and can with network in subscriber equipment communicate, its hardware includes but not limited to computer equipment, server etc.
In step S1, described display system is obtained document that the user uploads and the type of the employed browser of user.
Particularly, the user uploads to described display system by the browser in the employed subscriber equipment with the Teaching Document of this locality.Wherein, the form of described document can belong to video format, format slide, picture format or text formatting.
In step S2, described display system is identified the form of described document, and based on the type of the form of identifying and described browser determine described document whether can be directly by web displaying in described browser, if, then directly be loaded in the described webpage, otherwise, the document of the form of determining to identify can not be directly by web displaying in described browser the time, the form of described document is changed, and the document after will changing is written in the webpage.
Particularly, described display system determines by the suffix name of described document which kind of form described document belongs to first, when the form of described document can be by the viewed device identification of html tag, then select corresponding html tag based on the form of described document, directly to be loaded into described document in the webpage, when the form of described document can not be by the viewed device identification of html tag, perhaps need after the plug-in unit that is similar to Remote Instruction Software is installed in browser, could to identify by viewed device, then based on the form of identifying the format conversion of described document is become and can be loaded into form in the webpage by html tag, and select corresponding html tag according to the form of document after the conversion, in order to described document is written in the webpage.
When the form of described document belongs to video format, described display system also will determine whether described browser can play-over video based on the browser type that obtains, if the type of described browser is not supported the various video form, or the various video form supported by described browser but the form of described document does not belong to the video format that described browser is supported, then the format conversion with described document becomes the Flash form, described document after will changing again is written in the webpage, if the type of described browser supports the form of various video form and described document to belong to the video format that described browser is supported, then described document is written in the webpage, in order to play by described webpage.Wherein, the browser of supporting various video mainly is the browser of supporting the HTML5 form, and the browser of support HTML5 form can be supported the broadcast of the videos such as MP4 form, FLV form, OGG form.
Wherein, described display system determines that the mode of the type of browser includes but not limited to: the type of determining browser according to the version of the browser that obtains.For example, the browser version that obtains is IE7.0, and then definite described browser is not supported video format.And for example, the version of the browser that obtains is APPStore, then determines the webpage of described browser support HTML5 form, and namely described browser is supported video format.
For example, determining the form of the document that the user uploads when described display system is that .rmvb form and the employed browser of user are not supported video format, then utilize the RMVB-FLV conversion software, convert described document to the FLV form, be about to described document and convert the Flash form to, document after will changing again is written in the webpage, and the mode that then described document can Flash is play in browser, and need not the user self-defining player plug-in is installed in advance.
And for example, determining document format that the user uploads when described display system is the video that browser that .mp4 and user were suitable for is supported this form, then directly described document is written into webpage, so that the user watches.
When the form of described document belongs to format slide, described display system becomes the Flash form with the format conversion of described document, and the described document after will changing again is written in the webpage, in order to play by described webpage.
Particularly, described display system determines that the form of described document belongs to format slide, then utilizes the switching software of PPT-FLV to convert described document to the Flash form, and the described document after will changing again is written in the webpage.
When the form of described document belongs to picture format, described display system becomes the png form with the format conversion of described document, and the described document after will changing again is written in the webpage, in order to shown by described webpage.
For example, the form of described document is the SWF form, and then described display system is utilized the SWF-PNG conversion software, converts described document to the png form, and the document after will changing is written in the webpage, and then described document can directly be given described user by web displaying.
When the form of described document belongs to text formatting, described display system is resolved described document and is determined that described document belongs to streaming document or format document, if belong to the streaming document, then according to the position relationship between each information in the described document each described information is written in the webpage, if belong to format document, then according to the position relationship between each described information of the location positioning of each information in the page in the described document, and based on the position relationship between each described information each described information is written in the webpage; Wherein, described information comprises at least a in literal, formula, the picture, and wherein, described literal comprises: Chinese character, letter, punctuation mark etc.Described text formatting includes but not limited to: txt form, word form, pdf form etc.
Wherein, the mode that described display system is resolved described document and definite described document belongs to streaming document or format document includes but not limited to:
1) the suffix name of described document is mated with the suffix name that belongs to the streaming document of presetting and the suffix name of format document respectively, and determine that according to the Doctype under the suffix name of success coupling described document belongs to streaming document or format document.For example, the default suffix name that belongs to the streaming document comprises: .txt .doc .docx, the suffix name that belongs to format document comprises: .pdf, described display system identifies the suffix .doc by name of the document that obtains, and described .doc suffix name and each default suffix name mated, then by coupling, determine that the document that obtains belongs to the streaming document.
2) based on the form of the document of identifying described document is resolved, with obtain each information in the document the position, if described position is the relative position between each information, determine that then described document belongs to the streaming document, if described position for each information in the page or leaf of place the absolute position and determine then that according to adjacent literal described document belongs to format document.For example, the form of the document of identifying is .pdf, then by described document is resolved, the position coordinates that obtains the information such as literal, symbol in the described document be the place with the absolute coordinates of one page, determine that thus described document belongs to format document.
Then, when definite described document belongs to the streaming document, described display system splits at least one object according to the type of described information in document with described document, and the type of the information that comprises based on each object is written into each object in the webpage successively.Wherein, the type of described information comprises: literal type, picture/mb-type etc.
Particularly, described display system is by resolving described document, obtain with literal, formula, or the information such as picture, and according to the position relationship between each information, the information that the type of neighbor information is identical is merged into an object, wherein, comprise an information or a plurality of information in each object, and also comprise in each object from the relative position in described document, when comprising a plurality of information in the described object, also comprise in the described object: the data that are used for position relationship between each information of expression, then described display system is according to based on the corresponding HMTL label of the type selecting of the information that comprises in each object, and is written in the webpage according to the order of each object html tag with carrying information.
For example, described display system is by resolving described document, obtain successively text object a1, object picture a2 and text object a3, comprise literal among the text object a1, position relationship between the adjacent literal and the word flow a1 sequence number 1 in described document, comprise picture among the object picture a2, and the sequence number 2 of object picture a2 in described document, text object a3 comprises literal, position relationship between the adjacent literal and the text object a3 sequence number 3 in described document, then described display system is written into respectively the expression literal with described each object successively according to the type of the information in described each object, in the html tag of picture and literal, and described label is written in the webpage successively.
When determined document belongs to format document, described display system is extracted the type of each information in the described document and each information in the absolute position of affiliated page or leaf, and according to the absolute position of each described information in the described page or leaf, determine in the ranks the position relationship with intersegmental information, again based on converting described document to the streaming document with the position relationship of intersegmental information in the ranks, and according to the processing mode of streaming document described document is written in the webpage.
Described display system is by resolving described document, determine the type of each information in the document, and according to row-coordinate and the row coordinate of each information in the described document ascending or descending ordering is carried out in the position of each information, and the position relationship of information is in the ranks determined in the ordering of and row coordinate identical based on row-coordinate, and the position relationship of determining intersegmental information based on row coordinate position relationship in the row under separately of first information of the row coordinate of last information of lastrow and current line, described display system can be determined the relative position relation of each information in the document thus, and convert described document to the streaming document accordingly, the information that the type of neighbor information is identical is incorporated in the object again, and then the type based on information in the object is written into each object in the webpage successively.
For example, described display system is obtained each literal in one page by resolving described document, the coordinate of the absolute position of picture, and with each literal, picture is capable, the row ordering, identical from row-coordinate, and during sorting successively, the row coordinate determines the position relationship of delegation's literal or graph text information, simultaneously, if the row coordinate of last information of certain a of delegation is less than row coordinate maximal value in other row, and the row coordinate of first information of (a+1) row is more than or equal to the row coordinate minimum value of other row, then described display system determines that (a+1) row information place paragraph and the capable information of a are in two paragraphs, thus, described display system is determined position relationship in the ranks and intersegmental position relationship between each information according to the absolute location coordinates of each information; Then, described display system is written into described document in the webpage according to the type of each information processing mode according to the streaming document.
As a kind of optimal way, when the form that identifies described document belongs to text formatting, described step 2) also comprise: described display system is extracted the attribute information of described document Chinese word, and the attribute information of described literal is written in the webpage, is shown with corresponding attribute for described literal.Wherein, described attribute information includes but not limited to: font size, font-weight, text color, literal highlight color, literal underscore etc.
Particularly, described display system is by the parsing to described document, obtain the attribute information of each literal in the document, and the attribute information of each literal is loaded in the tag attributes of the corresponding literal of webpage, as user during by this webpage of browser display, each word attribute in the described document will present, thus, and can be accurately and the original looks of the document that the original subscriber uploads.
In sum, the document with multiple format of the present invention is presented at the method in the webpage, the document that belongs to different-format can be converted to can be viewed the webpage format of device identification, need not browser plug-in unit be installed, be user-friendly to; In addition, document to text formatting, by the parsing of document is determined that document is to belong to streaming document or format document, for the streaming document, the present invention is loaded into each information in the document in the webpage according to the order that provides in the document, so document can be converted to pure words and picture, again pure words and picture are loaded in the webpage, the problem that can avoid the user installation plug-in unit or can't read the streaming document because browser version is not supported plug-in unit; Also have, to format document, the present invention obtains the literal in the document, the absolute position of picture, and determine in the ranks and intersegmental literal according to the absolute position, and the relativeness between literal and the picture, thus, convert document to the constant pure words of sequence of positions and picture, solve thus format document and can't directly be presented at problem in the browser.So the present invention has effectively overcome various shortcoming of the prior art and the tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not is used for restriction the present invention.Any person skilled in the art scholar all can be under spirit of the present invention and category, and above-described embodiment is modified or changed.Therefore, have in the technical field under such as and know that usually the knowledgeable modifies or changes not breaking away from all equivalences of finishing under disclosed spirit and the technological thought, must be contained by claim of the present invention.