pdftables / python-pdftables-api

Python library to interact with https://pdftables.com API
https://pdftables.com/api
BSD 3-Clause "New" or "Revised" License
85 stars 33 forks source link

How to save file or give option to download on server #3

Closed raj15feb closed 8 years ago

raj15feb commented 8 years ago

Hi, I'm using this feature to convert pdf into xlsx format. After conversion how to use option to save file on desired place. Means after conversion it will ask to save file on desired place.

Thanks..

StevenMaude commented 8 years ago

It's possible to specify a full path to the input and output. For example, from the example in the documentation:

import pdftables_api

c = pdftables_api.Client('my-api-key')
c.xlsx('/home/my_path/input.pdf', '/home/another_path/output.xlsx')

That's if you're using OS X or Linux; if on Windows, your paths will be in the form of:

'C:\\some_directory\\some_pdf_file.pdf'

If you wanted to prompt a user to select a file location, you would have to specify the paths as variables, e.g.

c.xlsx(input_file_path, output_file_path)

and then you'd have to write code that prompts the user to set the values of input_file_path and output_file_path. You could do this via a file dialog, for example.

Please reopen if this doesn't answer your question.

raj15feb commented 8 years ago

Hi, Thanks for the reply. But on server we don't know the actual path. And my server accessed on multiple system or user. So how to save converted file.

Thanks. On 27-Sep-2016 2:44 AM, "Steven Maude" notifications@github.com wrote:

It's possible to specify a full path to the input and output. For example, from the example in the documentation:

import pdftables_api

c = pdftables_api.Client('my-api-key') c.xlsx('/home/my_path/input.pdf', '/home/another_path/output.xlsx')

That's if you're using OS X or Linux; if on Windows, your paths will be in the form of:

'C:\some_directory\some_pdf_file.pdf'

If you wanted to prompt a user to select a file location, you would have to specify the paths as variables, e.g.

c.xlsx(input_file_path, output_file_path)

and then you'd have to write code that prompts the user to set the values of input_file_path and output_file_path. You could do this via a file dialog, for example.

Please reopen if this doesn't answer your question.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pdftables/python-pdftables-api/issues/3#issuecomment-249699650, or mute the thread https://github.com/notifications/unsubscribe-auth/APVQNEHjhMwZK1hksPcWGyuigIskYYEKks5quDXLgaJpZM4KGuyT .

pwaller commented 8 years ago

@raj15feb I don't quite understand your question. Are you asking how to prompt the user where to save the file with a "save file dialog"? Or something else?

raj15feb commented 8 years ago

Hi, Yes, after conversion pdf into xlsx. user able to save file on his location or able to download from server. My code is: @api.multi def convert_report(self): api_key = self.pool.get("ir.config_parameter").get_param(self._cr, self._uid, "pdf_to_excel_report.pdftable_api", default=False, context=self._context) attachment_o = self.pool.get('report').get_pdf(self._cr, self._uid, self._ids, 'school_ordersheet.report_school_ordersheet_order_clothing', html=None, data=None, context=None) files = {'f': ('example.pdf', attachment_o)} response = requests.post(api_key, files=files) response.raise_for_status() with open("/home/galaxy/Desktop/order_clothing.xlsx", "wb") as f: f.write(response.content) From attachment_o i'm getting PDF file, in api_key i have pdftables api. So after conversion i want to save this file on user desired location. in current I'm saving this file at /home/galaxy/Desktop/order_clothing.xlsx this location, but it's static. I want to save converted file in user's location.

Thanks.

On Tue, Sep 27, 2016 at 4:05 PM, Peter Waller notifications@github.com wrote:

@raj15feb https://github.com/raj15feb I don't quite understand your question. Are you asking how to prompt the user where to save the file with a "save file dialog"? Or something else?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pdftables/python-pdftables-api/issues/3#issuecomment-249828305, or mute the thread https://github.com/notifications/unsubscribe-auth/APVQNPjVXRoZEiTZciPcV_t_4IkQ0Ij7ks5quPFUgaJpZM4KGuyT .

Rajeev kumar

pwaller commented 8 years ago

You want to search the internet for how to do this.

Something like this might work:

http://stackoverflow.com/questions/9319317/quick-and-easy-file-dialog-in-python

Good luck!

raj15feb commented 8 years ago

Hi, Thanks for reference. One more thing How to save converted file(xlsx file) in binary field. I have created a binary field.

Thanks.

On Tue, Sep 27, 2016 at 4:35 PM, Peter Waller notifications@github.com wrote:

You want to search the internet for how to do this.

Something like this might work:

http://stackoverflow.com/questions/9319317/quick-and- easy-file-dialog-in-python

Good luck!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pdftables/python-pdftables-api/issues/3#issuecomment-249834392, or mute the thread https://github.com/notifications/unsubscribe-auth/APVQNAhOyJFcB6MgTJsLfYIAACh5UC-nks5quPiJgaJpZM4KGuyT .

Rajeev kumar