สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ใช้ window อะไรครับ
ลองใช้ path เต็ม ของ โปรแกรม xpdf มาใส่
ตามตัวอย่าง

โค้ด: เลือกทั้งหมด

exec('C:\Program Files\xpdf>pdftotext parameter')
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
touleg
PHP Super Member
PHP Super Member
โพสต์: 480
ลงทะเบียนเมื่อ: 25/01/2010 11:57 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย touleg »

ลองทำแล้วปรากฎว่าสามารถรันได้ แต่ได้ไฟล์ว่างเปล่า ที่มีชื่อว่า pdftotext ไม่มีนามสกุล

ผมเก็บไฟล์ไว้ตามนี้ครับ
C:/xpdf
C:/Appserv/pdftotextphp/test.php
C:/Appserv/pdftotextphp/0405601501.pdf

โค้ด: เลือกทั้งหมด

<?php
	$filename = "0405601501.pdf";
	$content = exec('C:\Program Files\xpdf>pdftotext '.$filename.'');
	echo $content;
?>
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

รูปแบบการใช้งาน

โค้ด: เลือกทั้งหมด

pdftotext [options] [PDF-file [text-file]]

OPTIONS
-f number
Specifies the first page to convert.

-l number
Specifies the last page to convert.

-layout
Maintain (as best as possible) the original physical layout of
the text. The default is to 'undo' physical layout (columns,
hyphenation, etc.) and output the text in reading order.

-fixed number
Assume fixed-pitch (or tabular) text, with the specified charac-
ter width (in points). This forces physical layout mode.

-raw Keep the text in content stream order. This is a hack which
often "undoes" column formatting, etc. Use of raw mode is no
longer recommended.

-htmlmeta
Generate a simple HTML file, including the meta information.
This simply wraps the text in <pre> and </pre> and prepends the
meta headers.

-enc encoding-name
Sets the encoding to use for text output. The encoding-name
must be defined with the unicodeMap command (see xpdfrc(5)).
The encoding name is case-sensitive. This defaults to "Latin1"
(which is a built-in encoding). [config file: textEncoding]

-eol unix | dos | mac
Sets the end-of-line convention to use for text output. [config
file: textEOL]

-nopgbrk
Don't insert page breaks (form feed characters) between pages.
[config file: textPageBreaks]

-opw password
Specify the owner password for the PDF file. Providing this
will bypass all security restrictions.

-upw password
Specify the user password for the PDF file.

-q Don't print any messages or errors. [config file: errQuiet]

-cfg config-file
Read config-file in place of ~/.xpdfrc or the system-wide config
file.

-v Print copyright and version information.

-h Print usage information. (-help and --help are equivalent.)
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
touleg
PHP Super Member
PHP Super Member
โพสต์: 480
ลงทะเบียนเมื่อ: 25/01/2010 11:57 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย touleg »

ก็ถูกนะครับ ลองรันกับ cmd ของ window ก็ใช้ได้นะครับ
touleg
PHP Super Member
PHP Super Member
โพสต์: 480
ลงทะเบียนเมื่อ: 25/01/2010 11:57 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย touleg »

http://loewyi.com/info/pdftotext-php-xpdf/

เค้าใช้แค่นั้นก็ใช้ได้แล้ว แต่ผมใช้ไม่ได้เหอะๆๆ
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ที่ผมเคยทำผมจะ exec() แปลง เป็นไฟล์ text แล้ว php อ่านไฟล์ text มาใช้อีกทีหนึ่ง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
touleg
PHP Super Member
PHP Super Member
โพสต์: 480
ลงทะเบียนเมื่อ: 25/01/2010 11:57 pm
ติดต่อ:

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย touleg »

เรียบร้อยได้แล้วครับ ความพยายามอยู่ที่ไหนความพยายามอยู่ที่นั่น เอ้ยความสำเร็จ

โค้ด: เลือกทั้งหมด

<?php
	$filename = "541170301.pdf";
	$content = exec('C:\AppServ\www\pdftotextphp\pdftotext.exe '.$filename.'');
	echo $content;
?>
ถ้าเอาไฟล์ pdftotext มาไว้ที่เดี๋ยวกับไฟล์เว้บเราก็เรียกแบบนี้ได้เลย

โค้ด: เลือกทั้งหมด

<?php
	$filename = "541170301.pdf";
	$content = exec('pdftotext.exe '.$filename.'');
	echo $content;
?>
ขอบคุณมากครับ
Naluebed Oneselfz
PHP Newbie
PHP Newbie
โพสต์: 2
ลงทะเบียนเมื่อ: 08/06/2017 1:48 pm

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย Naluebed Oneselfz »

อันนี้แก้ในไฟล์ไหนหรอครับที่เพิ่ม encoding ลงไปอะครับ
Naluebed Oneselfz
PHP Newbie
PHP Newbie
โพสต์: 2
ลงทะเบียนเมื่อ: 08/06/2017 1:48 pm

Re: สอบถามผู้รู้ แปลง PDF เป็น text หรือ HTML

โพสต์ที่ยังไม่ได้อ่าน โดย Naluebed Oneselfz »

อันนี้แก้ไฟล์ไหนหรอครับที่เพิ่ม encoding ลงไปอะครับ
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Amazon [Bot], Google [Bot] และบุคลทั่วไป 120