How to read picture/image from word document using Win32::OLE in perl

Using Win32::OLE i am able to read tables, paragraphs from word document. But i want to read picture/image from word document, is there any function to get pictures ?

Below is the code for tables and paragraphs reading.

$Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application');
$Word->{'Visible'}     = 0;
$Word->{DisplayAlerts} = 0;

my $document = $Word->Documents->Open($Req_doc_path);

### for tables reading
my $tables = $document->{'Tables'};
for my $table (in $tables){
   my $tableText = $table->ConvertToText({ Separator => wdSeparateByTabs });
   #print "Table: ", $tableText->Text(), "\n";
}

### for paragraphs reading
$paragraphs = $document->paragraphs();
$enumerate = new Win32::OLE::Enum($paragraphs);
while(defined($paragraph = $enumerate->Next()))
{

}
#

please help me out to read images/pictures also. Thanks in advance.

Answers


You need InlineShapes() and Shapes for this:

#!/usr/bin/perl

use Modern::Perl;
use Win32::OLE;

my $Word = Win32::OLE->GetActiveObject('Word.Application')
  || Win32::OLE->new('Word.Application');
$Word->{'Visible'} = 0;
$Word->{DisplayAlerts} = 0;

my $document = $Word->Documents->Open("test.docx");

my $shapes = $document->InlineShapes(); #you need to process $document->Shapes() also


my $enumerate = new Win32::OLE::Enum($shapes);
while ( defined( my $shape = $enumerate->Next() ) ) {

    say "Width: ", $shape->Width();
}

Need Your Help

Deserialise a Json object containing a Json String

parsing json

I have a problem where I am unable to de-serialise a Json string to an object in cases where the object already has a Json string in it.

what does following sql code do?

sql oracle oracle11g

guys i have seen following code in internet

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.