Created attachment 29643 [details] This zip contains the PPT file and the PNG image resulting from the code above When converting the attached PPT file with HSLF, and the code below, some of the text (but not all of it) is rendered as if seen in a mirror (see the PNG file attached). Code snippet: InputStream is = getInputStream(); //A FileInputStream on the ppt file SlideShow ppt = new SlideShow(is); Dimension pgsize = ppt.getPageSize(); double scaleW = (double)TARGET_WIDTH / (double)pgsize.width; double scaleH = (double)TARGET_HEIGHT / (double)pgsize.height; double scale = Math.min(scaleW, scaleH); int width = (int) (pgsize.width * scale); int height = (int) (pgsize.height * scale); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); graphics.setPaint(Color.white); graphics.clearRect(0, 0, width, height); graphics.scale((double)width/pgsize.width, (double)height/pgsize.height); slide[i].draw(graphics); // save the result File image = new File(root, "slide"+Integer.toString(i)+".png"); ImageIO.write(img, "png", image); }
The trouble is with rendering text in flipped shapes. It appears that text in shapes follows the rotation transform, but does not follow the flip transform. That is, if a shape is rotated then any text inside this shape is rotated too, but if a shape is flipped then the text follows the original (not flipped) transform. In current implementation it is not so and the text in flipped shapes is painted upside down. PPTX2PNG has the same problem.
Here's a proposed patch that takes horizontal and vertic
Created attachment 29654 [details] Proposed patch generated with patch.xml Here's a proposed patch that takes horizontal and vertical flips, as well as rotation for TextPainter
The patch is empty. Please try again. (In reply to comment #3) > Created attachment 29654 [details] > Proposed patch generated with patch.xml > > Here's a proposed patch that takes horizontal and vertical flips, as well as > rotation for TextPainter
Created attachment 29656 [details] Text patch The gerenated gz patch does not seem to contain the patch; however, a patch.txt file is generated with the changes in it, so I attached that one instead, hope it'll be ok.
Thanks for the patch, applied in r1416165 with some tweaks. Yegor
You're welcome! Any idea ni what release it would be included and when that would be released? (In reply to comment #6) > Thanks for the patch, applied in r1416165 with some tweaks. > > Yegor
The fix will be included in POI-4.0 which is expected in 2013. I recommend to use the latest build from trunk which can be downloaded from https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/ Yegor (In reply to comment #7) > You're welcome! Any idea ni what release it would be included and when that > would be released? > > (In reply to comment #6) > > Thanks for the patch, applied in r1416165 with some tweaks. > > > > Yegor
Hello, do you have any idea of when version 4.0 will be released? Alternatively, would it be possible to include the fix for this bug in in 3.9.X release? Thanks.
It's unlikely to be very soon, as most of the committers to Apache POI are very busy, and there are a lot of contributed patches that need to be applied first for now, you can either use a nightly build, or checkout from svn and build yourself
Hello, I just did a test with POI 3.10-FINAL which according to http://poi.apache.org/changes.html should contain the fix (it's included since the beta-1), but I still have the image mirrored from the ppt in the attachemnt I sent when I opened the issue. Note that to be able to test, the ppt must first be edited and the title's font changed from Calibri to anything else, because there seems to be a JDK bug that gives an ArrayOutOfBoundException when using the Calibri font. I changed to Arial and after that I still get the mirrored version. Would it be possible to have another look? Thanks, Vincent.
It'd be helpful if you could create a test file with various flipped / rotated / flipped and rotated bits of text in it. Ideally with a few different fonts and sizes for each one. Maybe a few directional shapes too, while we're at it. With that done, please attach the file, try rendering it with POI, and report back which ones work and which ones don't. With that info, it'll be much easier to hone in on what's still a problem, and which bits we've already fixed
Well I attached a ZIP file when I created the issue; it contains a .ppt file which shows the issue when used with the code I mentioned in my first comment. To be honest I have no idea how the PPT was created as it came from a customer of mine (I just changed the text). But that file definitely causes the issue. I re-attached it with the font changed as I previously explained that the JJVM can't seem to handle Calibri anymore, and put the result PNG I get after calling the aforementioned code. Is that sufficient for you?
Created attachment 31312 [details] A PPT test case and the result of the conversion
The backward.ppt fails in JDK 1.6.0_45, but works in JDK 1.7.0_45 (Windows) with the current POI trunk and the text is also displayed the same way as the MS PPT Viewer would do. There's a quite recent bug report on IBM JDK [1], which is probably the same for Oracle/Sun JDK 1.6. Is it really necessary to workaround the linebreak measurer stuff in POI? (... maybe skip JDK 1.6 support and continue with 1.7 directly :) ...) [1] http://www-01.ibm.com/support/docview.wss?uid=swg1IV47787
Hello, do you have any news about this? Cheers Vincent
Is this related to #55644, i.e. is this affected by the following JDK bug? https://bugs.openjdk.java.net/browse/JDK-8013716
Hi, thanks for your reply. I only discovered what is described in the linked issue by trying to prepare a test case for the original issue, which is that some text was mirrored (inverted). I submitted a patch that was adapted and integrated a relatively long time ago (a few months); then I downloaded a version of POI that integrated that patch, but I still had the issue, and I created a test case, where I noticed the font issue. So in short, no, it's not linked, and the original issue was still there last time I tried. That being said, I haven't tried since February, maybe it's been fixed in the meantime, but then I would have expected this issue to be updated :) Cheers Vincent
I've just validated the rendering. The expected output is non-mirrored texts, right!? On my Win7/64 machine with the 32-bit version of 1.6.45 but with the old fontmanager.dll of 1.6.43 it works. with the 1.6.45-fontmanager.dll I get the AIOOBE. with 1.7.45 it works.
I wonder if it's worth putting something on the site to list "known broken" JVMs for Apache POI? IIRC Apache Lucene do something similar for ones they have found to not work
Hi, What is the status of this issue? I see it's marked as 'NEEDINFO', however I don't see what more I can provide. The last comments brought some confusion to me; The goal is indeed to not have flipped text, no matter the font used in the document. Thanks! Vincent
I've changed two issues as part of r1714290 - the default alignment of text is now top - the old flipping code contained an unnecessary rotation, instead of it the code now traverses the parent group for flipping and supports text rotation, i.e. an additional rotation to the shape rotation
Hi, Thanks very much. Do you know in what version this will be available, and when it will be released? Thanks, Vincent.
We are working towards 3.14-Beta1 now - which will be available in 1-2 weeks. I think most of the changes were already in 3.13 with the common-sl upgrade, but the next beta contains the fixes mentioned in comment 23
OK thanks for the info. I'll try to find some time to test the 3.14 beta when it's out.