Pdf2docx: 変換後のdocxファイルの問題

作成日 2021年05月13日  ·  7コメント  ·  ソース: dothinking/pdf2docx

コミュニティへようこそ。プログラミングは初めてです。 だから、事前のおかげで、私はpycharmでプログラムを実行し、変換が開始され、問題なく動作しているようです(ページの解析...->ページの作成...など)、ファイルがあったディレクトリに移動すると保存して、変換が機能したかどうかを確認するために、添付の画像に何が表示されているかを確認します(docxファイルはテキストではなく断片のように画像のように表示されます)。それを修正する方法があります。
problem

good first issue question

最も参考になるコメント

わかりました、私はそれを念頭に置いています、あなたの迅速な返事をありがとう。 私はあなたがすでにユーザーインターフェースを行っているかどうかわかりませんが、私はあなたのプログラムのための基本的なフレンドリーなユーザーインターフェースを行いました、そしてここにこれからのコードがあります。

from pdf2docx import Converter
from tkinter import *
from tkinter.filedialog import *
from tkinter import filedialog

root = Tk()
root.title('PDF_2_Docx Converter')
root.geometry('500x500')
root.config(bg='grey')


def pdf_file_location():
    Tk().withdraw()
    filename = askopenfilename()
    file_path_pdf_entry.insert(0, filename)


def docx_folder_location():
    Tk().withdraw()
    folder_selected = filedialog.askdirectory() + "/" + 'New_DOCX.docx'
    file_path_docx_entry.insert(0, folder_selected)


def convert_button_function():
    cv = Converter(file_path_pdf_entry.get())
    cv.convert(file_path_docx_entry.get(), start=0, end=None)
    cv.close()


"""Labels"""
label1 = Label(text='PDF to Docx', font='Impact 40', bg='white', fg='#1E90FF')
label1.grid(column=2, row=1, sticky='n', pady=50, padx=120)


"""Entries"""

# PDF file entry
file_path_pdf_entry = Entry(border=5)
file_path_pdf_entry.grid(ipadx=90, ipady=4, padx=20, sticky='nw', column=2, pady=1, row=2)

# Docx file entry
file_path_docx_entry = Entry(border=5)
file_path_docx_entry.grid(column=2, ipady=4, ipadx=90, padx=20, sticky='nw', pady=70, row=3)

"""Buttons"""

# Convert Button
converter_button = Button(text='Convert', bg='#1E90FF', fg='white', font='impact 20', border=5,
                          command=convert_button_function)
converter_button.grid(padx=175, sticky='s', ipady=5, ipadx=10, column=2, row=4)

select_pdf_file = Button(text='Select PDF file', fg='black', bg='white', border=3,
                         command=pdf_file_location)
select_pdf_file.grid(column=2, sticky='ne', row=2, pady=6, padx=60)

select_new_file_folder = Button(text='Select new file folder', fg='black', bg='white', border=3,
                                command=docx_folder_location)
select_new_file_folder.grid(column=2, sticky='ne', row=3, pady=74, padx=26)


root.mainloop()

全てのコメント7件

こんにちは、ようこそ。 スクリーンショットから、あなたが見た「テキスト」は実際のテキストではないと思います。 テキストをコピーして貼り付けることはできますか? 私のテストのためにPDFをアップロードできれば素晴らしいと思います(失敗した1ページで十分です)。

one_page.pdf

変換したいPDF。


one_page.docx

変換されたdocx。

これがお役に立てば幸いです

申し訳ありませんが、 pdf2docx制限の1つは、テキストベースのPDFのみを処理できることです。 あなたのPDFページは複数の画像で構成されています。これらの画像は作成されませんが、docxに直接コピーされます。 以下のスクリーンショットは、PDF形式の画像を示しています。

image

わかりました、私はそれを念頭に置いています、あなたの迅速な返事をありがとう。 私はあなたがすでにユーザーインターフェースを行っているかどうかわかりませんが、私はあなたのプログラムのための基本的なフレンドリーなユーザーインターフェースを行いました、そしてここにこれからのコードがあります。

from pdf2docx import Converter
from tkinter import *
from tkinter.filedialog import *
from tkinter import filedialog

root = Tk()
root.title('PDF_2_Docx Converter')
root.geometry('500x500')
root.config(bg='grey')


def pdf_file_location():
    Tk().withdraw()
    filename = askopenfilename()
    file_path_pdf_entry.insert(0, filename)


def docx_folder_location():
    Tk().withdraw()
    folder_selected = filedialog.askdirectory() + "/" + 'New_DOCX.docx'
    file_path_docx_entry.insert(0, folder_selected)


def convert_button_function():
    cv = Converter(file_path_pdf_entry.get())
    cv.convert(file_path_docx_entry.get(), start=0, end=None)
    cv.close()


"""Labels"""
label1 = Label(text='PDF to Docx', font='Impact 40', bg='white', fg='#1E90FF')
label1.grid(column=2, row=1, sticky='n', pady=50, padx=120)


"""Entries"""

# PDF file entry
file_path_pdf_entry = Entry(border=5)
file_path_pdf_entry.grid(ipadx=90, ipady=4, padx=20, sticky='nw', column=2, pady=1, row=2)

# Docx file entry
file_path_docx_entry = Entry(border=5)
file_path_docx_entry.grid(column=2, ipady=4, ipadx=90, padx=20, sticky='nw', pady=70, row=3)

"""Buttons"""

# Convert Button
converter_button = Button(text='Convert', bg='#1E90FF', fg='white', font='impact 20', border=5,
                          command=convert_button_function)
converter_button.grid(padx=175, sticky='s', ipady=5, ipadx=10, column=2, row=4)

select_pdf_file = Button(text='Select PDF file', fg='black', bg='white', border=3,
                         command=pdf_file_location)
select_pdf_file.grid(column=2, sticky='ne', row=2, pady=6, padx=60)

select_new_file_folder = Button(text='Select new file folder', fg='black', bg='white', border=3,
                                command=docx_folder_location)
select_new_file_folder.grid(column=2, sticky='ne', row=3, pady=74, padx=26)


root.mainloop()

とても有難い。 それは良い考えです-> GUIをバックログに入れます。

バッチモードでユーザー定義フォルダーの下にあるマルチPDFファイルを変換するなど、もう少し改善したいですか。 その後、PRを提出してください。そうすれば、あなたの作品をこのライブラリにマージして、より多くの人々に利益をもたらすことができます。

バッチモードとは、バッチファイルとして保存して実行するという意味ですか? 私はそれをWindowsexeで行うことができます。 あなたは何を好むか?

ユーザーインターフェイスを使用すると、一度に1つのファイルを変換できます。 しかし、多くのpdfファイルを変換する必要があるかもしれません。そのような場合、すべてのpdfファイルをフォルダーに入れ、そのフォルダーを選択して、一度にすべてを変換する方が便利です。

このページは役に立ちましたか?
0 / 5 - 0 評価