Git Product home page Git Product logo

itext-sample's Introduction

iText 7 sample

Preserve the embedded image

Sometimes you want to crop part of the image and add it to the PDF. If you use BufferedImage to manipulate the input images, some information will be lost. For example, exif or color profiles.

To keep the original image file untouched, you could crop the image by using PdfFormXObject. Then add the object to a PDFCanvas.

Example here https://github.com/leoleozhu/itext-sample/blob/master/src/test/java/com/leoleozhu/itextimage/ImageColorSpaceTest.java#L84

Spot color

In order to create a spot color in iText, we need to bind an alternate color space to the spot color (Separation).

Example here https://github.com/leoleozhu/itext-sample/blob/master/src/test/java/com/leoleozhu/itextcolor/SpotColorTest.java#L32

Add image with mask

iText has already provided an example for this topic. But if you apply a mask to a transparent image, you get blacked image.

The reason is that:

  • When you create ImageData with imageData = ImageDataFactory.create, there is already a mask image in imageData.getImageMask()
  • When you apply image mask with imageData.setImageMask(maskData);, the original image mask got replaced.

In order to correctly place an extra mask on the transparent image, you could combine both the original loaded image mask and the new one.

Example here https://github.com/leoleozhu/itext-sample/blob/master/src/test/java/com/leoleozhu/itextimage/ImageMaskTest.java#L87

The mask creation is not very fast. There could be better solutions for this use case.

itext-sample's People

Contributors

leoleozhu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.