django-selenium-pdfmaker


Namedjango-selenium-pdfmaker JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/Execut3/django-selenium-pdfmaker
SummaryA Light Django Application which uses selenium to convert any html page to pdf. Using this approach you can easily make pdf of HTML pages with charts, tables and having their loaded Styles.
upload_time2023-01-20 09:49:25
maintainer
docs_urlNone
authorReza Torkaman Ahmadi
requires_python
licenseGPT
keywords django selenium pdf export-pdf convert-html-to-pdf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-selenium-pdfmaker
A Light Django Application which uses selenium to convert any html page to pdf. Using this approach you can easily make pdf of HTML pages with charts, tables and having their loaded Styles.


## Install

Install easily via pip:

```
pip install django-selenium-pdfmaker
```

Then add package name `django_selenium_pdfmaker` to the INSTALLED_APPS of django.

## Usage

To use this module:

```python
from django_selenium_pdfmaker.modules import PDFMaker
pdfmaker = PDFMaker()
res = pdfmaker.get_pdf_from_html(url='https://google.com', filename='output', write=True)
```

and `res` includes:

```json
{
  "status": true,
  "raw": "pdf in binary format",
  "pdf": "ConvertedPDF instance if write flag is True.",
  "message": ""
}
```

- `status` is `true` when converting to pdf is successful, else will be `false`.
For example when url path is unreachable `status` will be `false`.
- `raw` is binary data of pdf before storing in file. Will hold data if `status == true`
- `pdf` is `ConvertedPDF` object if `status` is `true`.
- `message` will hold reason why `status` is `false`.

## Settings

```
CHROMEDRIVER_PATH
```
Override this variable to address the binary file of chromedriver of your own.

```
SELENIUM_DELAY
```
To set delay on selenium requests (default 3). it will last that amount of time crawling
requested page before closing the session and create pdf of it. 

## Installation Chrome

Be noted to use this package google-chrome in your os. To install on ubuntu use following commads:

```bash
sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add 
sudo bash -c "echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list" 
sudo apt -y update 
sudo apt -y install google-chrome-stable 
```

## Exceptions

##### 1- Message: session not created: This version of ChromeDriver only supports Chrome version 90 Current browser version is 103.0.5060.53 with binary path /usr/bin/google-chrome
If you faced a problem like this, you should address the correct chromedriver binary in your codes.
To do that download the proper chromedriver version and place in your OS. Then address it with following option in
your `settings.py` file:

```bash
CHROMEDRIVER_PATH = '/usr/bin/chromedriver'
```

Also you can use below script to automatically fix this problem:

```bash
pip install webdriver-manager
```

Then use the driver in python as follows

