Bug 59323 - Unable to process the document having bookmarks
Summary: Unable to process the document having bookmarks
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.13-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-14 15:55 UTC by adityagaitonde
Modified: 2016-05-17 19:37 UTC (History)
0 users



Attachments
Sample doc to reproduce the issue (138.00 KB, application/msword)
2016-04-14 15:55 UTC, adityagaitonde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adityagaitonde 2016-04-14 15:55:55 UTC
Created attachment 33761 [details]
Sample doc to reproduce the issue

When trying to process the document having bookmarks using POI, we get the following exception and the sample file is also attached to reproduce the issue.

CODE :

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.converter.WordToHtmlConverter;
import org.w3c.dom.Document;

import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.io.FileInputStream;

public class PoiIssues {

    public static void main(String[] args) throws Exception {
        File file = new File("C:\\test_wonders_of_world.doc");
        FileInputStream fileInputStream = new FileInputStream(file);
        Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(document);
        HWPFDocumentCore hwpfDocumentCore = new HWPFDocument(HWPFDocumentCore.verifyAndBuildPOIFS(fileInputStream));
        wordToHtmlConverter.processDocument(hwpfDocumentCore);
        System.out.println(document.toString());
        System.out.println("Process Complete");
    }
}
 
EXCEPTION : 

Exception in thread "main" java.lang.IllegalArgumentException: The end (117) must not be before the start (175)
	at org.apache.poi.hwpf.usermodel.Range.sanityCheckStartEnd(Range.java:213)
	at org.apache.poi.hwpf.usermodel.Range.<init>(Range.java:175)
	at org.apache.poi.hwpf.converter.AbstractWordConverter$2.<init>(AbstractWordConverter.java:411)
	at org.apache.poi.hwpf.converter.AbstractWordConverter.processCharacters(AbstractWordConverter.java:410)
	at org.apache.poi.hwpf.converter.WordToHtmlConverter.processParagraph(WordToHtmlConverter.java:576)
	at org.apache.poi.hwpf.converter.AbstractWordConverter.processParagraphes(AbstractWordConverter.java:1111)
	at org.apache.poi.hwpf.converter.WordToHtmlConverter.processSingleSection(WordToHtmlConverter.java:608)
	at org.apache.poi.hwpf.converter.AbstractWordConverter.processDocument(AbstractWordConverter.java:721)
	at PoiIssues.main(PoiIssues.java:20)