Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to add PNG image into RTF #15

Open
StefanPavlik opened this issue Jan 5, 2023 · 1 comment
Open

Not able to add PNG image into RTF #15

StefanPavlik opened this issue Jan 5, 2023 · 1 comment

Comments

@StefanPavlik
Copy link

StefanPavlik commented Jan 5, 2023

Summary:
It is not possible to add PNG image into RTF document.
Following exception is thrown:

com.lowagie.text.DocumentException: Only BMP, PNG, WMF, GIF and JPEG images are supported by the RTF Writer
	at com.lowagie.text.rtf.graphic.RtfImage.<init>(RtfImage.java:179)
	at com.lowagie.text.rtf.RtfMapper.mapElement(RtfMapper.java:168)
	at com.lowagie.text.rtf.RtfWriter2.add(RtfWriter2.java:186)
	at com.lowagie.text.Document.add(Document.java:302)

Steps to reproduce:
The problem can be reproduce by adding following code into CreateSimpleRTFDocumentTest.java file:

    document.add(new Paragraph("pngnow.png"));
    Image png = Image.getInstance("pngnow.png");
    document.add(png);

The "pngnow.png" file is taken from LibrePDF/OpenPDF source code.

Note: Adding JPG file works without problems.

Edited:
It seems that problem was introduced by this commit in OpenPDF repository. The class PngImage.java (and others) was removed. As a result the method setOriginalType(Image.ORIGINAL_PNG) is now not called at all.

@andreasrosdal
Copy link
Contributor

andreasrosdal commented Jan 27, 2023

Thank you for reporting this. Pull requests welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants