Python Forum
Need help to open PDF file and Export to text file
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help to open PDF file and Export to text file
#1
Hi All,

I need to open PDF file with Adobe Reader and save to text file using sendkeys:
- File : ALT+F
- Save to Others : H
- Text : X

This is my code to open the file and sendkeys:

import win32com.client
import os
from sys import argv

shell = win32com.client.Dispatch("WScript.Shell")

filename = "C:\RATNA\temp\TU1-2.pdf"

os.chdir('C:\\RATNA\\temp')

os.system('"C:\\Program Files (x86)\\Adobe\\Reader 11.0\\Reader\\AcroRd32.exe" TU1-2.pdf' )

shell.AppActivate('Acrobat.exe')

shell.SendKeys("%{f}",0)
shell.SendKeys("H", 0)
shell.SendKeys("X", 0)

The problem with this code is the sendkeys will be triggered only after I closed the PDF file.

Thank You
Reply


Messages In This Thread
Need help to open PDF file and Export to text file - by ratna_ain - Oct-09-2017, 01:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 1,339 Apr-24-2024, 05:47 AM
Last Post: Bronjer
  very newbie problem on text file zapad 2 361 Apr-12-2024, 06:50 PM
Last Post: zapad
  Open/save file on Android frohr 0 413 Jan-24-2024, 06:28 PM
Last Post: frohr
  file open "file not found error" shanoger 8 1,406 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Replace a text/word in docx file using Python Devan 4 4,078 Oct-17-2023, 06:03 PM
Last Post: Devan
  Need to replace a string with a file (HTML file) tester_V 1 853 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  How can i combine these two functions so i only open the file once? cubangt 4 972 Aug-14-2023, 05:04 PM
Last Post: snippsat
  How can I change the uuid name of a file to his original file? MaddoxMB 2 1,059 Jul-17-2023, 10:15 PM
Last Post: Pedroski55
  save values permanently in python (perhaps not in a text file)? flash77 8 1,363 Jul-07-2023, 05:44 PM
Last Post: flash77
  Start print a text after open an async task via button Nietzsche 0 766 May-15-2023, 06:52 AM
Last Post: Nietzsche

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020