A kind of method and system for mobile terminal viewing pdf document
Technical field
The present invention relates to a kind of network digitalization information dissemination method and systems, and in particular to one kind is watched for mobile terminal
The method and system of pdf document.
Background technique
PDF file plays critically important effect in people's lives, due to being a kind of portable electronic document lattice
Formula, and in several operation systems be all it is general, this performance becomes PDF format to carry out electronics text on network
Shelves distribution and digital information propagate ideal document format, more and more e-books, the description of product, company's proclamation,
Network data, Email begin to use the file of PDF format.And with the development of internet, people are not content with this
PDF file is read on ground, is posted and is wished to read online PDF file based on the browser on mobile terminal.
Currently, common Android and IOS cell phone system can support the parsing and reading of pdf document, and disadvantage is must
Pdf document must be entirely loaded into memory.In addition, being limited to mobile device memory and mobile network's rate limitation, movement is set
The demand that online PDF is watched on standby (such as mobile phone, Pad) is not still well positioned to meet.
It is concentrated mainly on Railway Project below:
1. loading velocity is slow, just can be carried out since PDF reading must load the entire pdf document of completion, so causing to load
Speed is slow;
2. expending network flow, entire file must be downloaded by reading each pdf document, so a large amount of stream can be expended
Amount;
3. which kind of technology no matter committed memory use, PDF reading must be loaded into memory PDF, for biggish hundred
Million or more pdf document, for the mobile device of memory valuableness, undoubtedly pressure is huge;
4. occupying cpu resource, the parsing and display of PDF needs to expend cpu resource and parses to file, expends CPU money
Source;
5. the power consumption that the consuming of network flow and memory, CPU can improve mobile phone;
6. display effect can carry out compression processing to PDF, but cause to compress often in order to overcoming the above Railway Project
PDF mass declines afterwards, influences reading experience or even lost content.
Summary of the invention
The purpose of the present invention is to provide a kind of method and system for mobile terminal viewing pdf document, can quickly beat
Read interface and content are opened, user experience is promoted, saving network flow uses, and reduces the EMS memory occupation of reading;The invention enables
Need not there are the browser of PDF parsing function and APP to have the ability to display pdf document content, as long as in fact, can support to scheme
The terminal of piece browsing can support the PDF browsing function.
The technical solution of the invention is as follows:
A method of pdf document being watched for mobile terminal, is characterized in that, this method comprises:
1) PDF is uploaded into cloud space;
2) server downloads the pdf document from cloud space from cloud spatial perception to new pdf document;
3) pdf document is read in memory by server;
4) server by utilizing java applet, which say to the pdf document in memory, is converted to the operation of JPG format picture, and will
JPG format picture is stored on server disk;
5) the picture file batch on disk is uploaded into CDN;
6) mobile terminal requested webpage or picture, server successively return to CDN, transfer the picture of corresponding page, and are shown in
Mobile terminal is watched for user.
Above-mentioned CDN is content distributing network, by network place that node server constituted everywhere existing
One layer of intelligent virtual network on Internet basic, CDN can be in real time according to the connections of network flow and each node, load
Situation and the request of user is re-directed into the service nearest from user to the integrated informations such as the distance of user and response time
On node.
The mode of above-mentioned generation JPG format picture is to be loaded into memory pdf document using Java development language, then
It reads page by page, reuses the tool in java applet and every page PDF is generated to the picture of JPG format in memory, and will give birth to
At picture be stored under the specified directory of server, picture name is the page number, and the corresponding picture of first page is 1.jpg, nth page
Corresponding picture is n.jpg.
The above-mentioned picture file batch by disk uploads to CDN, specifically by one visit of corresponding generation of each picture
It asks the way diameter, and by access path storage to database.
It is above-mentioned say to the pdf document in memory that being converted to the operation of JPG format picture specifically includes using java applet:
1) tool is read using the file in Java development language to be loaded into memory pdf document;
2) first page is intercepted from PDF;
3) content in PDF is given birth in memory using BufferedImage the and Graphics tool of java applet
At picture;
4) width and height for first obtaining the PDF page, empty painting canvas is established using Java picture processing program;
5) by PDF text and picture extract;
6) picture and text are added in painting canvas using Java paint program;
7) picture in memory is stored under the specified directory of server, the filename page number adds the form of jpg;
8) judge whether pdf document has lower one page, exited if not, if there is if take lower one page, continue to generate.
Above-mentioned mobile terminal includes the browser or APP of mobile terminal;The picture is shown in mobile terminal and refers to mobile terminal
Browser or APP initiate to request to server, and server returns to the access path of picture;Mobile terminal browser or APP root
Every page PDF corresponding JPF picture access address is risked according to the picture path taken, and is Loaded Image.
Above-mentioned server is to be found out to new using the realization of timing probe monitoring programme from cloud spatial perception to new pdf document
Pdf document.
It is a kind of realize the above method for mobile terminal watch pdf document system, be characterized in that including service
Device, and the mobile terminal connected with server by internet, the management end in the cloud space, upper transmitting file that are connect with server with
And database, the server are equipped with picture processing program, the server includes at least a temp directory.
Above-mentioned mobile terminal refers to the browser or APP of mobile terminal.
Above-mentioned picture processing program includes timing probe monitoring programme and java applet.
The invention has the advantages that
1, read interface and content are quickly opened, user experience is promoted.
2, saving network flow uses.
3, the EMS memory occupation read is reduced.
4, the loss to CPU is reduced.
5, from the saving to flow, memory, CPU three, to save battery.
6, greatly retain original PDF reading effect.
Detailed description of the invention
Fig. 1 is implementation process schematic diagram of the present invention.
Specific embodiment
Referring to Fig. 1, the invention discloses a kind of method and system that pdf document is shown for mobile terminal.This method includes
PDF is uploaded into cloud space;The monitoring programme of server is from cloud spatial perception to new pdf document;Server is under cloud space
Carry pdf document;Pdf document is read in memory using java applet by server;Java applet turns the pdf document in memory
The operation of JPG format picture is changed, every page of pdf document generates a JPG picture and is stored on server disk, and picture name is page
Code, if the corresponding picture of first page is 1.jpg, the corresponding picture of page 99 is 99.jpg;Java applet is by the picture on disk
Files in batch uploads to CDN;Mobile terminal requested webpage or picture, server successively return to 1 to N pages corresponding picture, every time
Only one picture of display.
The full name of CDN is Content Delivery Network, i.e. content distributing network in the present invention.Its basic ideas
It is the bottleneck and link for avoiding being possible to influence data transmission bauds and stability on internet as far as possible, makes content transmission more
Fastly, more stable.By placing one on the existing Internet basic layer intelligence that node server is constituted everywhere in network
Can virtual network, CDN system can in real time according to the connection of network flow and each node, load state and to user away from
The request of user is re-directed on the service node nearest from user from integrated informations such as response times.The purpose is to use
Family can obtain required content nearby, solve the crowded situation of Internet network, improve the response speed that user accesses website.
The present invention say to the pdf document in memory using java applet is converted to the specific packet of JPG format picture operation
It includes:
1) tool is read using the file in Java development language to be loaded into memory pdf document;
2) first page is intercepted from PDF;
3) content in PDF is given birth in memory using BufferedImage the and Graphics tool of java applet
At picture;
4) width and height for first obtaining the PDF page, empty painting canvas is established using Java picture processing program;
5) by PDF text and picture extract;
6) picture and text are added in painting canvas using Java paint program;
7) picture in memory being stored under the specified directory of server, the filename page number adds the form of jpg, such as
First page is 1.jpg;
8) judge whether pdf document has lower one page, exited if not, if there is if take lower one page, continue to generate.
The invention enables the browser that need not have PDF parsing function and APP to have the ability to display pdf document content, real
On border, as long as can support the terminal of picture browsing that can support the PDF browsing function.Specific implementation method:
1) pdf document is uploaded to cloud space (such as OSS of Ali's cloud)
2) the timing probe monitoring programme of operation on the server finds out new pdf document, and obtains the visit of pdf document
It asks the way diameter;
3) java applet of operation on the server downloads pdf document to server memory from obtained access path;
4) operation java applet on the server carries out paging reading to the pdf document in memory and by every page of life
At a JPG format picture, picture name and the page number are corresponding, are 1.jpg as first page corresponds to picture;
5) program saves the JPG picture in memory in a temp directory on the server;
6) complete entire PDF turn picture process after, the program on server uploads to all pictures in CDN, and
By path storage into database;
7) browser or APP of mobile terminal initiate to request to server, and server returns to the access path of picture;
8) mobile terminal browser or APP risk the corresponding JPF picture access of every page PDF according to the picture path taken
Address, and Load Image.
Technical solution of the present invention bring the utility model has the advantages that
1, read interface and content are quickly opened, user experience is promoted.
2, saving network flow uses.
3, the EMS memory occupation read is reduced.
4, the loss to CPU is reduced.
5, from the saving to flow, memory, CPU three, to save battery.
6, greatly retain original PDF reading effect.