We are delighted to announce the release of Spire.PDF for Java 10.1.3. This version adds the PdfTextReplacer interface to implement text replacement function and the PdfImageHelper interface to implement image deletion, extraction, replacement, and compression functions. Besides, it improves the efficiency of drawing watermarks. More details are listed below.
Here is a list of changes made in this release
| Category | ID | Description |
| New feature | SPIREPDF-6454 | Improves the efficiency of drawing watermarks. |
| New feature | SPIREPDF-6459 | Adds the PdfTextReplacer interface to implement text replacement function.
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile("sample.pdf");
PdfPageBase page = pdf.getPages().get(0);
PdfTextReplacer replacer = new PdfTextReplacer(page);
PdfTextReplaceOptions options= new PdfTextReplaceOptions();
options.setReplaceType(EnumSet.of(ReplaceActionType.WholeWord));
replacer.replaceText("www.google.com", "1234567");
pdf.saveToFile(outputFile);
|
| New feature | - | Adds the PdfImageHelper interface to implement image deletion, extraction, replacement, and compression functions. Key code snippet: PdfImageHelper imageHelper = new PdfImageHelper();
PdfImageInfo[] imageInfoCollection= imageHelper.getImagesInfo(page);
Delete image:
imageHelper.deleteImage(imageInfoCollection[0]);
Extract image:
int index = 0;
for (com.spire.pdf.utilities.PdfImageInfo img : imageInfoCollection) {
BufferedImage image = img.getImage();
File output = new File(outputFile_Img + String.format("img_%d.png", index));
ImageIO.write(image, "PNG", output);
index++;
}
PdfImage image = PdfImage.fromFile("ImgFiles/E-iceblue logo.png");
imageHelper.replaceImage(imageInfoCollection[i], image);
Compress image:
for (PdfPageBase page : (Iterable<PdfPageBase>)doc.getPages())
{
if (page != null)
{
if (imageHelper.getImagesInfo(page) != null)
{
for (com.spire.pdf.utilities.PdfImageInfo info : imageHelper.getImagesInfo(page))
{
info.tryCompressImage();
}
}
}
}
|
| Bug | SPIREPDF-6468 | Fixes the issue that the program threw java.lang.StringIndexOutOfBoundsException exception when saving documents. |
Click the link below to download Spire.PDF for Java 10.1.3: