CN107491430B - Method for filling pdf by pdf toolkit and SPEL expression - Google Patents

Method for filling pdf by pdf toolkit and SPEL expression Download PDF

Info

Publication number
CN107491430B
CN107491430B CN201710750510.4A CN201710750510A CN107491430B CN 107491430 B CN107491430 B CN 107491430B CN 201710750510 A CN201710750510 A CN 201710750510A CN 107491430 B CN107491430 B CN 107491430B
Authority
CN
China
Prior art keywords
pdf
expression
context
toolkit
filled
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.)
Expired - Fee Related
Application number
CN201710750510.4A
Other languages
Chinese (zh)
Other versions
CN107491430A (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.)
Nongfanji Information Technology Jiangsu Co ltd
Original Assignee
Nanjing Nongfenqi E Commerce 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 Nanjing Nongfenqi E Commerce Co ltd filed Critical Nanjing Nongfenqi E Commerce Co ltd
Priority to CN201710750510.4A priority Critical patent/CN107491430B/en
Publication of CN107491430A publication Critical patent/CN107491430A/en
Application granted granted Critical
Publication of CN107491430B publication Critical patent/CN107491430B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/174Form filling; Merging

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method for filling a pdf by using a pdf toolkit and a SPEL expression, which comprises the following steps: step 1, selecting a pdf toolkit; step 2, inquiring all data which can be filled, and putting the data into the Context of the expression; step 3, registering the self-defined method in the Context of the expression; step 4, reading the pdf template to be filled by using a pdf toolkit, and traversing all form names to be filled; step 5, taking the read form name as an expression, and analyzing the expression by reading the Context to obtain a corresponding result value; and 6, writing the result value back to the pdf template by using the pdf toolkit to generate a new file stream.

Description

