You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by sujanpatnana <su...@gmail.com> on 2019/10/19 19:23:38 UTC

NullPointerException on repeated execution of XSLFTextShape.getTextHeight()

Hi Team,

I am receiving NullPointerException while running the following code.
The output seems strange as I get value for XSLFTextShape.getTextHeight()
and when the same method execute after few lines code it throws null pointer
in the same object. Here is the code sample.
==========================================
                     XMLSlideShow ppt = new XMLSlideShow();
		     XSLFSlideMaster slideMaster = ppt.getSlideMasters()[0];
		     XSLFSlideLayout slidelayout =
slideMaster.getLayout(SlideLayout.TITLE_AND_CONTENT);
		     XSLFSlide slide = ppt.createSlide(slidelayout);
		      
		     XSLFTextShape box = slide.getPlaceholder(1);

			final double maxHeight = box.getAnchor().getHeight();
			System.out.println("maxHeight " + maxHeight);
			
			box.clearText();
			XSLFTextParagraph p = box.addNewTextParagraph();
			p.addNewTextRun().setText("Sujan Sujan 1  ");
			System.out.println("box.getText() ->" + box.getText());	

			System.out.println("textHeight 0 " + box.getTextHeight());
			box.addNewTextParagraph().addNewTextRun().setText("Patnana Patnana 2");
			System.out.println("textHeight 1 " + box.getTextHeight());

			box.addNewTextParagraph().addNewTextRun().setText("Patnana Patnana 3");
			System.out.println("textHeight 2 " + box.getTextHeight());

			box.addNewTextParagraph().addNewTextRun().setText("Patnana Patnana 4");
			System.out.println("textHeight 3 " + box.getTextHeight());
=============================================
O/P

maxHeight 356.37503937007875
box.getText() ->Sujan Sujan 1  
textHeight 0 40.0625
java.lang.NullPointerException
	at
org.apache.poi.xslf.usermodel.XSLFTextShape.drawParagraphs(XSLFTextShape.java:529)
	at
org.apache.poi.xslf.usermodel.XSLFTextShape.getTextHeight(XSLFTextShape.java:455)
	at apapoisample.OverFlowText.overflow(OverFlowText.java:49)
	at apapoisample.OverFlowText.main(OverFlowText.java:24)

Please look into this. This seem to be bug for me. I am using POI 3.9
version.

Thanks in advance for your help.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: NullPointerException on repeated execution of XSLFTextShape.getTextHeight()

Posted by kiwiwings <ki...@apache.org>.
Hi,

please try with a current POI version first, e.g. I've just released POI
4.1.1.

Andi



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org