Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
exclude: "docs/make.bat"
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 25.12.0
rev: 26.3.1
hooks:
- id: black
args: [--target-version, py36]
Expand All @@ -28,7 +28,7 @@ repos:
- id: blacken-docs
additional_dependencies: [black==22.1.0]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.13
rev: v0.15.6
hooks:
- id: ruff
args: ['--fix']
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ maint:
python -m pip install --upgrade .
python -m pip lock --group dev --group docs .
uv pip install -r pylock.toml
git submodule update --remote

release:
python make_release.py
Expand Down
10 changes: 10 additions & 0 deletions docs/user/subcommand-cat.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ pdfly cat input.pdf 5 -o out.pdf

Note that it is `5`, because the page indices always start at 0.

### Specify a negative index

Get the last page of a PDF:

```
pdfly cat -o out.pdf input.pdf -- -1
```

`--` must be used to escape negative indices.

### Concatenate two PDFs

Just combine two PDF files so that the pages come right after each other:
Expand Down
10 changes: 5 additions & 5 deletions pdfly/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ def cat(
resolve_path=True,
),
],
output: Path = typer.Option(..., "-o", "--output"), # noqa
fn_pgrgs: list[str] | None = typer.Argument( # noqa: B008
None, help="filenames and/or page ranges"
),
verbose: bool = typer.Option(
False, help="show page ranges as they are being read"
None, allow_dash=True, help="filenames and/or page ranges"
),
output: Path = typer.Option(..., "-o", "--output"), # noqa
password: str = typer.Option(
None, help="Document's user or owner password."
),
verbose: bool = typer.Option(
False, help="show page ranges as they are being read"
),
) -> None:
pdfly.cat.main(
filename, fn_pgrgs, output=output, verbose=verbose, password=password
Expand Down
12 changes: 1 addition & 11 deletions pdfly/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def main(pdf: Path, output: OutputOptions) -> None:
v_value=reader._encryption.V,
revision=reader._encryption.R,
)
if reader.is_encrypted and reader._encryption
if reader._encryption
else None
),
pdf_file_version=reader.stream.read(8).decode("utf-8"),
Expand All @@ -66,21 +66,12 @@ def main(pdf: Path, output: OutputOptions) -> None:
)
else:
info = reader.metadata

reader.stream.seek(0)
pdf_file_version = reader.stream.read(8).decode("utf-8")
pdf_stat = pdf.stat()
pdf_id = reader.trailer.get("/ID")
meta = MetaInfo(
pages=len(reader.pages),
encryption=(
EncryptionData(
v_value=reader._encryption.V, # type: ignore
revision=reader._encryption.R, # type: ignore
)
if reader.is_encrypted and reader._encryption
else None
),
page_mode=reader.page_mode,
pdf_file_version=pdf_file_version,
page_layout=reader.page_layout,
Expand Down Expand Up @@ -188,7 +179,6 @@ def main(pdf: Path, output: OutputOptions) -> None:
os_table.add_row(
"Access Time", f"{meta.access_time:%Y-%m-%d %H:%M:%S}"
)

console = Console()
console.print(os_table)
console.print(table)
Expand Down
4 changes: 2 additions & 2 deletions pdfly/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _sign_pdf_contents(
)
pdf.sign(
key=key,
cert=cert,
cert=cert, # type: ignore
extra_certs=extra_certs,
hashalgo=hashalgo,
signing_time=sign_time,
Expand Down Expand Up @@ -135,7 +135,7 @@ def _sign_pdf_contents(
signer,
content_to_sign,
key,
cert,
cert, # type: ignore
extra_certs,
hashalgo,
sign_time,
Expand Down
2 changes: 1 addition & 1 deletion pdfly/x2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def image_to_pdf(filepath: Path) -> BytesIO:
w, h = cover.size
width, height = px_to_mm(w), px_to_mm(h)
pdf = FPDF(unit="mm")
pdf.add_page(format=(width, height))
pdf.add_page(format=(width, height)) # type: ignore
pdf.image(filepath, x=0, y=0)
return BytesIO(pdf.output())

Expand Down
Loading
Loading