[
https://issues.apache.org/jira/browse/TIKA-3827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17575881#comment-17575881
]
Tika User commented on TIKA-3827:
---------------------------------
Below is the code:
You can easily extract text from the document using code like this:
{{Document doc = new Document("C:\Temp\in.doc");
doc.save("C:\Temp\out.txt");}}
Or of you need to extract text into a String, you can use code like this:
{{Document doc = new Document("C:\Temp\in.doc");
String docText = doc.toString(SaveFormat.TEXT);}}
The following code can be used for image extraction:
{{Document doc = new Document("C:\Temp\in.doc");
Iterable<Shape> shapes = doc.getChildNodes(NodeType.SHAPE, true);
int counter = 0;
for (Shape s : shapes)
\{
if (s.hasImage())
{
s.getImageData().save("C:\Temp\img_" + counter +
FileFormatUtil.imageTypeToExtension(s.getImageData().getImageType()));
counter++;
}
}}}
> Word Document extracted mpga file extension instead of bitmap
> --------------------------------------------------------------
>
> Key: TIKA-3827
> URL: https://issues.apache.org/jira/browse/TIKA-3827
> Project: Tika
> Issue Type: Bug
> Components: parser
> Reporter: Tika User
> Priority: Major
> Attachments: Screenshot from 2022-08-04 06-05-09.png, example.DOC,
> example.zip, file_1.bmp, file_2.bmp, image-2022-08-04-10-52-44-800.png,
> image-2022-08-04-10-53-48-894.png, image-2022-08-04-15-44-48-396.png,
> image-2022-08-04-15-45-10-892.png
>
>
> When tried to parser the .doc document it is extracted two mpga files which
> can't be open to play. We are suspecting they should be bitmap image files.
> The Tika version we are using is 2.4.1.
> [^example.DOC]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)