2013-05-31 3 views
5

Perl에서 아래의 Microsoft Presentation Object Properties를 사용하는 방법을 알려주십시오.Perl을 사용하여 암호로 보호 된 PPT 파일

http://msdn.microsoft.com/en-us/library/office/bb251459(v=office.12).aspx

는 기본적으로 나는 프레젠테이션을 보호하기 위해 암호 속성을 사용하고 싶습니다.

+2

일반적으로 할 수 없습니다. ppt 파일은 매우 독점적이며 Perl에서이 파일에 액세스하는 모듈을 모릅니다. PowerPoint를 동일한 컴퓨터에 설치 한 경우 Win32 :: Ole을 사용하여 Perl에서 PowerPoint를 자동화 할 수 있습니다 (예 : 몇 가지 힌트를 보려면 http://www.perlmonks.org/?node_id=922835를 참조하십시오) – FtLie

답변

1

이 스크립트는 위의 @FtLie의 설명에 따라 angiehope의 perlmonks 기사를 기반으로합니다. 필자는 Office 2010에서이를 테스트했습니다. 스크립트는 스크립트와 동일한 파일에 ppt_test.ppt라는 파일을 만들고 저장된 문서에 암호 'secret'을 설정합니다.

use strict; 
use warnings; 
use v5.10; 

use Try::Tiny; 
use Data::Dumper; 
use Carp; 

use FindBin qw ($Bin); 

use Win32::OLE qw(in CP_UTF8); 
Win32::OLE->Option(CP => CP_UTF8); 
$Win32::OLE::Warn = 3; 
my $filename = "$Bin/ppt_test.ppt"; 
unlink $filename if (-e $filename); 

print("Starting Powerpoint Object\n"); 
my $power = Win32::OLE->GetActiveObject('Powerpoint.Application') || 
    Win32::OLE->new('Powerpoint.Application', 'Quit'); 

my $ppt = $power->Presentations->Add(); 
# 12 = blank layout 
my $slide = $ppt->Slides->Add(1,12); 
# 1 = text in horizontal direction, the next two numbers describe the position 
# and the last numbers the width and height of the box 
my $new_textbox = $slide->Shapes->AddTextbox(1,30,30,600,200); 
my $text_frame = $new_textbox->TextFrame; 
my $text_range = $text_frame->TextRange; 
$text_range->{Text} = "Please print \x{03B1},\x{03B2},\x{03B3}"; 

# Now set the password 
my $password = 'secret'; 
$ppt->{Password} = $password; 

$ppt->SaveAs($filename); 
$ppt->Close(); 
관련 문제