CN112487335A - OFD file reading method based on browser - Google Patents

OFD file reading method based on browser Download PDF

Info

Publication number
CN112487335A
CN112487335A CN202011395370.1A CN202011395370A CN112487335A CN 112487335 A CN112487335 A CN 112487335A CN 202011395370 A CN202011395370 A CN 202011395370A CN 112487335 A CN112487335 A CN 112487335A
Authority
CN
China
Prior art keywords
file
ofd
page
browser
reading method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011395370.1A
Other languages
Chinese (zh)
Inventor
何冉冉
何中
鞠海林
严伟
姚童
戴建峰
顾永新
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Zhongwei Technology Software System Co ltd
Original Assignee
Jiangsu Zhongwei Technology Software System 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 Jiangsu Zhongwei Technology Software System Co ltd filed Critical Jiangsu Zhongwei Technology Software System Co ltd
Priority to CN202011395370.1A priority Critical patent/CN112487335A/en
Publication of CN112487335A publication Critical patent/CN112487335A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses an OFD file reading method based on a browser, which comprises the following steps: analyzing the OFD file to obtain file resources; turning to Json; acquiring character content and style attributes; drawing canvas and a Dom tree according to the character style attributes; drawing generates an Html page. The method does not damage the original OFD file, can quickly display the OFD file without installing any plug-in, and effectively improves the whole reading experience.

Description

OFD file reading method based on browser
Technical Field
The invention relates to the field of OFD file reading, in particular to an OFD file reading method based on a browser.
Background
At present, when reading files in the specific format of the OFD files, plug-ins or clients are required to be relied on, otherwise normal reading cannot be performed. How to read in a common browser is a very worthy technical problem to be researched under the condition of not depending on any plug-in.
Disclosure of Invention
The present invention is directed to a method for reading OFD files based on a browser, which solves one or more of the above-mentioned problems.
The invention provides an OFD file reading method based on a browser, which comprises the following steps:
analyzing the acquired file resources, acquiring an OFD file, decompressing the OFD file and acquiring the file resources;
converting the XML file into a Json array, reading the file in the file resource, and converting the XML file into a Json array;
analyzing the file data of the Json array to obtain page basic attributes and text content style attributes;
drawing canvas and a Dom tree according to the page basic attribute and the text content style attribute;
and drawing to generate an Html page for displaying.
In some embodiments, the method for analyzing and acquiring file resources specifically includes:
receiving an OFD file;
modifying the name of the suffix of the OFD file OFD into zip to obtain a zip file;
and decompressing the zip file to obtain a corresponding file folder, namely a file resource, of the OFD file after decompression.
In some embodiments, the method for converting to Json is specifically:
reading all files of the file resources, including public Res.xml and Pages folders;
reading Page number information of a Page _ N file and content.xml file in each Pages folder, and establishing a corresponding Page path, wherein N in the Page _ N is the Page number of the OFD file, and the content.xml file in the Page _ N is the content corresponding to each Page of the OFD file in the OFD folder;
merge public res. xm and content. xml files under each Page _ N into a Json array.
Xml is font configuration information and the Pages folder is page content in some embodiments.
In some embodiments, the specific way to draw canvas and Dom trees according to the page basic attributes and the text content style attributes is as follows:
drawing a canvas according to the basic attribute of the page;
and generating Div according to the text content style attribute and constructing a tree structure of the Dom tree.
In some embodiments, the page base attributes include a desired font for the page and a page base size.
In some embodiments, the textual content style attributes include boundaries, font size, relative position, horizontal axis displacement, and textual content.
In some embodiments, the relative position includes the coordinates of vector X and the coordinates of vector Y.
In some embodiments, the method for generating the Html page by drawing is specifically as follows:
and acquiring presentation tree nodes according to the Dom tree, and drawing and generating an Html file on canvas according to the text content style attributes according to each presentation tree node.
The OFD file reading method based on the browser has the advantages that:
1. the original OFD file is not damaged, and the OFD file can be displayed without deviation;
2. no plug-in and control are required to be installed;
3. the compatibility is good, and the method can be suitable for various browsers on the market.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. In the drawings:
fig. 1 is a flowchart of a method for reading an OFD file based on a browser according to a first embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure are described in more detail below with reference to the accompanying drawings. While the disclosed exemplary embodiments are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
The OFD file reading method based on the browser provided by the embodiment of the present invention is described in detail.
Referring to a flow chart of an OFD file reading method based on a browser shown in fig. 1, the present embodiment provides an OFD file reading method based on a browser, including the following steps:
step 1, analyzing and acquiring file resources, specifically comprising:
step 11, receiving an OFD file;
step 12, modifying the name of the suffix of the OFD file OFD into zip to obtain a zip file;
step 13, decompressing the zip file to obtain a corresponding file folder after the OFD file is decompressed;
step 2, reading the file in the file resource, and converting the XML file in the file resource into a Json array, which specifically comprises the following steps:
step 21, reading all files of file resources; xml is font configuration information, and the Pages folder is page content;
step 22, reading Page number information of a Page _ N file and content.xml file in each Pages folder, and establishing a corresponding Page path, wherein N in the Page _ N is the Page number of the OFD file, and the content.xml file in the Page _ N is the content corresponding to each Page of the OFD file in the OFD folder;
step 23, merging and converting public Res.xm and content.xml files under each Page _ N into Json files;
step 3, acquiring page basic attributes and text content style attributes, wherein the page basic attributes comprise fonts and page basic size required by a page;
the text content style attributes comprise boundaries, fonts, font sizes, relative positions, horizontal axis displacement and text contents;
the method for acquiring the page basic attribute and the text content style attribute specifically comprises the following steps:
step 31, analyzing file data of the Json array;
32, obtaining ofd Font, ofd Area, ofd TextObjects and ofd TextCode in a Json array, obtaining the Font required by the page according to ofd Font, obtaining the basic Size of the page according to ofd Area, and respectively obtaining the Boundary, the Font and the Font Size according to ofd Boundary, Font and Size in the TextObjects; obtaining coordinates of vector X and coordinates of vector Y in relative positions from X and Y in ofd: TextCode; acquiring horizontal axis displacement according to ofd DeltaX in the TextCode, and acquiring text content according to ofd TextCode;
step 4, drawing canvas and Dom trees according to the page basic attribute and the character content style attribute, wherein the specific operation is as follows:
drawing canvas according to ofd, Area set page pagesize;
selecting a Font in ofd: Font according to a Font value in ofd: TextObject, setting a Font Size according to a Size value in ofd: TextObject, setting Top and Left values of Div relative to a page according to a Boundary value in ofd: TextObject, setting a position of a character relative to a parent level Div according to X, Y in ofd: TextCode, setting a relative offset of each character according to DeltaX in ofd: TextCode, generating a new Div, and constructing a tree structure of a Dom tree;
and step 5, acquiring the nodes of the presentation tree according to the Dom tree, and drawing and generating an Html file on the canvas according to the text content style attributes according to each node of the presentation tree to display the Html file.
The foregoing is only a preferred form of the invention and it should be noted that several similar variations and modifications could be made by one skilled in the art without departing from the inventive concept and these should also be considered within the scope of the invention.

