Coder Social home page Coder Social logo

pylovepdf's Introduction

pylovepdf 1.3.3 - Unofficial, Unmaintained.

ilovepdf.com python API library

What it does

This library allow to manipulate pdf using the API of http://www.ilovepdf.com. See the Tools section to know what you can do.

Prerequisites

Installation (older version)

pip install pylovepdf 

Manual installation (up to date)

Download the latest release.

python setup.py install

Getting started

Example files are located inside samples/. Change file paths and the public_key parameter with the one you found in your developer account (See prerequisites). Run the files and enjoy.

Tools

Currently the following tools are available:

  • compress (Reduce the size of pdf files)
  • imagepdf (Converts an image to pdf)
  • merge (Merge multiple pdf into single file)
  • officepdf (Office document to pdf conversion)
  • pagenumber (Place numbers on pages)
  • pdfa (Converts into PDF/A)
  • pdfjpg (Converts a pdf into jpeg image)
  • protect (Add password to a pdf)
  • rotate (Rotates the pages of a file)
  • split (Split a pdf)
  • unlock (Remove the password security from the pdf, the coolest feature ever!)
  • validatepdfa (Checks the conformity of PDF/A format)
  • watermark (Adds watermark to the file)

Example Usage (compress tool)

from pylovepdf.ilovepdf import ILovePdf

ilovepdf = ILovePdf('public_key', verify_ssl=True)
task = ilovepdf.new_task('compress')
task.add_file('pdf_file')
task.set_output_folder('output_directory')
task.execute()
task.download()
task.delete_current_task()

Alternative Example Usage (compress tool)

A tool can be created directly:

from pylovepdf.tools.compress import Compress

t = Compress('public_key', verify_ssl=True)
t.add_file('pdf_file')
t.set_output_folder('output_directory')
t.execute()
t.download()
t.delete_current_task()

Documentation

Please see https://developer.ilovepdf.com/docs for up-to-date documentation.

Built With

Versioning

I use SemVer for versioning.

Authors

pylovepdf's People

Contributors

andycybersec avatar aster94 avatar markhaakman avatar mrpaperbag avatar oscar6echo avatar r0dz avatar sinistro14 avatar tgrandje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pylovepdf's Issues

Can't add an image watermark (Error: DamagedFile)

Hello,

watermark tool works perfectly with a text mark,
but it doesn't with an image:

from pylovepdf.tools.watermark import Watermark

t = Watermark(public_key, verify_ssl=True, proxies='')
t.add_file('document.pdf')
t.debug = False
t.image = 'image.png'

t.set_output_folder('./')

t.execute()
t.download()
t.delete_current_task()

the result is:

Uploading file...
File uploaded! Below file stats:
Error type: ProcessingError
message: This task can't be processed. Check why in the params.
text: ['Text cannot be blank.']
status: 400

no file to be downloaded
Task delete status: 200

AttributeError: 'Response' object has no attribute 'token'

I'm having this issue while "Watermark" tool

Traceback (most recent call last):
  File "add_watermark.py", line 16, in <module>
    task = Watermark(secret_key,
  File "C:\Users\Usuário\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pylovepdf\tools\watermark.py", line 28, in __init__
    super(Watermark, self).__init__(public_key, True, verify_ssl, proxies)
  File "C:\Users\Usuário\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pylovepdf\task.py", line 42, in __init__
    self.auth()
  File "C:\Users\Usuário\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pylovepdf\task.py", line 50, in auth
    self._set_token(response.token)
AttributeError: 'Response' object has no attribute 'token'

can we give a specific filename to the compress Class

Is it possible to give a specific filename for this example here. Its was not an issue until i found that the tz of the API server and mine is different so if do

tday = date.today().strftime("%d-%m-%Y")
        return True, f'{location}/compress_{tday}.pdf'

the date will be different.

ModuleNotFoundError: No module named 'pylovepdf.tools.pdfjpg'

task = ilovepdf.new_task('pdfjpg')

File "/home/anton/PycharmProjects/AnalyseStepInUniversity/venv/lib/python3.10/site-packages/pylovepdf/ilovepdf.py", line 101, in new_task
module_name = importlib.import_module('.tools.' + tool.lower(), package='pylovepdf')
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pylovepdf.tools.pdfjpg'

How to rotate -90° (or 270) a PDF File?

Hello!

First at all, thanks for this amazing wrapper!

Can't find the way to to rotate -90° (or 270) a PDF File,
I tried with -90, 270 and 'left', any of them modifies the position.

Error when using `new_task()` method

Using new_task() with tool names as described in https://github.com/AndyCyberSec/pylovepdf#tools gives me some errors.
Check this gist out. My output is the following:

TOOL: imagepdf
No module named 'pylovepdf.tools.imagepdf'
TOOL: officepdf
module 'pylovepdf.tools.officepdf' has no attribute 'Officepdf'
TOOL: pdfa
module 'pylovepdf.tools.pdfa' has no attribute 'Pdfa'
TOOL: pdfjpg
No module named 'pylovepdf.tools.pdfjpg'
TOOL: validatepdfa
module 'pylovepdf.tools.validatepdfa' has no attribute 'Validatepdfa'

This is a generalization of #15 and #16

⭐   BTW, thanks for your pretty work!

download will overwrite the previous files

I'm trying to loop over several files. When I download the pdfs and store them in a folder, they all get the same name (split_date_range.pdf), overwritting the previous files.

I had to overwrite the download method in task such that filename = self.output_filename.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.