semvec/pypi-packages huggingface dataset:
pdfsquash 0.0.3
Tool(s) for placing multiple PDF pages on a sheet for printin
License: MIT
Keywords: pdf

# pdfsquash

Tool(s) to transform PDFs for printing multiple pages on a sheet.

## Usage
```bash
pdfsquash -o <output-pdf> <input-pdf-1> <input-pdf-2> ...
```

For more options, see
```bash
pdfsquash -h
```

## Examples
Following PDF files are used as sample inputs:
* [1.pdf](samples/1.pdf)
* [2.pdf](samples/2.pdf)
* [3.pdf](samples/2.pdf)
* [4.pdf](samples/2.pdf)

## Default options
```bash
pdfsquash -o samples/1-4-default.pdf \
    samples/1.pdf samples/2.pdf samples/3.pdf samples/4.pdf
```
Here is how result will look: [1-4-default.pdf](samples/1-4-default.pdf)

![image](https://github.com/pgmmpk/pdfsquash/assets/569458/28bb98eb-813d-48b8-ab1e-3c6c7c9a4358)

## Change spacing between minipages
Default spacing is 0. To chang it to 10pt use this command:
```bash
pdfsquash -o samples/1-4-spacing.pdf \
    -s 10 \
    samples/1.pdf samples/2.pdf samples/3.pdf samples/4.pdf
```
Here is how result will look: [1-4-default.pdf](samples/1-4-spacing.pdf)

![image](https://github.com/pgmmpk/pdfsquash/assets/569458/ca524df7-0dc2-4000-b123-6317e38d8437)

## Change page margin
Default page margin is 20pt. To change it to 0pt use this command:
```bash
pdfsquash -o samples/1-4-margin.pdf \
    -m 0 \
    samples/1.pdf samples/2.pdf samples/3.pdf samples/4.pdf
```
Here is how result will look: [1-4-default.pdf](samples/1-4-margin.pdf)

![image](https://github.com/pgmmpk/pdfsquash/assets/569458/e7a10859-c04d-43a0-9b7a-dba1d033507c)

## Keep aspect ratio of the original
By default, original mini-pages will be shrinked and stretched to fit the target sheet location,
**independently in X and Y direction***.
If you want to preserve original aspect, do this:
```bash
pdfsquash -o samples/1-4-keep-aspect.pdf \
    -m 0 \
    -k \
    samples/1.pdf samples/2.pdf samples/3.pdf samples/4.pdf
```
Here is how result will look: [1-4-keep-aspect.pdf](samples/1-4-keep-aspect.pdf)

![image](https://github.com/pgmmpk/pdfsquash/assets/569458/13d938db-420e-48ff-b2b5-048f7a05df5f)

## TODO
1. Support other paper sizes (currently hardcoded to US Letter)
2. Support other number of mini-pages per paper sheet (2, 6, 8). Currently do only 4 mini-pages per paper sheet.
3. Support page re-ordering. Currently mini-pages are placed in a fixed order (left-to-right, top-to-bottom).

## License
MIT
bike 0.3.6
A lightweight model validator for modern projects.
License: MIT
Requires Python: >=3.10,<4.0

# bike
A lightweight model validator for modern projects.

## Instalation
```shell
pip install bike
```

## First Pedals

Lets define a simple model to represent a person.

```python hl_lines="1"
import bike


@bike.model()
class Person:
    name: str
    height: float
    weight: float
    
...

p1 = Person(
    name='Patrick Love', 
    height=75, 
    weight=180
)
```
A Person instance can be created passing the attributes.
Also can be instantiated by a dict.
```python
...

data = {
    'name': 'Patrick Love',
    'height': 75,
    'weight': 180
}

p1 = Person(**data)
```

## Nested Models

We can create and mananger more complex structs by nested
models. It's simply by using a model as field type of other model.

```python
# implement.py
import bike


@bike.model()
class Address:
    address_1: str
    address_2: str = ''
    city: str
    state: str
    code: str
    country: str

    
@bike.model()
class Phone:
    country_code: str
    local_code: str
    number: str

    
@bike.model()
class Person:
    name: str
    address: Address
    phones: list[Phone]
    
...
    
payload = {
    'name': 'Aline Mark',
    'address': {
        'address_1': '239 W 45th St',
        'address_2': '',
        'city': 'New York',
        'state': 'NY',
        'code': '10036',
        'country': 'EUA'
    },
    'phones': [
        {
            'country_code': '+1',
            'local_code': '010',
            'number': '134354325'
        },
        {
            'country_code': '+2',
            'local_code': '011',
            'number': '134565436'
        }
    ]
}
p1 = Person(**payload)
print(p1.phones[0].country_code)
# +1
print(p1.phones[1].local_code)
# 011
print(p1.address.state)
# NY
```

## Parsing to Json and Dict

We can parse data to dict or json by using
.dict() or json() methods respectively.

```python
import bike


@bike.model()
class Make:
    name: str
    country: str

    
@bike.model()
class Car:
    name: str
    make: Make
    

m1 = Make(name='Nissan', country='JP')
c1 = Car(name='Leaf', make=m1)

c1_dict = c1.dict()
print(c1_dict['make']['country'])
# JP

c1_json = c1.json()
print(c1_json)
# {"name": "Leaf", "make": {"name": "Nissan", "country": "JP"}}
```

## Validating Fields

Fields can be validated adding the validator annotation.

```python
import bike


@bike.model()
class Character:
    name: str
    health: float = 1.0

    @bike.validator('name')
    def name_validator(cls, val):
        return val.title()
    
    @bike.validator('health')
    def health_validator(cls, val):
        if val < 0: 
            return 0.0
        elif val > 1:
            return 1.0
        return val
    
    
c1 = Character(name='ninki walker', health=2.0)
print(c1.name)
# Ninki Walker
print(c1.health)
# 1.0
```