A kind of e-book method for making based on SWF
Technical field
The present invention relates to the information digitalization processing technology field, be specifically related to a kind of method for making based on the e-book of the high-fidelity of SWF that is adapted at Internet Transmission, be specially adapted to the occasion that visual effect and volume are all had relatively high expectations.
Background technology
The use of e-book is very extensive, and the obtaining of e-book can be led to mobile memory medium and be copied this locality to, and such as u dish, portable hard drive, CD etc. copies.But under many circumstances, e-book is to download by network.In a distributed system, books may repeatedly transmit between a plurality of servers before being issued to final client.Therefore the size that how to reduce e-book just seems of crucial importance.
Under existing technology, the volume of e-book reduces, and a lot of situations are cost by its sharpness of decrease, color.But in a lot of occasions, we do not wish to reduce its sharpness, the electronic teaching material that for example uses for students in middle and primary schools, and based on students in middle and primary schools' characteristics, the color that we wish to keep the high definition of teaching material, significantly do not lose book.At present, the electronic teaching material (textbook) of the e-book, particularly middle and primary schools of the distribution of each publishing house is substantially all PDF, its characteristics be lucuriant in design, character is clear, bulky.For e-book being carried out the system of Internet Transmission, above-mentioned bulky electronics is unsuitable beyond doubt.
The SWF of Adobe company (shock wave flash)) file has used vector technology, under given conditions, can significantly reduce the volume of e-book, and therefore transferring PDF to SWF is a kind of scheme preferably.Support on the market that at present PDF is converted to the software of SWF a lot, such as gpdf2swf, PDFZilla, FlashPaper2, macromedia flashpaper etc., but these softwares not support program call, can only manual operations.Like this, usually, be difficult to advance in own e-book making software these switching softwares are integrated.To use PDF conversion SWF in the books manufacturing system, two schemes can be arranged: be 1) all the disclosed file of form due to PDF and SWF file, also have more increasing income to resolve the storehouse, such as XPdfLib etc., can own pdf document be resolved, and produce by the SWF file layout.2) call some assemblies or background program, such as PDF2SWF etc.No matter be which kind of mode, all need to rational conversion parameter be set for different PDF contents, could obtain optimum efficiency.In addition, in present existing crossover tool, mostly adopt unified strategy to change, specific aim is also relatively poor.
In present electronic document, word has several forms of expression usually: 1) use vector font library; 2) use dot matrix word library; 3) be that bitmap shows with character conversion.
Wherein, vector font library also claims font vector, vector fonts (Vector font), all is called the font vector herein.The font vector is the most widely used a kind of form now.Its each font is described by mathematic curve, and it has comprised the borderline key point of font, the derivative information of line etc., and then the render engine of font carries out certain mathematical operation and plays up by reading these mathematical vector.Relatively the advantage of this class font is font physical size convergent-divergent and indeformable, variable color arbitrarily.Relative raster font, the advantage such as it is few that the font vector has the data of taking, and convergent-divergent is not indeformable.
Raster font is that each character is divided into 16 * 16 or 24 * 24 points, then represents the profile of character with the actual situation of each point.Advantage is that display speed is fast, needs to calculate unlike vector fonts; Maximum shortcoming is to amplify, in case will find the sawtooth at word edge after amplifying.This kind raster font is main only as the part of " assisting " now, uses less.
Be the form that bitmap shows with character conversion, in fact had nothing to do with character.For example with the e-book that paper book scans, digital camera is taken pictures and become image and generate, just belong to this type.
In addition, in some specific occasions, some characters in a fancy style that for example use in advertising, also normal form with polar plot designs, and its essence is not character, but a sub-picture.
In present e-book, image has the form of expression in 2 usually: 1) use polar plot; 2) use dot chart.
Polar plot claims again Polygon figure, vector plot, drawing image, all is called Polygon figure or Polygon herein.Polygon figure is with the geometric graphic element presentation video based on math equation such as point, straight line or polygon in computer graphics.It is less that the vector graphics advantage is that file takes up room, and no matter amplify, dwindle or rotation etc. can distortion; Shortcoming is to be difficult to show the abundant photorealism effect of gradation, and drafting efficient is high not as dot chart.
Dot chart claims again bitmap (Bitmap), grid map, pixel map, briefly, is exactly the figure that least unit is made of pixel, and convergent-divergent can distortion.The least unit that consists of bitmap is pixel, and bitmap is realized its display effect by the arrangement of pel array.Its advantage is to produce image beautiful in colour, complicated and changeable; Shortcoming is bulky.
Can find out from above-mentioned discussion, from reducing the angle of electron number volume, can consider the word in e-book is represented (font vector) with vector font library; Image is better with the form performance of polar plot.But in actual conditions, final volume is also relevant to content.For example, polar plot is fit to express simple figure, and therefore for simple graph, vector map data is more much smaller than data bitmap volume.If but original image is bitmap, and bitmap comprises complicated shape and many colors, and the volume of the vector graphics after the conversion can be larger than original bitmap! Therefore to comprising the e-book of complicated image, without exception with it vector quantization and improper.To complicated bitmap, convert it to the compression forms such as jpeg, often can obtain the less volume that gets.In case of necessity, transfer some complicated bitmap to vector, more manually with edit tools such as Flush etc., vector is carried out smoothing processing, can obtain the balance of color, effect, volume preferably; But for some complicated content, can larger gap be arranged with former figure after pressure is level and smooth, lose aesthetics.Therefore to reduce be the process of a complexity to the volume of e-book, need to design for different situations, auxiliary with manually in case of necessity, could obtain the effect of the best.
Summary of the invention
For the defective that exists in prior art, the object of the present invention is to provide a kind of e-book method for making based on SWF, for different PDF contents, adopt different conversion settings when being converted to SWF, make the file after conversion guarantee higher sharpness, reach simultaneously less size, obtained better conversion effect.
For achieving the above object, the technical solution used in the present invention is:
A kind of e-book method for making based on SWF comprises the following steps:
(1) open pending pdf document, analyze the content of every one page in pdf document and the content of every one page is classified; The content of every one page in pdf document is divided into 5 large types: word is that master, image are auxiliary type, and the word that is converted to image is that master, image are auxiliary type, and image is host type, and word is that master, image are background type and comprehensive image mixed character typeset type;
(2) type of one page content every according to pdf document, arrange respectively the parameter when PDF is converted to SWF;
(3) according to the conversion parameter that arranges, pdf document is converted to the SWF file;
(4) the SWF compressing file after changing and add file header forms final e-book.
Further, a kind of e-book method for making based on SWF as above, in step (2), the parameter when PDF is converted to SWF arranges as follows:
When the content in pdf document be word be main, when image is auxiliary type, word remains the font vector, image transfers polygon figure to;
When the content in pdf document be the word that is converted to image be main, when image is auxiliary type, polygon figure remains polygon figure, other image transfers the Jpeg form to;
When the content in pdf document is image when being host type, polygon figure remains polygon figure, and other image transfers the Jpeg form to;
When the content in pdf document be word be main, when image is background type, transfer image to the Jpeg form, word remains the font vector;
When the content in pdf document was comprehensive image mixed character typeset type, polygon figure remained polygon figure, and other image transfers the Jpeg form to.
Further, a kind of e-book method for making based on SWF as above is in step (2), when parameters, when the content in pdf document be the word that is converted to image be main, when image is auxiliary type, the image setting that transfers the Jpeg form to is intermediate resolution; Described intermediate resolution refers to that the Q factor scope of Jpeg is 70~80.
Further, a kind of e-book method for making based on SWF as above, in step (2), when parameters, when the content in pdf document is image when being host type, the image setting that transfers the Jpeg form to is high definition; Described high definition refers to that the Jpeg Q factor is 95~100.
Further, a kind of e-book method for making based on SWF as above, in step (2), when parameters, when the content in pdf document be word be main, when image is background type, the image setting that transfers the Jpeg form to is low definition; Described low definition refers to that the Jpeg Q factor is 60~65.
Further, a kind of e-book method for making based on SWF as above, in step (2), when parameters, when the content in pdf document was comprehensive image mixed character typeset type, the image setting that transfers the Jpeg form to was intermediate resolution.
Further, a kind of e-book method for making based on SWF as above in step (3), after pdf document is converted to the SWF file, is carried out hand inspection to the file after conversion, and the undesirable page is processed separately.
Further again, a kind of e-book method for making based on SWF as above in step (4), adopts the Zip algorithm that the file after changing is compressed.
Further, a kind of e-book method for making based on SWF as above adopts key to be encrypted processing to the file after compression.
Effect of the present invention is: at first method of the present invention distinguishes the different content of PDF, and adopts different conversion settings in conjunction with different contents when being converted to SWF, thereby obtains optimum efficiency.In addition, the e-book tools have also used the compression skills such as Zip, further dwindle the books size.Be encrypted with key, obtain confidentiality preferably.This document is guaranteeing higher document sharpness, is not reducing color bit depth, is reaching simultaneously less size, is specially adapted to the occasion that visual effect and volume are all had relatively high expectations.
Description of drawings
Fig. 1 is the process flow diagram of a kind of e-book method for making based on SWF of the present invention;
Fig. 2 is that the specific embodiment Chinese word is that main contents, image are one page pdf document of background type;
Fig. 3 adopts the file in Fig. 2 the Local map of the SWF file that generates after the default parameter conversion;
Fig. 4 is for changing the file in Fig. 2 the Local map of the SWF file of rear generation by method of the present invention;
Fig. 5 is the partial enlarged drawing of Fig. 4.
Embodiment
The present invention is described in further detail below in conjunction with Figure of description and embodiment.
Fig. 1 shows the process flow diagram of a kind of e-book method for making based on SWF of the present invention, by finding out in figure that the method mainly comprises the following steps:
Step S11: with every one page classifying content of pending pdf document;
Open pending pdf document, analyze the content of every one page in pdf document and the content of every one page is classified; The content of every one page in pdf document is divided into 5 large types: word (embedded/as to connect outward) is that master+image is auxiliary type, the word that is converted to image is that master+image is auxiliary type, image is host type, and word is that master+image is background type and comprehensive image mixed character typeset type.
Step S12: conversion parameter is set according to the type of every page of PDF content;
After every one page classifying content with pdf document in step S11, according to the type of every page of content of pdf document, the parameter when PDF is converted to SWF is set respectively.Concrete set-up mode is as follows:
1) word (embedded/as to connect outward) is that master, image are auxiliary type;
When parameter arranged, word remained the font vector, was polygon figure with image transitions.
2) to be converted into image be that main, image is auxiliary type to word;
When parameter arranged, polygon figure kept polygon figure, and other image transitions is the Jpeg form, and the Jpeg format-pattern is set to intermediate resolution.
3) image is main contents, the less type of word;
When parameter arranged, polygon figure kept polygon figure, image to transfer the Jpeg form to, and be high definition with the image setting of Jpeg form.
4) word is that main contents, image are the type of background;
When parameter arranged, image transferred the Jpeg form to, and was set to low definition, and word keeps the font vector.
5) comprehensive image mixed character typeset type.
When parameter arranged, Polygon figure kept the polygon image, and image transfers the Jpeg form to, and the Jpeg format-pattern is set to intermediate resolution.
In this embodiment, 5 kinds is more common type.Certainly, for the classification of PDF document content, the user can according to the needs in reality, carry out different classification.In 5 kinds of common types, set intermediate resolution, high definition and low definition refer to the difference of image quality parameter.The image of Jpeg form is a kind of lossy compression method image, and its compressibility is used Q factor (abbreviation quality) usually, represents also referred to as the Q factor, compressibility factor.The value of quality factor from 1 to 100.Be worth littlely, intensity of compression is higher, is also that the pixel mass loss gets also larger.The quality of common Jpeg image is at 60-80%.In transferring the process of Jpeg to, can the quality of jpeg be set according to different situations, when for example image being unessential Background, quality that can its quality setting is lower; When being main, important content to image, its quality can be arranged higher quality etc.In this embodiment, intermediate resolution refers to that the quality scope of Jpeg is 70~80, and high definition refers to that the quality scope of Jpeg is 95~100, and the quality scope of low definition Jpeg is 60~65.
Step S13: pdf document is converted to the SWF file according to the conversion parameter that arranges;
Different switching parameter according to set according to different content types in step S12 is converted to the SWF file with pdf document.PDF is converted to SWF belongs to existing technology, the user can select required switching software as required.Pdf document is carried out the SWF vector quantization, exactly pdf document is converted to the SWF file, can adopt gpdf2swf or other existing software to carry out; In addition, because PDF and SWF file layout are all disclosed, therefore also voluntarily coding carry out the reading and writing conversion process.
In case of necessity, converting the inspection of laggard pedestrian's work, can carry out independent processing to unsatisfied page again, the method that adopts this program interpretation to be combined with hand inspection can access better effect.
Adopt the method for the invention in practical application in following table, the different parameters setting when carrying out the SWF conversion for every page of dissimilar PDF content, and the contrast of the file size before and after conversion.By finding out in table, after adopting method conversion of the present invention, file size after conversion significantly reduces than original document, and for rear three types, adopt method of the present invention than the default parameter conversion method, its effect is also clearly, and the size of file is also having diminished clearly.
Table 1
Step S14: the SWF file is added that data head forms final e-book.
With the conversion after the SWF compressing file and add file header, form final e-book.In the application of reality, after the SWF after conversion is compressed, after adopting the Zip algorithm to compress, can adopt key that the data after compressing are encrypted, obtain confidentiality preferably, then for file adds data head, form final e-book.
When adopting the above-mentioned method of the present invention to carry out the e-book making, overcome and loved and respected that pdf document in prior art when being converted to the SWF file, the problem that specific aim is poor, document sharpness, size and the more serious problem of color conflict especially appear, during general outstanding wherein certain characteristic, normal significantly to sacrifice other characteristic as the problem of cost, method of the present invention this to different content types, be provided with respectively different conversion parameters, guarantee under the condition of higher document sharpness, color fidelity, keep simultaneously less document size.
Technical scheme for a better understanding of the present invention below in conjunction with specific embodiment, is carried out further detailed introduction to method of the present invention.
Embodiment
Describe as an example of the content (word is as main contents, image as background type) of the pdf document of the 4th type example in the present embodiment.
As shown in Figure 2, this original PDF document is very clear, and its size is 683k.If adopt default configuration to change to this page document, the part of its transformation result can find out that the image of changing out is also very clear, but size is larger, is 121k as shown in Figure 3, reduces the requirement of volume size for needs, and this result is undesirable.
The below adopts method of the present invention that this PDF content is changed.
At first judge with the method for the invention, know this PDF content, its word is main contents, and image section is less, therefore adopts the plan of establishment of " transfer image to the Jpeg form, and be set to very low sharpness, word keeps the font vector ".After arranging according to above-mentioned parameter, adopt prior art that pdf document is converted to the SWF file, the part as a result after conversion as shown in Figure 4.Can see that image section is comparatively fuzzy in the SWF file that produces, but word segment is very clear, and the file size after conversion is 45K.Obviously, in this case, the reader also is indifferent to auxiliary image section, and image section shows that comparatively fuzzy is acceptable.But word segment is extremely important, is the emphasis of readers ' reading, and should guarantee the font vector representation this moment, obtain the word of high-resolution, and big or small result is also very desirable.
Fig. 5 is the situation after the local amplification of Fig. 4, can see, it is fuzzyyer that image section becomes.But because it is inessential from the angle of content, we can accept this fuzzy for all; And the word segment of main body owing to being converted into vector, in the situation that amplification is a lot, has still kept higher sharpness.
Obviously, those skilled in the art can carry out various changes and modification and not break away from the spirit and scope of the present invention the present invention.Like this, if within of the present invention these are revised and modification belongs to the scope of claim of the present invention and equivalent technology thereof, the present invention also is intended to comprise these changes and modification interior.