Claims (9)

1. An OFD file reading method based on a browser is characterized by comprising the following steps:
analyzing the acquired file resources, acquiring an OFD file, decompressing the OFD file and acquiring the file resources;
converting the XML file into a Json array, reading the file in the file resource, and converting the XML file into a Json array;
analyzing the file data of the Json array, and acquiring page basic attributes and text content style attributes;
drawing canvas and a Dom tree according to the page basic attribute and the text content style attribute;
and drawing to generate an Html page for displaying.
2. The OFD file reading method based on the browser of claim 1, wherein the method for obtaining file resources by parsing specifically includes:
receiving an OFD file;
modifying the name of the suffix of the OFD file OFD into zip to obtain a zip file;
and decompressing the zip file to obtain a corresponding file folder, namely a file resource, of the OFD file after decompression.
3. The OFD file reading method based on a browser of claim 1, wherein the method of converting to Json specifically comprises:
reading all files of the file resources, including public Res.xml and Pages folders;
reading Page number information of a Page _ N file and content.xml file in each Pages folder, and establishing a corresponding Page path, wherein N in the Page _ N is the Page number of the OFD file, and the content.xml file in the Page _ N is the content corresponding to each Page of the OFD file in the OFD folder;
merge public res. xm and content. xml files under each Page _ N into a Json array.
4. The OFD file reading method based on a browser of claim 3, wherein the publicres.
5. The OFD file reading method based on a browser of claim 1, wherein the specific way of drawing canvas and Dom trees according to the page basic attribute and the text content style attribute is as follows:
drawing a canvas according to the basic attribute of the page;
and generating Div content according to the text content style attributes, and constructing a tree structure of the Dom tree.
6. The browser-based OFD file reading method according to claim 1 or 5, wherein said page basic properties include page required font configuration information and page basic size.
7. The browser-based OFD file reading method according to claim 1 or 5, wherein said text content style attributes include a boundary, a font size, a relative position, a horizontal axis displacement, and a text content.
8. The browser-based OFD file reading method according to claim 7, wherein said relative position includes a coordinate of vector X and a coordinate of vector Y.
9. The OFD file reading method based on a browser of claim 1, wherein the method for generating the Html page by drawing specifically comprises:
and acquiring presentation tree nodes according to the Dom tree, and drawing and generating an Html file on canvas according to the text content style attributes according to each presentation tree node.
CN202011395370.1A 2020-12-03 2020-12-03 OFD file reading method based on browser Pending CN112487335A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011395370.1A CN112487335A (en) 2020-12-03 2020-12-03 OFD file reading method based on browser

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011395370.1A CN112487335A (en) 2020-12-03 2020-12-03 OFD file reading method based on browser

