Jump to content

AutoIt Library For epub/pdf to TXT file Conversion?


Recommended Posts

he's not a UDF but he's doing this job.

instead of .pdf  give .epud  file

Local $pdf = "D:\Documents\_pdf\MX Linux Users Manual.pdf"

_PdfToTxt($pdf)


; #FUNCTION# ----------------------------------------------------------------------------
; Name...........: _PdfToTxt()
; Description ...: Save pdf as text with SumatraPDF
; Syntax.........: _PdfToTxt($pdf [, $Dest])
; Parameters ....: $pdf     - The path of source pdf file
;                  $Dest    - The dir destnation where txt file save
; Notes .........: if no $Dest parameter then destnation = source dir
; https://www.sumatrapdfreader.org/download-free-pdf-viewer
;----------------------------------------------------------------------------------------
Func _PdfToTxt($pdf, $Dest = "")
    Local $Sumatra, $hWnd, $hSvWnd, $txt, $aTmp

    $Sumatra = "D:\i\Pro\SumatraPDF-3.4.6\SumatraPDF-3.4.6-32.exe"

    If $Dest = "" Then
        $txt = StringTrimRight($pdf, 4) & ".txt"
    Else
        If StringRight($Dest, 1) = "\" Then
            $Dest = StringTrimRight($Dest, 1)
        EndIf
        $aTmp = StringSplit($pdf, "\", 1)
        $txt = $aTmp[$aTmp[0]]
        $txt = $Dest & "\" & StringTrimRight($txt, 4) & ".txt"
    EndIf

    Run('"' & $Sumatra & '" "' & $pdf & '"', "", @SW_MINIMIZE)

    $hWnd = WinWait("[CLASS:SUMATRA_PDF_FRAME]")
    ControlSend($hWnd, "", "SUMATRA_PDF_CANVAS1", "^s")

    $hSvWnd = WinWait("Save As")
    ControlSetText($hSvWnd, "", "ComboBox1", $txt)
    ControlCommand($hSvWnd, "", "ComboBox2", "SelectString", 'Text documents')
    ControlSend($hSvWnd, "", "Button2", "{ENTER}")

    WinClose($hWnd)

EndFunc   ;==>_PdfToTxt

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...