At IDR Solutions Ive spent a lot of time working with the development of the JPedal Java PDF Library and PDF to HTML5 Converter I thought about writing an article on PDF lattice shading to illustrate how to achieve Lattice shading in PDF files.
Where can I get shading information ?
BitsPerCoordinate : This entry is used to represent the number of bits required to find x,y vertex coordinates.
BitsPerComponent : Entry used to represent number of bits required to define color components.
VerticesPerRow : This is the unique entry in lattice shading compared to free-form. Vertices per row defines how many vertices are located in a single row.
Decode : An array of number specifies how to map vertex coordinates and color components to appropriate ranges. [xmin xmax ymin ymax c1,min c1,max … cn,min cn,max]
You can find above information in the PDF reference, where it will be in more detail.
Mapping : In many PDF files large coordination space are defined with small coordination space and it will then map to large domain using decode array.
For example : the xy coordinates can be defined as x:0.50109 and y:0.52197 and use -16384.0 16384.0 -16384.0 16384.0 as array values in decode array entry in order to obtain x= 36.0, y= 720.0.
Data Representation : Triangle data in PDF files looks defined similar to below order if it contains 5 vertices per row:
x1y1c1…cn x2y2c1…cn x3y3c1…cn x4y4c1…cn x5y5c1…cn
x6y6c1…cn x7y7c1…cn x8y8c1…cn x9y9c1…cn x10y10c1…cn
Triangles are formulated connecting vertices points and color interpolation is used to define colors in triangular space. More information on color interpolation on freeform triangle mesh can be found in this article I wrote called ‘PDF Gouraud shading (Free-Form) Color Interpolation‘
I Hope you find this information useful and in the future I will investigate coons shading in my next article.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Find out more about our software for Developers
|Convert PDF to HTML5 or SVG|
|Convert AcroForms and XFA to HTML5|
|Java PDF SDK for working with PDF files|