Hi Andreas,

PFA PPTX file for your review.

Thanks,
Simanchal

On Thu, Jan 30, 2014 at 2:44 AM, Andreas Beeker [via Apache POI]
<[email protected]> wrote:
> Hi,
>
> is there a chance to get your .pptx-files?
>
> - link it to your stackoverflow post [1]
> - or open a bugzilla entry [2]
> - or send it to my email address (least preferred ...)
>
> Andi.
>
>
> [1]
> http://stackoverflow.com/questions/21386211/retrieving-content-of-hyperlinked-slides-in-powerpoint-files-pptx-through-apac
> [2] http://issues.apache.org/bugzilla/buglist.cgi?product=POI
>
> On 29.01.2014 07:21, simanchal maharana wrote:
>
>> I am trying to get the text content of powerpoint files and replace with
>> some
>> other text. I have a powerpoint file of 20 slides. where 13,14,15,16
>> slides
>> have hyperlink to 17,18,19 and 20th slide. I am using XMLSlideshow to
>> traverse through the slides, But it gives only 16 slides. It does not give
>> last 4 hyperlinked slides.
>>
>> Any idea really appreciable in advance how can I get content of all
>> hyper-linked slides and Replace by some other text.
>>
>> here is my code.
>>
>> import java.io.FileInputStream;
>> import java.io.FileOutputStream;
>> import org.apache.poi.xslf.usermodel.XMLSlideShow;
>> import org.apache.poi.xslf.usermodel.XSLFShape;
>> import org.apache.poi.xslf.usermodel.XSLFSlide;
>> import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
>> import org.apache.poi.xslf.usermodel.XSLFTextShape;
>> import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
>> public class Testing {
>> static String inputFile =
>> "C:\\Users\\SM78882\\Desktop\\Testing\\IE_Basics_English.pptx";
>> static String outputFile =
>> "C:\\Users\\SM78882\\Desktop\\Testing\\result.pptx";
>>
>> public static String replaceUnwantedChar(String originalString) {
>> if (null != originalString)
>> return "" + originalString.replaceAll("(\n+)|(\t+)|(\\s{2,})", " ")
>> .trim();
>> else
>> return "";
>> }
>> public static void main(String[] args) {
>> FileInputStream fis = null;
>> FileOutputStream fos = null;
>> XMLSlideShow ppt = null;
>> try {
>> fis = new FileInputStream(inputFile);
>> fos = new FileOutputStream(outputFile);
>> ppt = new XMLSlideShow(fis);
>> System.out.println("No of slides:" + ppt.getSlides().length); // gives 16
>> slides.
>> for (XSLFSlide slide : ppt.getSlides()) {
>> for (XSLFShape shape : slide) {
>> if (shape instanceof XSLFTextShape) {
>> XSLFTextShape txShape = (XSLFTextShape) shape;
>> for (XSLFTextParagraph xslfParagraph : txShape .getTextParagraphs()) {
>> String originalText = replaceUnwantedChar(xslfParagraph .getText());
>> if (!originalText.isEmpty()) {
>> String translation = "";
>> if (translation != null) {
>> CTRegularTextRun[] ctRegularTextRun = xslfParagraph
>> .getXmlObject().getRArray();
>> for (int index = ctRegularTextRun.length - 1; index > 0; index--) {
>> xslfParagraph.getXmlObject().removeR( index);
>> }
>> if (ctRegularTextRun.length > 0)
>> ctRegularTextRun[0].setT(translation);
>> }
>> }
>> }
>> }
>> }
>> }
>> ppt.write(fos);
>> fos.close();
>> fis.close();
>> } catch (Exception ex) {
>> ex.printStackTrace();
>> }
>> }
>> }
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-poi.1045710.n5.nabble.com/Retrieving-content-of-hyperlinked-slides-in-powerpoint-files-PPTX-through-apache-POI-tp5714766.html
>> Sent from the POI - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-poi.1045710.n5.nabble.com/Retrieving-content-of-hyperlinked-slides-in-powerpoint-files-PPTX-through-apache-POI-tp5714766p5714769.html
> To unsubscribe from Retrieving content of hyperlinked slides in powerpoint
> files(.PPTX) through apache POI, click here.
> NAML


Final_2.7z (16M) 
<http://apache-poi.1045710.n5.nabble.com/attachment/5714773/0/Final_2.7z>
IE_Basics_English.pptx (4M) 
<http://apache-poi.1045710.n5.nabble.com/attachment/5714773/1/IE_Basics_English.pptx>
PPTXParser_Code.java (4K) 
<http://apache-poi.1045710.n5.nabble.com/attachment/5714773/2/PPTXParser_Code.java>




--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Retrieving-content-of-hyperlinked-slides-in-powerpoint-files-PPTX-through-apache-POI-tp5714766p5714773.html
Sent from the POI - User mailing list archive at Nabble.com.

Reply via email to