"HTML to docx Converter 설치"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 3명의 중간 판 13개는 보이지 않습니다)
9번째 줄: 9번째 줄:


==설치==
==설치==
*서버의 [[/usr/share/php/vendor 폴더]]에 zip파일 업로드<ref>폴더가 없으면 만들어서 넣자.</ref>
*서버의 [[/usr/share/php 폴더]]에 zip파일 업로드
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetawiki vendor]# ll htmltodocx_0_6_5_alpha.zip
[root@zetawiki ~]# cd /usr/share/php/
-rw-r--r-- 1 root root 623496 Aug 31 13:03 htmltodocx_0_6_5_alpha.zip
[root@zetawiki php]# ll htmltodocx*
</source>
-rw-r--r-- 1 root root 623496 Sep  9 13:06 htmltodocx_0_6_5_alpha.zip
*하위폴더 만들고 압축해제
</syntaxhighlight>
<source lang='cli'>
*하위폴더 htmltodocx에 압축해제
[root@zetawiki vendor]# mkdir htmltodocx
<syntaxhighlight lang='console'>
[root@zetawiki vendor]# unzip htmltodocx_0_6_5_alpha.zip -dhtmltodocx
[root@zetawiki php]# unzip htmltodocx_0_6_5_alpha.zip -dhtmltodocx
... (생략)
... (생략)
   inflating: htmltodocx/simplehtmldom/manual/manual_faq.htm   
   inflating: htmltodocx/simplehtmldom/manual/manual_faq.htm   
   inflating: htmltodocx/simplehtmldom/simple_html_dom.php   
   inflating: htmltodocx/simplehtmldom/simple_html_dom.php   
   inflating: htmltodocx/example.php
   inflating: htmltodocx/example.php
</source>
</syntaxhighlight>
*확인 후 zip 파일 삭제
<syntaxhighlight lang='console'>
[root@zetawiki php]# ll | grep htmltodocx
drwxr-xr-x  7 root root  4096 Sep  9 13:08 htmltodocx
-rw-r--r--  1 root root 623496 Sep  9 13:06 htmltodocx_0_6_5_alpha.zip
[root@zetawiki php]# rm -f htmltodocx_0_6_5_alpha.zip
[root@zetawiki php]#
</syntaxhighlight>


==test1.php 작성==
==test1.php 작성==
<source lang='cli'>
*홈 폴더로 이동하여 test1.php 작성
<syntaxhighlight lang='console'>
[root@zetawiki php]# cd
[root@zetawiki ~]# vi test1.php
[root@zetawiki ~]# vi test1.php
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
<?php
<?php
require_once 'vendor/htmltodocx/phpword/PHPWord.php';
require_once 'htmltodocx/phpword/PHPWord.php';
require_once 'vendor/htmltodocx/simplehtmldom/simple_html_dom.php';
require_once 'htmltodocx/simplehtmldom/simple_html_dom.php';
require_once 'vendor/htmltodocx/htmltodocx_converter/h2d_htmlconverter.php';
require_once 'htmltodocx/htmltodocx_converter/h2d_htmlconverter.php';


$html = '<html>
$html = '<html>
63번째 줄: 73번째 줄:
$objWriter = PHPWord_IOFactory::createWriter($phpword, 'Word2007');
$objWriter = PHPWord_IOFactory::createWriter($phpword, 'Word2007');
$objWriter->save('sample1.docx');
$objWriter->save('sample1.docx');
</source>
</syntaxhighlight>


==테스트==
==테스트==
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php test1.php
[root@zetawiki ~]# php test1.php
[root@zetawiki ~]# ll sample1.docx  
[root@zetawiki ~]# ll sample1.docx  
-rw-r--r-- 1 root root 8526 Sep  1 15:01 sample1.docx
-rw-r--r-- 1 root root 8526 Sep  1 15:01 sample1.docx
</source>
</syntaxhighlight>
:→ sample1.docx를 받아보니 잘 된다...
:→ sample1.docx를 받아보니 잘 된다...


==같이 보기==
==같이 보기==
*[[HTML to docx Converter 그림파일 포함]]
*[[HTML to docx Converter 그림파일 포함]]
*[[HTML to docx Converter 서버에 저장하지 않고 다운로드시키기]]
*[[SimpleHTMLDom]]
*[[SimpleHTMLDom]]
*[[PHPWord]]
*[[PHPWord]]


==참고 자료==
==참고==
*https://htmltodocx.codeplex.com/
*https://htmltodocx.codeplex.com/


[[분류: PHPWord]]
[[분류: HTML to docx Converter]]
[[분류: HTML to docx Converter]]
[[분류: CodePlex]]
[[분류: CodePlex]]

2020년 11월 2일 (월) 02:56 기준 최신판

HTML to docx Converter 설치

1 사전 작업[ | ]

2 다운로드[ | ]

3 설치[ | ]

Console
Copy
[root@zetawiki ~]# cd /usr/share/php/
[root@zetawiki php]# ll htmltodocx*
-rw-r--r-- 1 root root 623496 Sep  9 13:06 htmltodocx_0_6_5_alpha.zip
  • 하위폴더 htmltodocx에 압축해제
Console
Copy
[root@zetawiki php]# unzip htmltodocx_0_6_5_alpha.zip -dhtmltodocx
... (생략)
  inflating: htmltodocx/simplehtmldom/manual/manual_faq.htm  
  inflating: htmltodocx/simplehtmldom/simple_html_dom.php  
  inflating: htmltodocx/example.php
  • 확인 후 zip 파일 삭제
Console
Copy
[root@zetawiki php]# ll | grep htmltodocx
drwxr-xr-x  7 root root   4096 Sep  9 13:08 htmltodocx
-rw-r--r--  1 root root 623496 Sep  9 13:06 htmltodocx_0_6_5_alpha.zip
[root@zetawiki php]# rm -f htmltodocx_0_6_5_alpha.zip
[root@zetawiki php]#

4 test1.php 작성[ | ]

  • 홈 폴더로 이동하여 test1.php 작성
Console
Copy
[root@zetawiki php]# cd
[root@zetawiki ~]# vi test1.php
PHP
Copy
<?php
require_once 'htmltodocx/phpword/PHPWord.php';
require_once 'htmltodocx/simplehtmldom/simple_html_dom.php';
require_once 'htmltodocx/htmltodocx_converter/h2d_htmlconverter.php';

$html = '<html>
<body>
	<h1>Hello 친구들</h1>
	<ul>
		<li>하나</li>
		<li>둘</li>
	</ul>
	<table>
		<tr><td>1</td><td>한놈</td></tr>
		<tr><td>2</td><td>두시기</td></tr>
		<tr><td>3</td><td>석삼</td></tr>
	</table>
</body>
</html>';

$html_dom = new simple_html_dom();
$html_dom->load($html);
$html_arr = $html_dom->find('html',0)->children();

$phpword = new PHPWord();
$section = $phpword->createSection();

$state = array(
	'phpword_object' => &$phpword,
);

htmltodocx_insert_html($section, $html_arr[0]->nodes, $state);
$objWriter = PHPWord_IOFactory::createWriter($phpword, 'Word2007');
$objWriter->save('sample1.docx');

5 테스트[ | ]

Console
Copy
[root@zetawiki ~]# php test1.php
[root@zetawiki ~]# ll sample1.docx 
-rw-r--r-- 1 root root 8526 Sep  1 15:01 sample1.docx
→ sample1.docx를 받아보니 잘 된다...

6 같이 보기[ | ]

7 참고[ | ]