Skip to content

YoichiroUrita/Misc.

Repository files navigation

Misc.

Miscellaneous


PDF to text

Sorry, this article is for Japanese.
PDF24 printerを使ってPDFを作成したものからテキストを抜き出すと文字化けしていました。
最初はphpのsmalot/PdfPaserを使って変換していて文字化けを起こしたので、他のを試そうと思いました。
なかなかPDFからテキストを抽出できるものでインストールできるものが有りません。
インストールしてあるPython2系統でも使えるpdfminer.sixを試したところが、やはり文字化けが。
ただし、文字化けを起こしているところが(cid:****)という形で表記されます。
数字はcidのmapとは一致しないので、手作業でマップを作るしかなさそう・・・
で、作業をしている途中で気づいたのですが、MS-OfficeからPDFに直接変換する場合では文字化けは起こらなかったんです。
なので、作業は途中でやめていますが、何かで使うこともあるかもと思いましたのでアップしておきます。

これは、pdfminer.sixを使ってテキストを抽出するもの。
でもPythonはわからないので、参照元のものをファイル名をプログラムの中で指定する方法から引数で渡す方法に変更しています。
pdfminer.sixはatoumとインストールするためにpipが必要になります。
自分はこちらを参考にさせて頂きました。
こちらは、上記のファイルを外部実行してreplaceするもの。
Pythonは全く設定していません。
ところが、ブラウザで結果を見たかったのと、修正後に抽出したテキストをMySQLに渡す予定だったので、ある程度慣れているphpを選んでいます。

Simple POST collector

My young co-worker asked "How to collect questionnaire by HTML ?", and she brought HTML written by a kind of old commercial HTML editor.

I suggest this script(PostCollection.php) , but it does not work....

I checked HTML , and finally find out the point of problem as below.

  <FORM ENCTYPE="text/plain" NAME=".......>

After removed encrypt type attribution, It works well. :P


This class is wrapper for MySQL PDO.

PDO This class Note
new PDO(***) new mysql_connector Parameters of connection are marked on head of this class
query(SQL) Query(SQL) Query() extract result directly. Fetch/FetchAll are not needed.(include)
prepare(SQL) Prepare(SQL) same as PDO
bindValue(PARAM,VALUE) BindValue(PARAM,VALUE) same as PDO
Excute() ExFetch() ExFetch() extract result directly. Fetch/FetchAll are not needed.(include)

It makes you reduce typing. ^_^


File list order by name for Windows

FilelistOrderByNameNotRecursive.bat is listing files order by name and is NOT recursive search.

See comments if you want another option.


File list with seeking sub-folder recursively by Excel

FilelistRecursively.vba is listing files by recursive search.

It is similar to above one but RECURSIVE.

BAT file is more quick. So choose this or BAT by your purpose.


Simple Example which output to browser from read XLSX file by PhpSpreadsheet.

This is a simple sample by PhpSpreadsheet.

PhpSpreadsheet is successor of PhpExcel, and deals with Excel Files (.xls,.xlsx,.xlsm and more).

I was looking for sample about output to browser from read XLSX. But that is rarely found.

So I wrote this for someone looking for same thing.