Skip to content

Commit

Permalink
DOC: Improve examples (#2612)
Browse files Browse the repository at this point in the history
file-size.md: simplify examples
metadata.md: add two fields
suppress-warnings.md: small wording change
  • Loading branch information
j-t-1 committed May 1, 2024
1 parent 40dc70c commit 6819f86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
16 changes: 4 additions & 12 deletions docs/user/file-size.md
Expand Up @@ -35,13 +35,9 @@ reduction (from 5.7 MB to 0.8 MB) within a real PDF.


```python
from pypdf import PdfReader, PdfWriter

reader = PdfReader("example.pdf")
writer = PdfWriter()
from pypdf import PdfWriter

for page in reader.pages:
writer.add_page(page)
writer = PdfWriter(clone_from="example.pdf")

writer.remove_images()

Expand All @@ -56,13 +52,9 @@ reduce the file size of the PDF overall. That depends on how well the reduced
quality image can be compressed.

```python
from pypdf import PdfReader, PdfWriter

reader = PdfReader("example.pdf")
writer = PdfWriter()
from pypdf import PdfWriter

for page in reader.pages:
writer.add_page(page)
writer = PdfWriter(clone_from="example.pdf")

for page in writer.pages:
for img in page.images:
Expand Down
6 changes: 4 additions & 2 deletions docs/user/metadata.md
Expand Up @@ -12,11 +12,13 @@ meta = reader.metadata
print(len(reader.pages))

# All of the following could be None!
print(meta.title)
print(meta.author)
print(meta.subject)
print(meta.creator)
print(meta.producer)
print(meta.subject)
print(meta.title)
print(meta.creation_date)
print(meta.modification_date)
```

## Writing metadata
Expand Down
4 changes: 2 additions & 2 deletions docs/user/suppress-warnings.md
Expand Up @@ -14,8 +14,8 @@ pypdf makes use of 3 mechanisms to show that something went wrong:
"warning".
* **Exceptions** are error-cases that pypdf users should explicitly handle.
In the `strict=True` mode, most log messages with the warning level will
become exceptions. This can be useful in applications where you can force to
user to fix the broken PDF.
become exceptions. This can be useful in applications where you can require
a user to fix the broken PDF.


## Exceptions
Expand Down

0 comments on commit 6819f86

Please sign in to comment.