CN113723059B - Method and system for converting HTML into PDF based on blockchain - Google Patents

Method and system for converting HTML into PDF based on blockchain Download PDF

Info

Publication number
CN113723059B
CN113723059B CN202110867977.3A CN202110867977A CN113723059B CN 113723059 B CN113723059 B CN 113723059B CN 202110867977 A CN202110867977 A CN 202110867977A CN 113723059 B CN113723059 B CN 113723059B
Authority
CN
China
Prior art keywords
html
blockchain
file
transaction request
intelligent contract
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
CN202110867977.3A
Other languages
Chinese (zh)
Other versions
CN113723059A (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.)
Weiyisign Hangzhou Technology Co ltd
Original Assignee
Weiyisign Hangzhou 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 Weiyisign Hangzhou Technology Co ltd filed Critical Weiyisign Hangzhou Technology Co ltd
Priority to CN202110867977.3A priority Critical patent/CN113723059B/en
Publication of CN113723059A publication Critical patent/CN113723059A/en
Application granted granted Critical
Publication of CN113723059B publication Critical patent/CN113723059B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • G06F40/154Tree transformation for tree-structured or markup documents, e.g. XSLT, XSL-FO or stylesheets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • Technology Law (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • General Engineering & Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application relates to a method and a system for converting HTML into PDF based on a blockchain, wherein the method comprises the following steps: receiving a transaction request initiated by a target transaction, wherein the transaction request comprises HTML information, XML information and XSLT information; verifying the legitimacy of the transaction request by an intelligent contract deployed on the blockchain; if the validity check is passed, the corresponding HTML content is converted into a PDF file through an intelligent contract according to the transaction request, and the method and the device solve the problems that the file format conversion mode is complex, the file information is easy to leak and difficult to manage, reduce the time related to processing the file information, reduce the cost and the risk of easy leakage of the file information, and improve the credibility and the visibility.

Description

Method and system for converting HTML into PDF based on blockchain
Technical Field
The application relates to the field of electronic documents, in particular to a method and a system for converting HTML into PDF based on blockchain.
Background
Currently, PDF, which is a digital format for representing documents that enables users to easily and reliably exchange and view electronic documents independent of any document creation, viewing, or printing environment, has been widely used for electronic form exchange of documents; users can combine PDF with software for creating, viewing, printing and processing PDF in various ways to meet the requirements of making, exchanging and using various electronic documents.
The traditional PDF mainly adopts software such as Microsoft Word or WPS Office to edit the content and then outputs the content into a PDF file through format conversion. In general, tool software such as Adobe Acrobat Pro can handle PDFs efficiently on any device at any time and place.
However, with the popularization of electronic products such as electronic invoices, electronic insurance policies, electronic medical records, electronic contracts, and the like, users are more required to create, edit, transfer, and the like in a service flow instead of independently creating or editing a PDF file through software.
Taking a part of electronic labor contract contracting platform as an example, the method for on-line editing and generating the electronic labor contract cannot be provided for personnel and workers, the method still relies on the software such as Microsoft Word or WPS Office to edit and then convert the software into PDF and upload the PDF to the electronic labor contract contracting platform, and the use cost of the personnel and workers is obviously increased. Furthermore, it is difficult to establish a sound electronic labor contract information protection system by using the existing centralized electronic labor contract establishment platform, so as to ensure that electronic labor contract information is not illegally collected, used, processed, transmitted, provided and disclosed, and to monitor whether the electronic labor contract establishment platform illegally provides services such as electronic labor contract review, calling and the like to others.
At present, no effective solution is proposed for the problems of complicated file format conversion mode, easy leakage of file information and difficult supervision in the related technology.
Disclosure of Invention
The embodiment of the application provides a method and a system for converting HTML into PDF based on blockchain, which at least solve the problems of complex file format conversion mode, easy leakage of file information and difficult supervision in the related technology.
In a first aspect, an embodiment of the present application provides a method for converting HTML into PDF based on blockchain, where the method includes:
Receiving a transaction request initiated by a target transaction, wherein the transaction request comprises HTML information, XML information and/or XSLT information;
verifying the legitimacy of the transaction request by an intelligent contract deployed on a blockchain;
if the validity check is passed, the corresponding HTML content is converted into a PDF file through the intelligent contract according to the transaction request by the validity check.
In some of these embodiments, verifying the validity of the transaction request by a smart contract deployed on a blockchain; if the validity check is passed, according to the transaction request, converting the HTML content into a PDF file through the intelligent contract comprises:
Invoking verification logic through an intelligent contract deployed on a blockchain to verify the validity of an HTML character string in the transaction request, wherein the HTML information comprises the HTML character string;
and converting the corresponding HTML content into a PDF file through the intelligent contract.
In some of these embodiments, before converting the corresponding HTML content into a PDF file by the smart contract, the method further includes:
and if the tags in the HTML character string are not closed, calling tag processing logic through the intelligent contract to perform closing processing on the non-closed tags.
In some of these embodiments, verifying the validity of the transaction request by a smart contract deployed on a blockchain; if the validity check is passed, according to the transaction request, converting the corresponding HTML content into a PDF file through the intelligent contract comprises:
Invoking verification logic through an intelligent contract deployed on a blockchain to verify the validity of an HTML file path in the transaction request, wherein the HTML information comprises the HTML file path;
acquiring a corresponding HTML file through the intelligent contract according to the HTML file path;
and converting the HTML content into a PDF file through the intelligent contract.
In some of these embodiments, verifying the validity of the transaction request by a smart contract deployed on a blockchain; if the validity check is passed, according to the transaction request, converting the corresponding HTML content into a PDF file through the intelligent contract comprises:
Calling verification logic through an intelligent contract deployed on a blockchain to verify an XML file path and an XSL file path in the transaction request, wherein the XML information comprises the XML file path and the XSLT information comprises the XSL file path;
According to the XSL parameters corresponding to the XSL file path, converting the XML file corresponding to the XML file path into an HTML file through the intelligent contract;
and converting the HTML content into a PDF file through the intelligent contract.
In some embodiments, after converting the corresponding HTML content into a PDF file by the smart contract according to the transaction request if the validity check passes, the method further includes:
performing BASE64 coding on the PDF file through the intelligent contract;
Transmitting the coded character string to an initiator of the target transaction.
In some of these embodiments, transmitting the encoded string to the initiator of the target transaction comprises:
dividing all the coded character strings or the coded character strings according to a preset proportion, and storing the character strings in an account book of the blockchain;
The stored transaction Ha Xichuan is entered into the initiator of the target transaction.
In some embodiments, after converting the corresponding HTML content into a PDF file by the smart contract according to the transaction request if the validity check passes, the method further includes:
Storing the PDF file into a file server, and transmitting an index and/or a storage address of the PDF file stored by the file server to an initiator of the target transaction;
and acquiring the PDF file according to the index and/or the storage address.
In some embodiments, after converting the corresponding HTML content into a PDF file by the smart contract according to the transaction request if the validity check passes, the method further includes:
and converting the PDF file into an OFD file through the intelligent contract.
In a second aspect, an embodiment of the present application provides a system for converting HTML into PDF based on a blockchain, where the system includes an intelligent contract, a blockchain network, and an SDK for interaction between the blockchain and an application, where the intelligent contract includes a request receiving module, a validity checking module, and an HTML conversion module, and the blockchain network includes a P2P network, a consensus algorithm, a chained ledger store, and MSP identity management;
The request receiving module receives a transaction request initiated by the SDK or other intelligent contracts, wherein the transaction request comprises HTML information, XML information and/or XSLT information;
the validity verification module verifies the validity of the transaction request;
The HTML conversion module converts corresponding HTML content into a PDF file according to the transaction request;
the SDK interacted between the blockchain and the application terminal is used for storing an identity certificate for interaction between the user and the blockchain.
Compared with the related art, the method and the system for converting the HTML into the PDF based on the blockchain provided by the embodiment of the application are used for receiving the transaction request initiated by the target transaction, wherein the transaction request comprises the HTML information, the XML information and the XSLT information; verifying the legitimacy of the transaction request by an intelligent contract deployed on the blockchain; if the validity check is passed, the corresponding HTML content is converted into a PDF file through an intelligent contract according to the transaction request, so that the problems of complex file format conversion mode, easy leakage of file information and difficult supervision are solved, the time related to processing the file information is reduced, the cost and the risk of easy leakage of the file information are reduced, and meanwhile, the credibility and the visibility are improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute a limitation on the application. In the drawings:
FIG. 1 is a flowchart of the steps for contracting for electronic labor in the related art;
FIG. 2 is a schematic diagram of a method of creating a smart contract;
FIG. 3 is a schematic diagram of a method of invoking a smart contract;
FIG. 4 is a schematic diagram of a method of creating a smart contract and invoking a smart contract;
FIG. 5 is a flowchart of steps for a method for converting HTML to PDF based on blockchain in accordance with an embodiment of the present application;
FIG. 6 is a timing diagram of the smart contract converting an HTML string to a PDF, as shown in FIG. 6;
FIG. 7 is a timing diagram of a smart contract converting HTML to PDF according to an HTML file path;
FIG. 8 is a flowchart of steps for a method for converting HTML to PDF based on blockchain in accordance with an embodiment of the present application;
fig. 9 is a schematic diagram of an internal structure of an electronic device according to an embodiment of the present application.
Description of the drawings: 80. an intelligent contract; 81. a blockchain network; 82. the SDK is interacted between the block chain and the application end; 83. a request receiving module; 84. a validity checking module; 85. an HTML conversion module; 86. a P2P network; 87. a consensus algorithm; 88. storing a chained account book; 89. MSP identity management.
Detailed Description
The present application will be described and illustrated with reference to the accompanying drawings and examples in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by a person of ordinary skill in the art based on the embodiments provided by the present application without making any inventive effort, are intended to fall within the scope of the present application.
It is apparent that the drawings in the following description are only some examples or embodiments of the present application, and it is possible for those of ordinary skill in the art to apply the present application to other similar situations according to these drawings without inventive effort. Moreover, it should be appreciated that while such a development effort might be complex and lengthy, it would nevertheless be a routine undertaking of design, fabrication, or manufacture for those of ordinary skill having the benefit of this disclosure, and thus should not be construed as having the benefit of this disclosure.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is to be expressly and implicitly understood by those of ordinary skill in the art that the described embodiments of the application can be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms used herein should be given the ordinary meaning as understood by one of ordinary skill in the art to which this application belongs. The terms "a," "an," "the," and similar referents in the context of the application are not to be construed as limiting the quantity, but rather as singular or plural. The terms "comprising," "including," "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to only those steps or elements but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The terms "connected," "coupled," and the like in connection with the present application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as used herein means two or more. "and/or" describes an association relationship of an association object, meaning that there may be three relationships, e.g., "a and/or B" may mean: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship. The terms "first," "second," "third," and the like, as used herein, are merely distinguishing between similar objects and not representing a particular ordering of objects.
PDF, a digital format for representing documents, has been widely used for electronic form exchange of documents because it enables users to exchange and view electronic documents easily and reliably without depending on any document creation, viewing or printing environment. Users may combine PDF with software for creating, viewing, printing, and processing PDF in a variety of ways to meet the production, exchange, and use requirements of various electronic documents, including:
preserving fidelity of documents independent of devices, platforms, and software;
combining the content of different sources (web site, word processing and spreadsheet software, scanned documents, photographs and graphics) into one independent document while maintaining the integrity of all original source documents;
Collaborative editing of a document from a plurality of locations or platforms;
Verifying authenticity by digital signature;
setting security and rights to enable the creator to maintain control over documents and related permissions;
for the disabled user, the content is accessible;
the extraction and reuse of the content are feasible by using other file formats and application programs;
data is collected using electronic forms and integrated into a business system.
The traditional PDF mainly adopts software such as Microsoft Word or WPS Office to edit the content and then outputs the content into a PDF file through format conversion. In general, tool software such as Adobe Acrobat Pro can handle PDFs efficiently on any device at any time and place.
However, with the popularization of electronic products such as electronic invoices, electronic insurance policies, electronic medical records, electronic contracts, and the like, users are more required to create, edit, transfer, and the like in a service flow instead of independently creating or editing a PDF file through software.
While modern technology has evolved from stone tablets and paper folders to hard disk drives and cloud platforms, the underlying structure is the same. Because there is no unified system for managing the identities of network participants, tracing is very laborious and the information of each database in the system is isolated, which also means a single point of failure. Even if the requirements for visibility and trust are clear, it is very difficult to construct a record system across service networks under the current information and flow sharing method of branch-and-break.
In the related art, taking an example of contracting for electronic labor as an example, fig. 1 is a flowchart of the steps of contracting for electronic labor in the related art, and the operation steps thereof are as follows:
Step S102, accessing an electronic labor contract establishment platform;
step S104, uploading labor contract text by a method provided by an electronic labor contract making platform;
Step S106, generating an electronic file of the labor contract through a creation service provided by the electronic labor contract establishment platform;
Step S108, signing the electronic labor contract by using reliable electronic signatures by a personnel unit and a laborer respectively;
Step S110, a person prompts the worker to download and save the electronic labor contract text in time by using a person unit, and informs the worker of the method for checking and downloading the electronic labor contract.
Through steps S102 to S110, the electronic labor contract formation platform cannot provide an online editing and electronic labor contract generation method for personnel and laborers, and still relies on converting the electronic labor contract into PDF after editing by software such as Microsoft Word or WPS Office, and uploading the PDF to the electronic labor contract formation platform, so that the use cost of the personnel and laborers is obviously increased. Furthermore, it is difficult to establish a sound electronic labor contract information protection system by using the existing centralized electronic labor contract formation platform, so as to ensure that the electronic labor contract information is not illegally collected, used, processed, transmitted, provided and disclosed, and to monitor whether the electronic labor contract formation platform illegally provides services such as electronic labor contract review, calling and the like to others.
The inventor researches and discovers that the blockchain is an important component of a new generation of information technology, is novel database software integrated by multiple technologies such as a distributed network, an encryption technology, an intelligent contract and the like, has the characteristics of traceability, supervision, data credibility, information disclosure and the like based on the technical characteristics of a distributed consensus mechanism, the intelligent contract, transparent data, non-falsification and the like, can provide technical support for improving the effectiveness and the credit of entity economy and public service, value circulation and multiparty cooperation, reduces the time, cost and risk related to processing private information, improves trust and visibility and is a natural credible basic technology.
Accelerating the application of the protection technology based on the blockchain, promoting the development of technical products such as multiparty consensus, trusted data sharing and the like, and being beneficial to establishing a trusted digital society.
The invention provides a method and a system for converting HTML into PDF based on blockchain, which aims to solve the problems and provide low-cost and high-credibility support for blockchain electronic contract or other file, document and other blockchain document applications.
Blockchains are generally divided into three types: public chain (Public Blockchain), private chain (Private Blockchain) and federated chain (Consortium Blockchain). In addition, there may be combinations of the above types, such as private chain+federation chain, federation chain+public chain, and the like.
Among them, the highest degree of decentralization is the public chain. The public chain is represented by bitcoin, ethernet, and participants joining the public chain (also referred to as nodes in the blockchain) can read data records on the chain, participate in transactions, and compete for accounting rights for new blocks, etc. Moreover, each node can freely join or leave the network and perform relevant operations.
The private chain is the opposite, the write rights of the network are controlled by an organization or organization, and the data read rights are specified by the organization. In short, the private chain may be a weakly centralized system with strict restrictions on the nodes and a small number of nodes. This type of blockchain is more suitable for use within a particular organization.
The alliance chain is a block chain between public and private chains, and can realize 'partial decentralization'. Each node in the federation chain typically has an entity organization or organization corresponding thereto; nodes join the network by authorization and form a benefit-related federation, which collectively maintains blockchain operation.
Based on the basic characteristics of a blockchain, a blockchain is typically made up of several blocks. The time stamps corresponding to the creation time of the block are recorded in the blocks respectively, and all the blocks form a time-ordered data chain strictly according to the time stamps recorded in the blocks.
For real data generated in the physical world, the real data can be constructed into a standard transaction (transaction) format supported by a blockchain, then the transaction is issued to the blockchain, the node equipment in the blockchain performs consensus processing on the received transaction, and after the consensus is achieved, the node equipment serving as an accounting node in the blockchain packages the transaction into a block, and the persistence is performed in the blockchain.
Among other things, the consensus algorithm supported in the blockchain may include:
A first type of consensus algorithm, namely a consensus algorithm that node equipment needs to contend for the accounting rights of the accounting period of each round; for example, consensus algorithms such as Proof of Work (POW), proof of equity (POS), proof of commission (DELEGATED PROOF OF STAKE, DPOS);
A second type of consensus algorithm, namely a consensus algorithm which pre-elects accounting nodes (without competing for accounting rights) for each round of accounting period; for example, a consensus algorithm such as Bayesian fault tolerance (PRACTICAL BYZANTINE FAULT TOLERANCE, PBFT) is used.
In blockchain networks employing a first type of consensus algorithm, node devices competing for accounting rights may perform a transaction after receiving the transaction. One of the node devices competing for the accounting rights may win out of the process of competing for the accounting rights in this round, becoming an accounting node. The accounting node may package the received transaction with other transactions to generate the latest chunk and send the generated latest chunk or chunks of the latest chunk to other node devices for consensus.
In blockchain networks employing a second type of consensus algorithm, node devices with accounting rights are already well-established prior to this round of accounting. Thus, after receiving a transaction, the node device may send the transaction to the billing node if it is not itself the billing node for the current round. For the billing node of the present round, the transaction may be performed during or before packaging the transaction with other transactions to generate the latest block. After generating the latest block, the accounting node may send the latest block or the block head of the latest block to other node devices for consensus.
As described above, regardless of which consensus algorithm is used by the blockchain as shown above, the accounting node of the round may package the received transaction to generate the latest chunk and send the generated latest chunk or chunks of the latest chunk to other node devices for consensus verification. If the other node equipment receives the latest block or the block head of the latest block, and is verified to have no problem, the latest block can be added to the end of the original blockchain, so that the accounting process of the blockchain is completed. Other nodes may also execute transactions contained in the block during the verification of the new block or block header from the accounting node.
In the blockchain domain, an important concept is Account (Account); taking an ethernet as an example, the ethernet generally divides accounts into two types, an external account and a contract account; the external account is an account directly controlled by the user, and is also called a user account; the contract account is an account (i.e., smart contract) that is created by the user through an external account and contains a contract code. Of course, for some blockchain projects (such as ant blockchains) derived from the ethernet-based architecture, the account types supported by the blockchains can be further expanded, which is not particularly limited in this specification.
For accounts in a blockchain, the account status of the account is typically maintained by a structure. When a transaction in a block is executed, the status of the account in the blockchain associated with the transaction will typically change.
Taking ethernet as an example, the structure of an account typically includes fields such as Balance, nonce, code, and Storage. Wherein:
A Balance field for maintaining a current account Balance of the account;
A Nonce field for maintaining a number of transactions for the account; the counter is used for guaranteeing that each transaction can be processed only once, and effectively avoiding replay attack;
A Code field for maintaining a contract Code for the account; in practical applications, only the hash value of the contract Code is usually maintained in the Code field; thus, the Code field is also commonly referred to as Codehash field.
A Storage field for maintaining the stored contents of the account (default field value is null); for a contract account, a separate storage space is generally allocated to store the storage content of the contract account; this separate storage space is commonly referred to as the account store for the contract account. The stored content of the contract account is stored in the independent storage space by a data structure which is generally constructed into MPT (MerklePatriciaTrie) trees; among them, the MPT tree constructed based on the stored contents of the contract account is also commonly referred to as Storage tree. Whereas the Storage field typically only maintains the root node of the Storage tree; thus, the Storage field is also commonly referred to as StorageRoot field.
For the external account, the field values of the Code field and the Storage field shown above are null values.
Furthermore, in practical applications, whether public, private or federated, it is possible to provide Smart contract (Smart contract) functionality. Intelligent contracts on a blockchain are contracts on a blockchain that can be executed by a transaction trigger. The smart contracts may be defined in the form of codes.
Taking the ethernet as an example, a user is supported to create and invoke some complex logic in the ethernet network. The ethernet is used as a programmable blockchain, and the core of the ethernet is an Ethernet Virtual Machine (EVM), and each ethernet node can run the EVM. EVM is a graphics-based virtual machine through which various complex logic can be implemented. The user's issuing and invoking of the smart contract in the ethernet is running on the EVM. In fact, the EVM runs directly on virtual machine code (virtual machine bytecode, hereinafter "bytecode"), so the smart contract deployed on the blockchain may be bytecode.
FIG. 2 is a schematic diagram of a method for creating a smart contract, as shown in FIG. 2, where Bob sends a Transaction (Transaction) containing information for creating a smart contract to an Ethernet network, and each node can execute the Transaction in the EVM. In fig. 1, the From field of the transaction is used To record an address of an account initiating creation of an intelligent contract, the contract code stored by the field value of the Data field of the transaction may be a byte code, and the field value of the To field of the transaction is a null account. After agreement is reached between nodes through the consensus mechanism, the intelligent contract is successfully created, and the subsequent user can call the intelligent contract.
After the intelligent contract is created, a contract account corresponding to the intelligent contract appears on the blockchain and has a specific address; for example, "0x68e12cf284 …" in each node in FIG. 2 represents the address of this contract account created; the contract Code (Code) and the account store (Storage) will be saved in the account store of the contract account. The behavior of the smart contract is controlled by the contract code, and the account store of the smart contract maintains the state of the contract. In other words, the smart contract causes a virtual account to be generated on the blockchain that includes the contract code and account store.
The foregoing mentions that the Data field containing the transaction that created the smart contract holds may be the bytecode of the smart contract. Bytecode consists of a series of bytes, each of which can identify an operation. Based on various aspects of development efficiency, readability and the like, a developer can select a high-level language to write intelligent contract codes instead of directly writing byte codes. For example, a high-level language such as Solidity, serpent, LLL language may be employed. For smart contract code written in a high-level language, it may be compiled by a compiler to generate bytecodes that may be deployed onto a blockchain.
Taking Solidity language as an example, the contract code written with it is very similar to classes (classes) in object-oriented programming languages, and multiple members can be declared in a contract, including state variables, functions, function modifiers, events, and so on. The state variable is a value permanently stored in an account store (Storage) field of the smart contract for saving the state of the contract.
Fig. 3 is a schematic diagram of a method for invoking a smart contract, as shown in fig. 3, taking ethernet as an example, bob sends a transaction containing information of invoking the smart contract to the ethernet network, and each node may execute the transaction in the EVM. The From field of the transaction in fig. 3 is used for recording the address of the account initiating the call of the smart contract, the To field is used for recording the address of the called smart contract, and the Data field of the transaction is used for recording the method and parameters for calling the smart contract. After invoking the smart contract, the account status of the contract account may change. Subsequently, a client may view the account status of the contract account through the accessed blockchain node (e.g., node 1 in FIG. 3).
The intelligent contract can be independently executed at each node in the blockchain network in a specified mode, all execution records and data are stored on the blockchain, so that when the transaction is executed, transaction credentials which cannot be tampered and cannot be lost are stored on the blockchain.
FIG. 4 is a schematic diagram of a method of creating a smart contract and invoking a smart contract, as shown in FIG. 4. To create an intelligent contract in the ethernet, the intelligent contract needs to be written, changed into byte codes, deployed to a blockchain and the like. The intelligent contract is called in the Ethernet, a transaction pointing to the intelligent contract address is initiated, EVM of each node can execute the transaction respectively, and intelligent contract codes are distributed and run in the virtual machine of each node in the Ethernet network.
The invention converts the HTML and CSS into PDFs meeting the standard through the blockchain intelligent contract, the PDFs are accessible, searchable and available for indexing, and the related conversion behavior is traceable and auditable.
The implementation process of the invention mainly calls a PDF conversion engine through a blockchain intelligent contract, and uses structural information from HTML to create PDF/A, PDF/UA or PDF with labels. The semantic and structural information existing in the HTML and CSS are fully utilized and mapped to the associated objects and styles, and the HTML content is converted into a rich and intelligent PDF document.
HTML (hypertext markup language) is mainly used to construct hypertext files and to put applications pointing to another file into one file.
XML (extensible markup language) is a source language that allows users to define their own markup language, which provides a uniform way to describe and exchange structured data that is independent of an application or vendor.
XSL (extended style sheet language) is mainly based on style sheet language for XML.
XSLT refers to XSL transformation, i.e. transforming an XML document into another document, such as HTML.
PDF (portable document format) is mainly used for a file format developed by a file exchange in a manner independent of an application program, an operating system, and hardware. PDF files are a form of data presentation for electronic documents based on the PostScript language image model that allows users to exchange and view electronic documents independent of the document's creation, viewing, or printing environment.
OFD (open layout document) mainly uses two-dimensional vector imaging model to describe any typeset primitive object, including text, graphics, image, etc., and generates an output result irrelevant to the device, which is used for executing program and transmitting it to output device.
It should be noted that, in the specific embodiment of the present invention, the HYPERLEDGER FABRIC blockchain network is adopted, the Java language is used to write the smart contracts, and the iText and pdfHTML components are used in the smart contracts, but the blockchain network, the smart contract programming language and the introduced components do not affect the method of the present invention, and other public chains, alliance chains and private chains are also applicable. The programming language for writing the smart contract is not limited to Java, but may be GoLang, node. Js, solidity, and the like. When the programming language is used, components corresponding to the maturity of the language can be introduced, so that the workload of coding is reduced, and the stability and the reliability of the intelligent contract are improved.
An embodiment of the present application provides a method for converting HTML into PDF based on a blockchain, and fig. 5 is a flowchart illustrating steps of the method for converting HTML into PDF based on a blockchain according to an embodiment of the present application, as shown in fig. 5, the method includes the following steps:
step S502, a transaction request initiated by a target transaction is received, wherein the transaction request comprises HTML information, XML information and/or XSLT information;
Step S504, verifying the validity of the transaction request through an intelligent contract deployed on the blockchain;
step S506, if the validity check is passed, the corresponding HTML content is converted into a PDF file through the intelligent contract according to the transaction request.
Through the steps S502 to S506 in the embodiment of the application, the problems of complicated file format conversion mode, easy leakage of file information and difficult supervision are solved, the time related to processing the file information is reduced, the cost and the risk of easy leakage of the file information are reduced, and meanwhile, the credibility and the visibility are improved.
In some of these embodiments, steps S504 and S506, the validity of the transaction request is verified by a smart contract deployed on the blockchain; if the validity check is passed, converting the HTML content into a PDF file through the intelligent contract according to the transaction request comprises the following steps:
Invoking verification logic through an intelligent contract deployed on the blockchain to verify the validity of an HTML character string in the transaction request, wherein the HTML information comprises the HTML character string;
the corresponding HTML content is converted into a PDF file by the smart contract.
Specifically, fig. 6 is a timing diagram of the smart contract converting the HTML string to PDF, as shown in fig. 6;
the SDK or other blockchains initiate a transaction request to the blockchain in a cross-chain mode, wherein the transaction request comprises a character string of HTML to be converted;
the intelligent contract deployed on the blockchain responds to the transaction request, and the intelligent contract calls the verification logic to verify the validity of the HTML character string in the transaction request;
The HTML character string is verified to be legal, and the intelligent contract calls convertToPdf () method in HtmlConverter objects to convert the HTML into PDF;
Optionally, the HTML in the transaction request is not closed, and the smart contract invokes the tag processing logic to perform a closing process on the non-closed tag.
In some of these embodiments, steps S504 and S506, the validity of the transaction request is verified by a smart contract deployed on the blockchain; if the validity check is passed, converting the corresponding HTML content into a PDF file through the intelligent contract according to the transaction request comprises the following steps:
Invoking verification logic through an intelligent contract deployed on the blockchain to verify the validity of an HTML file path in the transaction request, wherein the HTML information comprises the HTML file path;
Acquiring a corresponding HTML file through an intelligent contract according to the HTML file path;
The HTML content is converted into a PDF file by an intelligent contract.
Specifically, fig. 7 is a timing diagram of the smart contract converting HTML to PDF according to the HTML file path, as shown in fig. 7;
The SDK or other blockchains initiate a transaction request to the blockchain in a cross-chain mode, wherein the transaction request comprises a path of an HTML file to be converted;
The intelligent contract deployed on the blockchain responds to the transaction request, and the intelligent contract calls the verification logic to verify the validity of the HTML file path in the transaction request;
The HTML file path verification is legal, and the smart contract calls convertToPdf () method in HtmlConverter objects to convert the source HTML content pointed by the HTML file path into a PDF file.
The convertToPdf () method creates a complete PDF file. Once the input is parsed and converted to PDF, any File, outputStream, pdfWriter or PdfDocument passed to the convertToPdf () method is turned off.
In some cases, the smart contract may wish to add some extra information to documents, or may temporarily not want to convert HTML to PDF files, but rather to convert it to a series of objects that may be used for different purposes.
Optionally, the smart contract call convertToDocument () method returns a Document instance and may further use this Document instance to add some additional content.
Optionally, the smart contract call convertToElements () method creates a IElement list of objects.
In some of these embodiments, steps S504 and S506, the validity of the transaction request is verified by a smart contract deployed on the blockchain; if the validity check is passed, converting the corresponding HTML content into a PDF file through the intelligent contract according to the transaction request comprises the following steps:
The method comprises the steps of calling verification logic through an intelligent contract deployed on a blockchain, and verifying an XML file path and an XSL file path in a transaction request, wherein XML information comprises the XML file path and XSLT information comprises the XSL file path;
according to the XSL parameters corresponding to the XSL file path, converting the XML file corresponding to the XML file path into an HTML file through an intelligent contract;
The HTML content is converted into a PDF file by an intelligent contract.
Specifically, the SDK or other blockchains initiate a transaction request to the blockchain in a cross-chain mode, wherein the transaction request comprises a path of an XML file to be converted and a path of an XSL file;
the intelligent contract deployed on the blockchain responds to the transaction request, and the intelligent contract call checking logic checks the legitimacy of the XML file path and the XSL file path in the transaction request;
The XML and XSL file path verification is legal, and the intelligent contract calls newTransformer () method TransformerFactory to obtain the Transformer object of the XSL parameters. The smart contract then calls the transform () method of the transform object to complete the conversion of XML to HTML. Finally, the intelligent contract calls convertToPdf () method HtmlConverter to complete the conversion of the PDF file.
In some embodiments, after converting the corresponding HTML content into a PDF file through a smart contract according to the transaction request in step S506, the method further includes:
Performing BASE64 coding on the PDF file through the intelligent contract;
transmitting the encoded character string to an initiator of the target transaction.
In some of these embodiments, transmitting the encoded string to the initiator of the target transaction includes:
dividing all the coded character strings or according to a preset proportion, and storing the character strings in an account book of a blockchain;
the stored transaction hash is transmitted to the initiator of the target transaction.
In some embodiments, in step S506, after converting the corresponding HTML content into a PDF file through the smart contract according to the transaction request if the validity check is passed, the method further includes:
storing the PDF file into a file server, and transmitting an index and/or a storage address of the PDF file stored by the file server to an initiator of the target transaction;
And acquiring the PDF file according to the index and/or the storage address.
In some embodiments, in step S506, after converting the corresponding HTML content into a PDF file through the smart contract according to the transaction request if the validity check is passed, the method further includes:
the PDF file is converted into an OFD file by the smart contract.
It should be noted that the steps illustrated in the above-described flow or flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order other than that illustrated herein.
An embodiment of the present application provides a system for converting HTML into PDF based on blockchain, and fig. 8 is a flowchart illustrating steps of a method for converting HTML into PDF based on blockchain according to an embodiment of the present application, as shown in fig. 8, the system includes an intelligent contract 80, a blockchain network 81, and an SDK82 for interaction between the blockchain and an application, where the intelligent contract 80 includes a request receiving module 83, a validity checking module 84, and an HTML conversion module 85, and the blockchain network 81 includes a P2P network 86, a consensus algorithm 87, a chained ledger store 88, and an MSP identity management 89;
The request receiving module 83 receives a transaction request initiated by the SDK or other smart contracts, where the transaction request includes HTML information, XML information, and/or XSLT information;
The legitimacy verification module 84 verifies the legitimacy of the transaction request;
The HTML conversion module 85 converts the corresponding HTML content into a PDF file according to the transaction request;
the blockchain-to-application SDK82 is used to store identity certificates for user interactions with the blockchain.
The system solves the problems of complicated file format conversion mode, easy leakage of file information and difficult supervision, reduces the time related to processing the file information, reduces the cost and the risk of easy leakage of the file information, and improves the credibility and the visibility.
The above-described respective modules may be functional modules or program modules, and may be implemented by software or hardware. For modules implemented in hardware, the various modules described above may be located in the same processor; or the above modules may be located in different processors in any combination.
In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of converting HTML to PDF based on a blockchain. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
In one embodiment, fig. 9 is a schematic diagram of an internal structure of an electronic device according to an embodiment of the present application, and as shown in fig. 9, there is provided an electronic device, which may be a server, and an internal structure diagram of which may be shown in fig. 9. The electronic device includes a processor, a network interface, an internal memory, and a non-volatile memory connected by an internal bus, where the non-volatile memory stores an operating system, computer programs, and a database. The processor is used for providing computing and control capabilities, the network interface is used for communicating with an external terminal through a network connection, the internal memory is used for providing an environment for the operation of an operating system and a computer program, the computer program is executed by the processor to realize a method for converting HTML into PDF based on a block chain, and the database is used for storing data.
It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the electronic device to which the present application is applied, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SYNCHLINK) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It should be understood by those skilled in the art that the technical features of the above-described embodiments may be combined in any manner, and for brevity, all of the possible combinations of the technical features of the above-described embodiments are not described, however, they should be considered as being within the scope of the description provided herein, as long as there is no contradiction between the combinations of the technical features.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (8)

