Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@Nikita, This shall give you the detailed view of how its done :</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use Win32::OLE::Const 'Microsoft Word'; #$Win32::OLE::CP = CP_UTF8; binmode STDOUT, 'encoding(utf8)'; # OPEN FILE SPECIFIED AS FIRST ARGUMENT my $fname=$ARGV[0]; my $fnameFullPath = `cygpath.exe -wa $fname`; $fnameFullPath =~ s/\\/\\\\/g; $fnameFullPath =~ s/\s*$//; unless (-e $fnameFullPath) { print "Error: File did not exists\n"; exit 1;} # STARTING OLE my $Word = Win32::OLE-&gt;GetActiveObject('Word.Application') || Win32::OLE-&gt;new('Word.Application','Quit') or die Win32::OLE-&gt;LastError(); $Word-&gt;{'Visible'} = 0; my $doc = $Word-&gt;Documents-&gt;Open($fnameFullPath); my $paragraphs = $doc-&gt;Paragraphs() ; my $enumerate = new Win32::OLE::Enum($paragraphs); # PROCESSING PARAGRAPHS while(defined(my $paragraph = $enumerate-&gt;Next())) { my $text = $paragraph-&gt;{Range}-&gt;{Text}; my $sel = $Word-&gt;Selection; my $font = $sel-&gt;Font; if ($font-&gt;{Size} == 18){ print "Text: ", $text, "\n"; print "Font Bold: ", $font-&gt;{Bold}, "\n"; print "Font Italic: ", $font-&gt;{Italic}, "\n"; print "Font Name: ", $font-&gt;{Name}, "\n"; print "Font Size: ", $font-&gt;{Size}, "\n"; print "=========\n"; } } # CLOSING OLE $Word-&gt;ActiveDocument-&gt;Close ; $Word-&gt;Quit; </code></pre> <p>The output will be such:</p> <pre>Text: This is a doc file containing different fonts and size, document also contain header and footer (Font: TNR, Size: 18) Font Bold: 0 Font Italic: 0 Font Name: Times New Roman Font Size: 18 ========= Text: This is a Perl example (Font TNR, Size: 12) Font Bold: 0 Font Italic: 0 Font Name: Times New Roman Font Size: 18 ========= Text: This is a Python example(Font: Courier New, Size: 10) Font Bold: 0 Font Italic: 0 Font Name: Times New Roman Font Size: 18 =========</pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload