suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

Do you need to process or display PDF files?

Find out why you should be using IDRSolutions software

A Beginners guide to PDF Lattice Shading

1 min read

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

 lattice

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.



Our software libraries allow you to

Convert PDF files to HTML
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Read and write HEIC and other Image formats in Java
suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

How to insert an image into a PDF

Recently, we released JPedal 2023.07 which contains the ability to insert images into PDF files. All you need is a copy of JPedal, a...
Jacob Collins
18 sec read