Publications (1)

Publication Number Publication Date
CN112487335A true CN112487335A (en) 2021-03-12

Family

ID=74939046

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011395370.1A Pending CN112487335A (en) 2020-12-03 2020-12-03 OFD file reading method based on browser

Country Status (1)

Country Link
CN (1) CN112487335A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110717127A (en) * 2019-10-14 2020-01-21 北京华宇信息技术有限公司 Method and device for on-line analysis and browsing of OFD (office file)
CN110765385A (en) * 2019-10-24 2020-02-07 北京华宇信息技术有限公司 Method and system for browsing OFD document webpage end
CN111767491A (en) * 2020-06-30 2020-10-13 杭州天谷信息科技有限公司 OFD document analysis display method and system based on browser
CN111897776A (en) * 2020-06-22 2020-11-06 百望股份有限公司 OFD document processing method, electronic device and computer-readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110717127A (en) * 2019-10-14 2020-01-21 北京华宇信息技术有限公司 Method and device for on-line analysis and browsing of OFD (office file)
CN110765385A (en) * 2019-10-24 2020-02-07 北京华宇信息技术有限公司 Method and system for browsing OFD document webpage end
CN111897776A (en) * 2020-06-22 2020-11-06 百望股份有限公司 OFD document processing method, electronic device and computer-readable storage medium
CN111767491A (en) * 2020-06-30 2020-10-13 杭州天谷信息科技有限公司 OFD document analysis display method and system based on browser

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WINSTON.H: "《https://blog.csdn.net/u013823545/article/details/108151914》", 21 August 2020 *

Similar Documents

Publication Publication Date Title
JP4344693B2 (en) System and method for browser document editing
US10210144B2 (en) Creation and display of a webpage with alternative layouts for different webpage widths
US8051371B2 (en) Document analysis system and document adaptation system
US9058318B2 (en) Flexible web page template building system and method
CN108415702B (en) Dynamic rendering method and device for application interface of mobile terminal
CN105975576B (en) Terminal content adaptive display method and device and terminal
US8645823B1 (en) Converting static websites to resolution independent websites in a web development environment
CN107885792B (en) Webpage article display method, device and system
CN104050238A (en) Map labeling method and map labeling device
WO2016015564A1 (en) Method and apparatus for displaying document
CN113609820A (en) Method, device and equipment for generating word file based on extensible markup language file
EP2599013A1 (en) Visual separator detection in web pages by using code analysis
US9886426B1 (en) Methods and apparatus for generating an efficient SVG file
CN114791988A (en) Browser-based PDF file analysis method, system and storage medium
CN111274761A (en) Font editing method and system using SVG format, and computer-readable recording medium
CN112433995A (en) File format conversion method, system, computer equipment and storage medium
CN113449502A (en) Document generation method and system based on dynamic data
CN112487335A (en) OFD file reading method based on browser
CN111143749A (en) Webpage display method, device, equipment and storage medium
CN117055987A (en) Webpage display method and device, electronic equipment and computer readable storage medium
CN115309476A (en) Browser-based ofd file display and editing method
CN115169292A (en) Document processing method and device, electronic equipment and computer readable storage medium
JP4803218B2 (en) Information output device and information output processing program
CN111241788A (en) Document conversion method, device, equipment and storage medium based on linear model
JP2011216126A (en) Information output device and information output processing program

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210312