```python
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
```
You can find the solution [link](https://stackoverflow.com/questions/60296873/sessionnotcreatedexception-message-session-not-created-this-version-of-chrome)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Execut3/django-selenium-pdfmaker",
    "name": "django-selenium-pdfmaker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,selenium,pdf,export-pdf,convert-html-to-pdf",
    "author": "Reza Torkaman Ahmadi",
    "author_email": "execut3.binarycodes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c0/b8/2cb5b771f77f41e7c1e57a184f4aa74b778e2bc9326ecd79e700095774d7/django-selenium-pdfmaker-0.0.5.tar.gz",
    "platform": null,
    "description": "# django-selenium-pdfmaker\nA Light Django Application which uses selenium to convert any html page to pdf. Using this approach you can easily make pdf of HTML pages with charts, tables and having their loaded Styles.\n\n\n## Install\n\nInstall easily via pip:\n\n```\npip install django-selenium-pdfmaker\n```\n\nThen add package name `django_selenium_pdfmaker` to the INSTALLED_APPS of django.\n\n## Usage\n\nTo use this module:\n\n```python\nfrom django_selenium_pdfmaker.modules import PDFMaker\npdfmaker = PDFMaker()\nres = pdfmaker.get_pdf_from_html(url='https://google.com', filename='output', write=True)\n```\n\nand `res` includes:\n\n```json\n{\n  \"status\": true,\n  \"raw\": \"pdf in binary format\",\n  \"pdf\": \"ConvertedPDF instance if write flag is True.\",\n  \"message\": \"\"\n}\n```\n\n- `status` is `true` when converting to pdf is successful, else will be `false`.\nFor example when url path is unreachable `status` will be `false`.\n- `raw` is binary data of pdf before storing in file. Will hold data if `status == true`\n- `pdf` is `ConvertedPDF` object if `status` is `true`.\n- `message` will hold reason why `status` is `false`.\n\n## Settings\n\n```\nCHROMEDRIVER_PATH\n```\nOverride this variable to address the binary file of chromedriver of your own.\n\n```\nSELENIUM_DELAY\n```\nTo set delay on selenium requests (default 3). it will last that amount of time crawling\nrequested page before closing the session and create pdf of it. \n\n## Installation Chrome\n\nBe noted to use this package google-chrome in your os. To install on ubuntu use following commads:\n\n```bash\nsudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add \nsudo bash -c \"echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list\" \nsudo apt -y update \nsudo apt -y install google-chrome-stable \n```\n\n## Exceptions\n\n##### 1- Message: session not created: This version of ChromeDriver only supports Chrome version 90 Current browser version is 103.0.5060.53 with binary path /usr/bin/google-chrome\nIf you faced a problem like this, you should address the correct chromedriver binary in your codes.\nTo do that download the proper chromedriver version and place in your OS. Then address it with following option in\nyour `settings.py` file:\n\n```bash\nCHROMEDRIVER_PATH = '/usr/bin/chromedriver'\n```\n\nAlso you can use below script to automatically fix this problem:\n\n```bash\npip install webdriver-manager\n```\n\nThen use the driver in python as follows\n\n```python\nfrom selenium import webdriver\nfrom webdriver_manager.chrome import ChromeDriverManager\n\ndriver = webdriver.Chrome(ChromeDriverManager().install())\n```\nYou can find the solution [link](https://stackoverflow.com/questions/60296873/sessionnotcreatedexception-message-session-not-created-this-version-of-chrome)\n",
    "bugtrack_url": null,
    "license": "GPT",
    "summary": "A Light Django Application which uses selenium to convert any html page to pdf. Using this approach you can easily make pdf of HTML pages with charts, tables and having their loaded Styles.",
    "version": "0.0.5",
    "split_keywords": [
        "django",
        "selenium",
        "pdf",
        "export-pdf",
        "convert-html-to-pdf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2741ad4a111b767fc028363fa8808b348694a44c6646741747ce8e61a4dd0fb",
                "md5": "8455a7ef7fa0649b49daaab9038e2c7f",
                "sha256": "ab53d86d502ef29f4582131772bb22901ef195f4f7609597c9cbebf97ce79515"
            },
            "downloads": -1,
            "filename": "django_selenium_pdfmaker-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8455a7ef7fa0649b49daaab9038e2c7f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 30098,
            "upload_time": "2023-01-20T09:49:22",
            "upload_time_iso_8601": "2023-01-20T09:49:22.454324Z",
            "url": "https://files.pythonhosted.org/packages/b2/74/1ad4a111b767fc028363fa8808b348694a44c6646741747ce8e61a4dd0fb/django_selenium_pdfmaker-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c0b82cb5b771f77f41e7c1e57a184f4aa74b778e2bc9326ecd79e700095774d7",
                "md5": "598b2ac5575d1dc5899521fdc0353e0e",
                "sha256": "76883106a20a706d0e70577b6a1c754a115835f1d3b7399fdcec6b0c7fb9a75d"
            },
            "downloads": -1,
            "filename": "django-selenium-pdfmaker-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "598b2ac5575d1dc5899521fdc0353e0e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19046,
            "upload_time": "2023-01-20T09:49:25",
            "upload_time_iso_8601": "2023-01-20T09:49:25.206180Z",
            "url": "https://files.pythonhosted.org/packages/c0/b8/2cb5b771f77f41e7c1e57a184f4aa74b778e2bc9326ecd79e700095774d7/django-selenium-pdfmaker-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-20 09:49:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Execut3",
    "github_project": "django-selenium-pdfmaker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-selenium-pdfmaker"
}
        
Elapsed time: 0.04251s