Method for filling pdf by pdf toolkit and SPEL expression
Technical Field
The invention relates to the technical field of computers, in particular to a method for filling a pdf by using a pdf toolkit and a SPEL expression.
Background
The pdf is a main file format of official documents, and is widely applied in the fields of contracts, agreements, specifications and the like, and there are many scenes in these fields, and the pdf is dynamically filled according to the system information, and at present, the main scheme is to use a pdf operation library (iText) to operate the form of the pdf for filling, but in the face of the customized filling format and the variety of filling contents, the pdf template and the program are often required to be modified for achieving the purpose, which makes the use of users very inconvenient.
Disclosure of Invention
The purpose of the invention is as follows: the technical problem to be solved by the invention is that in the field of pdf filling, the content and format of filling are changed frequently, and the traditional scheme needs frequent program modification, so that the efficiency is low and the response is slow.
In order to solve the technical problems, the invention discloses a method for filling a pdf by combining a pdf toolkit (iText) with expression languages (SPEL, EL, OGNL and the like), which can achieve the effects of high practicability, good flexibility and strong universality.
The invention comprises the following steps:
step 1, selecting a pdf toolkit;
step 2, inquiring all data which can be filled, and putting the data into the Context of the expression;
step 3, registering the self-defined method in the Context of the expression; the self-defining method is that when the function in the expression can not meet the requirement, the code is required to be written and registered by the user, and the registration is the function provided in the expression context (for example, the expression can not express the function of formatting the Date type data into YYYYY-MM-DD, and the user-defining method is written).
Step 4, reading the pdf template to be filled by using a pdf toolkit, and traversing all form names to be filled;
step 5, taking the read form name as an expression, and analyzing the expression by reading the Context to obtain a corresponding result value; the result is the function of the expression language through Context analysis;
and 6, writing the result value back to the pdf template by using the pdf toolkit to generate a new file stream.
In step 2, the selected pdf toolkit is IText.
The step 2 comprises the following steps: the expression context is a part of an expression system, in SPEL, Strandard EvaluationContext is a context class, the context is constructed in a mode of StandardEvaluationContext ═ new StandardEvaluationContext (), and then possible filling data is put in through a calling method context. key is used to fetch data from the context and value represents data. context represents the context in which all data with padding is placed in key-to-value form, and the method is customized.
The step 3 comprises the following steps: in SPEL, a custom method is registered by calling a method context, which is a name for calling the custom method when an expression is used, and a method is a custom method.
The step 5 comprises the following steps: the ExpressionParser in SPEL is an expression parser, constructed by a method of ExpressionParser ═ new SpelExpressionParser (), and then obtained by a method of parser.
The invention also comprises a step 7: and converting the file stream into a result required by the user according to the service form. (e.g., result file download link, to printer, etc.).
Has the advantages that:
in the staged business, a large number of contract businesses exist, and due to various factors, contracts and filling contents can be changed frequently. The method dynamically fills the pdf by utilizing the pdf operation library and combining the expression characteristics of the expression language, and greatly improves the development cost and the maintenance cost of the system. When the filling requirement is changed, the program is not required to be modified again, and only the expression language in the form of the template is required to be modified.
Drawings
FIG. 1 is a flow chart of an implementation of the present invention.
Fig. 2 is a screenshot of a pdf to be filled according to the present invention.
Fig. 3 is a detailed view of the present invention.
Detailed Description
As shown in fig. 1, the present invention discloses a method for populating a pdf with a pdf toolkit and SPEL expressions, comprising the steps of:
step 1, selecting a pdf toolkit;
step 2, inquiring all data which can be filled, and putting the data into the Context of the expression;
step 3, registering the self-defined method in the Context of the expression; the self-defining method is that when the function in the expression can not meet the requirement, the code is required to be written and registered by the user, and the registration is the function provided in the expression context (for example, the expression can not express the function of formatting the Date type data into YYYYY-MM-DD, and the user-defining method is written).
Step 4, reading the pdf template to be filled by using a pdf toolkit, and traversing all form names to be filled;
step 5, taking the read form name as an expression, and analyzing the expression by reading the Context to obtain a corresponding result value; the result is the function of the expression language through Context analysis;
and 6, writing the result value back to the pdf template by using the pdf toolkit to generate a new file stream.
In step 2, the selected pdf toolkit is IText.
The step 2 comprises the following steps: an expression context is part of an expression hierarchy, constructed in the SPEL in a StandardEvaluationContext () manner, and put in potentially padded data through context.
The step 3 comprises the following steps: in SPEL, the method is registered by context.
The step 5 comprises the following steps: an expression parser is constructed in SPEL by ExpressionParser ═ new SpelExpressionParser (), and then a result value is obtained by parser.
The invention also comprises a step 7: and converting the file stream into a result required by the user according to the service form. (e.g., result file download link, to printer, etc.).
Examples
As shown in fig. 2, is a pdf screenshot of an order to fill. Fig. 3 is a detailed process for processing the data of fig. 2 using the method of the present invention.
The program in fig. 3 queries all service data (user information, order information) and puts them into the context of the expression (the expression context is a part of the expression system, the expression part in fig. 3 is SPEL as an example, and constructs the context by means of standardeventualcontextcontext ═ new standardeventualcontext (), and puts them into the context by means of calling method context.
Since the service requirement, the pdf of result has the requirement of displaying the capital amount number and the format of the order time year and month, the custom method of converting the capital amount into the capital amount (upperNum) and the time formatting (datetorsting) are registered in the context of the expression (by means of the context register function);
the pdf to be filled uses the pdf editor to create a form at the location to be filled, and uses the expression language to define the name of the form to be filled (in fig. 3, # user. user name can take the data from the context as the value of "three")
The IText reads the pdf to be filled, traverses all the form names to be filled, the expression language parses the result value by reading the defined context, and fig. 3 identifies a result corresponding to the expression parsing (the result value is obtained by constructing an expression parser and a parser.
Finally IText writes the result back to the pdf template to form a new file stream
While the present invention provides a method for populating a pdf with a pdf toolkit and SPEL expressions, and many ways to implement the same, the above description is only a preferred embodiment of the present invention, and it should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and such improvements and modifications should be considered as the protection scope of the present invention. All the components not specified in the present embodiment can be realized by the prior art.

Claims (1)

1. A method for populating a pdf with a pdf toolkit and a SPEL expression, comprising the steps of:
step 1, selecting a pdf toolkit;
step 2, inquiring all data which can be filled, and putting the data into the Context of the expression;
step 3, registering the self-defined method in the Context of the expression;
step 4, reading the pdf template to be filled by using a pdf toolkit, and traversing all form names to be filled;
step 5, taking the read form name as an expression, and analyzing the expression by reading the Context to obtain a corresponding result value;
step 6, writing the result value back to the pdf template by using the pdf toolkit to generate a new file stream;
in the step 2, the selected pdf tool package is IText;
the step 2 comprises the following steps: in SPEL, StrandardEviationContext is a context class, is constructed in a StandardEviationContext () mode, and is put in possibly filled data through a calling method context, set variable (key, value);
the step 3 comprises the following steps: register a custom method in SPEL by calling a method context, which is a name of calling the custom method when an expression is used, and a method which is a custom method;
the step 5 comprises the following steps: in SPEL, an expression parser is used as an expression parser, the expression parser is constructed by a method of expression parser, and then a result value is obtained by a method of parser.
Further comprising step 7: and converting the file stream into a result required by the user according to the service form.
CN201710750510.4A 2017-08-28 2017-08-28 Method for filling pdf by pdf toolkit and SPEL expression Expired - Fee Related CN107491430B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710750510.4A CN107491430B (en) 2017-08-28 2017-08-28 Method for filling pdf by pdf toolkit and SPEL expression

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710750510.4A CN107491430B (en) 2017-08-28 2017-08-28 Method for filling pdf by pdf toolkit and SPEL expression

Publications (2)

Publication Number Publication Date
CN107491430A CN107491430A (en) 2017-12-19
CN107491430B true CN107491430B (en) 2021-01-08

Family

ID=60646695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710750510.4A Expired - Fee Related CN107491430B (en) 2017-08-28 2017-08-28 Method for filling pdf by pdf toolkit and SPEL expression

Country Status (1)

Country Link
CN (1) CN107491430B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103020027A (en) * 2012-11-16 2013-04-03 北京北森测评技术有限公司 Method, device and system for generating dynamic report
CN104737163A (en) * 2012-10-17 2015-06-24 起元科技有限公司 Specifying and applying rules to data
CN105760172A (en) * 2016-03-02 2016-07-13 浪潮软件集团有限公司 Statement generation method based on itext
CN106776498A (en) * 2016-12-09 2017-05-31 山东浪潮商用系统有限公司 A kind of method that data export as PDF

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104737163A (en) * 2012-10-17 2015-06-24 起元科技有限公司 Specifying and applying rules to data
CN103020027A (en) * 2012-11-16 2013-04-03 北京北森测评技术有限公司 Method, device and system for generating dynamic report
CN105760172A (en) * 2016-03-02 2016-07-13 浪潮软件集团有限公司 Statement generation method based on itext
CN106776498A (en) * 2016-12-09 2017-05-31 山东浪潮商用系统有限公司 A kind of method that data export as PDF

Also Published As

Publication number Publication date
CN107491430A (en) 2017-12-19

Similar Documents

Publication Publication Date Title
CN101122899B (en) Report generation method and device
US6850950B1 (en) Method facilitating data stream parsing for use with electronic commerce
CN102117202B (en) J2EE architecture-based code generating device
US20040221233A1 (en) Systems and methods for report design and generation
US7680333B2 (en) System and method for binary persistence format for a recognition result lattice
CN104881275B (en) A kind of electronic report forms generation method and device
US10095672B2 (en) Method and apparatus for synchronizing financial reporting data
CA2438176A1 (en) Xml-based multi-format business services design pattern
CN109933752A (en) A kind of method and apparatus exporting electronic document
CN102043626A (en) Method and device for encapsulating extjs component, and method and system for generating user interface
CN108694214A (en) Generation method, generating means, readable medium and the electronic equipment of data sheet
CN109582647A (en) A kind of analysis method and system towards the unstructured instrument of evidence
CN109766085B (en) Method and device for processing enumeration type codes
CN108762743A (en) Data table operation code generation method and device
CN105095160A (en) Document conversion reading method and system
CN105335338A (en) Electronic document conversion method and device
CN105468571A (en) Method and device used for automatically generating report
CN109299074A (en) A kind of data verification method and system based on templating data base view
CN108280219A (en) Text interpretation method, device, computer equipment and storage medium
CN112199556A (en) Automatic XML Schema file format conversion method, system and related equipment
CN109979551A (en) A kind of editing machine of web-based electronic medical record document
Langer et al. Standard C++ IOStreams and locales: advanced programmer's guide and reference
CN103793464A (en) Method for exporting reports on basis of neutral formats
CN107491430B (en) Method for filling pdf by pdf toolkit and SPEL expression
CN102043769A (en) Method and device for editing documents

Legal Events

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

Effective date of registration: 20210425

Address after: No.1057, science and innovation center, Nanjing National Agricultural Innovation Park, No.8 Xingzhi Road, Pukou District, Nanjing City, Jiangsu Province, 210000

Patentee after: Nongfanji information technology (Jiangsu) Co.,Ltd.

Address before: 210000 Xuanwu Avenue, Xuanwu District, Jiangsu, Nanjing 699-1

Patentee before: NANJING NONGFENQI E-COMMERCE Co.,Ltd.

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20210108

Termination date: 20210828