Metadata-Version: 2.1
Name: WebSite2PDF
Version: 0.1.1
Summary: Simple and Fast Python framework to convert HTML files or Web Site to PDF
Home-page: https://github.com/uNickz/WebSite2PDF
Download-URL: https://github.com/uNickz/WebSite2PDF/releases/latest
Author: uNickz
Author-email: unickz.dev@gmail.com
License: LGPLv3
Project-URL: Tracker, https://github.com/uNickz/WebSite2PDF/issues
Project-URL: Source, https://github.com/uNickz/WebSite2PDF
Project-URL: Documentation, https://github.com/uNickz/WebSite2PDF/blob/main/README.md
Keywords: python file html site website pdf converter convert
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

<p align = "center">
    <a href = "https://github.com/uNickz/WebSite2PDF">
        <img src = "https://raw.githubusercontent.com/uNickz/WebSite2PDF/main/.github/graphics/GitHub-Banner-WebSite2PDF.png" width = "500px" alt = "WebSite2PDF Logo">
    </a>
    <br />
    <a href="https://github.com/uNickz/WebSite2PDF/tree/main/Example">Examples</a>
    •
    <a href="https://github.com/uNickz/WebSite2PDF/blob/main/README.md">Documentation</a>
    •
    <a href="https://pypi.org/project/WebSite2PDF/">PyPi</a>
    •
    <a href="https://t.me/uNickzProjects">News</a>
    •
    <a href="https://github.com/uNickz/WebSite2PDF/discussions">Chat</a>
</p>

# WebSite2PDF
> Simple and Fast Python framework to convert HTML files or Web Site to PDF

### Installing with pip

``` bash
pip3 install WebSite2PDF
```
or
``` bash
pip3 install git+https://github.com/uNickz/WebSite2PDF
```

### Installing with python

``` bash
python3 -m pip install WebSite2PDF
```
or
``` bash
python3 -m pip install git+https://github.com/uNickz/WebSite2PDF
```

### Dependencies

 - [Selenium Chrome WebDriver](https://chromedriver.chromium.org/downloads) (If [Chrome](https://www.google.com/chrome/) is installed on the machine you won't need to install the chrome driver)

## Example

### Using a url

``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client()
with open("file_name.pdf", "wb+") as file:
    file.write(c.pdf(url))
```
or
``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client()
c.pdf(url, filename = "file_name.pdf")
```

### Using a file HTML

``` python
import WebSite2PDF

file_path = "C:\Users\uNickz\index.html"

c = WebSite2PDF.Client()
with open("file_name.pdf", "wb+") as file:
    file.write(c.pdf(f"file:///{file_path}"))
```
or
``` python
import WebSite2PDF

file_path = "C:\Users\uNickz\index.html"

c = WebSite2PDF.Client()
c.pdf(f"file:///{file_path}", filename = "file_name.pdf")
```

### Using multiple urls or files HTML

``` python
import WebSite2PDF

urls_or_path = ["https://pypi.org", "file:///C:\Users\uNickz\index.html", "https://github.com/"]

c = WebSite2PDF.Client()
c.pdf(urls_or_path, filename = ["pypi.pdf", "index.pdf", "github.pdf"])
```
or
``` python
import WebSite2PDF

urls_or_path = ["https://pypi.org", "file:///C:\Users\uNickz\index.html", "https://github.com/"]
file_name = ["pypi.pdf", "index.pdf", "github.pdf"]

c = WebSite2PDF.Client()
data = c.pdf(urls_or_path)
for name, data in zip(name, data):
    with open(name, "wb+") as file:
        file.write(data)
```

### Using a delay (in seconds) before create PDF

``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client()
c.pdf(url, filename = "file_name.pdf", delay = 3)
```

### Using global [PDF Options](https://github.com/uNickz/WebSite2PDF/blob/main/PDF%20Page%20Options.md)

``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client(
    pdfOptions = {
        "landscape" = True,
        "displayHeaderFooter": True,
        "printBackground": True,
        "preferCSSPageSize": True,
    }
)
c.pdf(url, filename = "file_name.pdf")
```

### Using specific [PDF Options](https://github.com/uNickz/WebSite2PDF/blob/main/PDF%20Page%20Options.md) for a PDF

``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client(
    pdfOptions = {
        "landscape" = True,
        "displayHeaderFooter": True,
        "printBackground": True,
        "preferCSSPageSize": True,
    }
)
c.pdf(url, filename = "file_name.pdf", pdfOptions = {
    "landscape" = False,
    "displayHeaderFooter": True,
})
```

### Using global [Selenium ChromeDriver Options](https://github.com/uNickz/WebSite2PDF/blob/main/Selenium%20ChromeDriver%20Options.md)

``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client(
    pdfOptions = {
        "landscape" = True,
        "displayHeaderFooter": True,
        "printBackground": True,
        "preferCSSPageSize": True,
    }, seleniumOptions = [
        "--no-sandbox",
        "--headless",
    ]
)
c.pdf(url, filename = "file_name.pdf")
```

### Using specific [Selenium ChromeDriver Options](https://github.com/uNickz/WebSite2PDF/blob/main/Selenium%20ChromeDriver%20Options.md) for a PDF

``` python
import WebSite2PDF

url = "https://pypi.org"

c = WebSite2PDF.Client(
    pdfOptions = {
        "landscape" = True,
        "displayHeaderFooter": True,
        "printBackground": True,
        "preferCSSPageSize": True,
    }, seleniumOptions = [
        "--no-sandbox",
        "--headless",
    ]
)
c.pdf(url, filename = "file_name.pdf", pdfOptions = {
        "landscape" = False,
        "displayHeaderFooter": True,
    }, seleniumOptions = [
        "--no-sandbox",
        "--disable-gpu",
])
```
