CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 21:59:54 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"224b2ecda4b21efae0d1c5ba94024642"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=gDtlNoDR4SAu%2BMZbEmPFwqNUjzFCBNVe00R9m2Tiw%2BAnQRdvNNtE0lNV5cVAXvwqArlWDXKt%2FhiDCOh%2B%2FiQLOATwAH8iEDKm3IMhpK13dJnzYfNR%2BqZKN9YM6cTPpkFAdD4NOQH6kM2wxbHrWbeRXL6e%2FtkUo8hhGROxyf1t78gFeyOJ6V4VlTcvQu64WrLlFwMRBrMvhtqjjvpzEs%2F4wz4xkX1p7qv0vdFvP6j5v6cFLvIKcdz4kPzzuCUKwTooDTMpYRxq26WSn9r1BFAbwg%3D%3D--AU3Rurj2enrGuKyc--sqgOSJkdKUsB1dERBxcVGg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.849885788.1753307993; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 21:59:53 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 21:59:53 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 85C4:221257:14017F:1AC929:68815B59
Migrating from iText 2 and 4 · LibrePDF/OpenPDF Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 654
Migrating from iText 2 and 4
Andreas R edited this page Feb 29, 2024
·
7 revisions
One goal of LibrePDF is to maintain compatibility with iText, to be a drop-in replacement of iText.
OpenPDF 2.0.0 removed some deprecated methods, please review the JavaDoc for methods available in various versions: OpenPDF JavaDoc
But compatibility is not always possible, so we collect all changes you need to do in your code:
You must depends on twelvemonkeys
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-tiff</artifactId>
<version>3.4.1</version>
</dependency>
You can use the standard approach
Image tif = Image.getInstance("iText.tif");
but if you need to read a multipage TIFF
iText 2 RandomAccessFileOrArray + TiffImage
RandomAccessFileOrArray randomAccess =
new RandomAccessFileOrArray(
file.getAbsolutePath(),
false,
Document.plainRandomAccess);
int pages = TiffImage.getNumberOfPages(randomAccess);
for (int i = 1; i <= pages; i++) {
Image image = TiffImage.getTiffImage(randomAccess, i);
document.add(image);
}
OpenPDF
try (ImageInputStream iis = ImageIO.createImageInputStream(file)) {
ImageReader reader = getTiffImageReader();
reader.setInput(iis);
int pages = reader.getNumImages(true);
for (int imageIndex = 0; imageIndex < pages; imageIndex++) {
BufferedImage bufferedImage = reader.read(imageIndex);
Image image = Image.getInstance(bufferedImage, null, false);
document.add(image);
}
}
private static ImageReader getTiffImageReader() {
Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByFormatName("TIFF");
if (!imageReaders.hasNext()) {
throw new UnsupportedOperationException("No TIFF Reader found!");
}
return imageReaders.next();
}
iText 2
PdfReader reader = new PdfReader(origin);
PdfStamper stamper = new PdfStamper(reader, out);
reader.getCatalog().remove(PdfName.METADATA);
HashMap<String, String> info = reader.getInfo();
info.put("Title", "new title");
// ....
stamper.setMoreInfo(info);
OpenPDF & iText compatible
PdfReader reader = new PdfReader(origin);
PdfStamper stamper = new PdfStamper(reader, out);
reader.getCatalog().remove(PdfName.METADATA);
// This function now return Map
Map<String, String> info = reader.getInfo();
info.put("Title", "new title");
// ....
// And now we need a cast
// (setMoreInfo is deprecated in OpenPdf but the alternative doesn't exists in itext)
stamper.setMoreInfo((HashMap)info);
OpenPDF has no self implementation of Base64 anymore, and com.lowagie.text.pdf.codec.Base64
was removed. Please use java.util.Base64 instead.
You can’t perform that action at this time.