Hi
when replacing an image in pdf the image size increases by ~3 times.
i checked and this happens even when replacing the image with the exact same image without any changes, like in the code below:
private void replaceImageWithItself(String inputPath){
Document doc = new Document(inputPath);
for (Page page: doc.getPages()) {
XImageCollection xImageCollection = page.getResources().getImages();
for (int i = 1; i <= xImageCollection.size(); i++) {
byte[] bytes;
ByteArrayOutputStream imageOutStream = new ByteArrayOutputStream();
XImage image = xImageCollection.get_Item(i);
bytes = imageOutStream.toByteArray();
xImageCollection.replace(i, new ByteArrayInputStream(bytes));
}
}
doc.save();
}
how can I replace or add an image without to change the quality or increase the size?
Would you please share your sample document and sample image for our reference? We will test the scenario in our environment and address it accordingly.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-44766
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.