1. A method for converting HTML to PDF based on a blockchain, the method comprising:
Receiving a transaction request initiated by a target transaction, wherein the transaction request comprises HTML information, XML information and/or XSLT information;
Invoking verification logic through an intelligent contract deployed on a blockchain to verify the validity of an HTML character string in the transaction request, wherein the HTML information comprises the HTML character string;
And if the validity check is passed, according to the transaction request, calling a tag processing logic through the intelligent contract to perform closing processing on the tag which is not closed in the transaction request, and converting the corresponding HTML content into a PDF file through the intelligent contract.
2. The method of claim 1, wherein the legitimacy of the transaction request is verified by a smart contract deployed on a blockchain; if the validity check is passed, according to the transaction request, converting the corresponding HTML content into a PDF file through the intelligent contract comprises:
Invoking verification logic through an intelligent contract deployed on a blockchain to verify the validity of an HTML file path in the transaction request, wherein the HTML information comprises the HTML file path;
acquiring a corresponding HTML file through the intelligent contract according to the HTML file path;
and converting the HTML content into a PDF file through the intelligent contract.
3. The method of claim 1, wherein the legitimacy of the transaction request is verified by a smart contract deployed on a blockchain; if the validity check is passed, according to the transaction request, converting the corresponding HTML content into a PDF file through the intelligent contract comprises:
Calling verification logic through an intelligent contract deployed on a blockchain to verify an XML file path and an XSL file path in the transaction request, wherein the XML information comprises the XML file path and the XSLT information comprises the XSL file path;
According to the XSL parameters corresponding to the XSL file path, converting the XML file corresponding to the XML file path into an HTML file through the intelligent contract;
and converting the HTML content into a PDF file through the intelligent contract.
4. The method of claim 1, wherein after converting the corresponding HTML content into a PDF file by the smart contract according to the transaction request if the validity check is passed, the method further comprises:
performing BASE64 coding on the PDF file through the intelligent contract;
Transmitting the coded character string to an initiator of the target transaction.
5. The method of claim 4, wherein transmitting the encoded string to the initiator of the target transaction comprises:
dividing all the coded character strings or the coded character strings according to a preset proportion, and storing the character strings in an account book of the blockchain;
The stored transaction Ha Xichuan is entered into the initiator of the target transaction.
6. The method of claim 1, wherein after converting the corresponding HTML content into a PDF file by the smart contract according to the transaction request if the validity check is passed, the method further comprises:
Storing the PDF file into a file server, and transmitting an index and/or a storage address of the PDF file stored by the file server to an initiator of the target transaction;
and acquiring the PDF file according to the index and/or the storage address.
7. The method of claim 1, wherein after converting the corresponding HTML content into a PDF file by the smart contract according to the transaction request if the validity check is passed, the method further comprises:
and converting the PDF file into an OFD file through the intelligent contract.
8. A system for converting HTML into PDF based on a blockchain, which is characterized by comprising an intelligent contract, a blockchain network and an SDK for interaction between the blockchain and an application end, wherein the intelligent contract comprises a request receiving module, a validity checking module and an HTML conversion module, and the blockchain network comprises a P2P network, a consensus algorithm, a chained account book storage and MSP identity management;
The request receiving module receives a transaction request initiated by the SDK or other intelligent contracts, wherein the transaction request comprises HTML information, XML information and/or XSLT information;
The validity verification module invokes verification logic through an intelligent contract deployed on a blockchain to verify the validity of an HTML character string in the transaction request, wherein the HTML information comprises the HTML character string;
The HTML conversion module is used for carrying out closing processing on the label which is not closed in the transaction request through the intelligent contract call label processing logic according to the transaction request if the validity check is passed, and then converting the corresponding HTML content into a PDF file through the intelligent contract;
the SDK interacted between the blockchain and the application terminal is used for storing an identity certificate for interaction between the user and the blockchain.
CN202110867977.3A 2021-07-29 2021-07-29 Method and system for converting HTML into PDF based on blockchain Active CN113723059B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110867977.3A CN113723059B (en) 2021-07-29 2021-07-29 Method and system for converting HTML into PDF based on blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110867977.3A CN113723059B (en) 2021-07-29 2021-07-29 Method and system for converting HTML into PDF based on blockchain

Publications (2)

Publication Number Publication Date
CN113723059A CN113723059A (en) 2021-11-30
CN113723059B true CN113723059B (en) 2024-07-05

Family

ID=78674436

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110867977.3A Active CN113723059B (en) 2021-07-29 2021-07-29 Method and system for converting HTML into PDF based on blockchain

Country Status (1)

Country Link
CN (1) CN113723059B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112417049A (en) * 2020-11-24 2021-02-26 杭州云象网络技术有限公司 Cross-chain interaction method and system based on block chain all-in-one machine
CN112631613A (en) * 2020-12-29 2021-04-09 杭州趣链科技有限公司 Intelligent contract deploying and calling method based on block chain platform and related equipment

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011142737A1 (en) * 2010-05-08 2011-11-17 Hewlett-Packard Development Company, L.P. Executing transcription requests on files
CN110008195B (en) * 2019-04-11 2020-06-02 重庆猪八戒知识产权服务有限公司 Method, device and system for dynamically configuring html (hypertext markup language) to pdf (pdf)
CN110119486A (en) * 2019-04-18 2019-08-13 杭州宇链科技有限公司 A kind of data format and its generation and analytic method for the transaction of block chain
CN111274202B (en) * 2020-01-15 2023-07-14 深圳市中农网有限公司 Electronic contract generation method, device, computer equipment and storage medium
CN111882419B (en) * 2020-05-25 2022-02-08 马上消费金融股份有限公司 Method and device for quality inspection of files and server
CN112184230A (en) * 2020-10-14 2021-01-05 深圳壹账通智能科技有限公司 Transaction data processing method, system, device and storage medium based on block chain
CN112861102B (en) * 2021-03-12 2024-02-06 杭州溪塔科技有限公司 Method and system for processing electronic file based on block chain

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112417049A (en) * 2020-11-24 2021-02-26 杭州云象网络技术有限公司 Cross-chain interaction method and system based on block chain all-in-one machine
CN112631613A (en) * 2020-12-29 2021-04-09 杭州趣链科技有限公司 Intelligent contract deploying and calling method based on block chain platform and related equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于区块链技术的电子签名系统设计与实现;李勇;《企业科技与发展》(第4期);35-38 *

Also Published As

Publication number Publication date
CN113723059A (en) 2021-11-30

Similar Documents

Publication Publication Date Title
US11789933B2 (en) System and method for a hybrid contract execution environment
KR102611572B1 (en) Techniques to limit injection of unlock transaction bytecode
CA2716982C (en) Digital signatures on composite resource documents
CN113408259B (en) Method, system, device and storage medium for filling in file based on blockchain
KR20210090611A (en) Methods and systems for improved blockchain-implemented smart contracts
CN112015396B (en) DSL-based intelligent contract code generation method, device, equipment and storage medium
WO2021120537A1 (en) Blockchain-based infringement evidence collection method and apparatus, electronic device, and storage medium
CN113609219A (en) Method, system, device and storage medium for verifying file based on block chain
CN115208665B (en) Germplasm resource data safe sharing method and system based on blockchain
CN110597814A (en) Structured data serialization and deserialization method and device
Klomp et al. On symbolic verification of Bitcoin’s script language
US20120204036A1 (en) Encryption Scheme
CN112749537A (en) Role-based electronic engineering document management method
US11188911B2 (en) Object oriented smart contracts for UTXO-based blockchains
CN113409127B (en) Block chain-based medical electronic bill printing method, system and device
CN113468862A (en) Method and device for creating layout file by block chain, electronic equipment and storage medium
CN113723059B (en) Method and system for converting HTML into PDF based on blockchain
Ahmad Integration of IoT devices via a blockchain-based decentralized application
Hobeck et al. Towards object-centric process mining for blockchain applications
Falazi et al. Blockchain-based collaborative development of application deployment models
CN112699170B (en) Query method and system based on multi-source data structure block chain
EP3952202B1 (en) A device and a method for performing a cryptographic algorithm
Shang et al. A Blockchain-based Electronic Data Forensics System Design and Implementation
Gao et al. A security problem in small scale private Ethereum network
Zhuge et al. Modeling language and tools for the semantic link network

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