faker_file.providers.pdf_file.generators package

Submodules

faker_file.providers.pdf_file.generators.pdfkit_generator module

class faker_file.providers.pdf_file.generators.pdfkit_generator.PdfkitPdfGenerator(**kwargs)[source]

Bases: BasePdfGenerator

Pdfkit PDF generator.

Usage example:

from faker import Faker
from faker_file.providers.pdf_file import PdfFileProvider
from faker_file.providers.pdf_file.generators.pdfkit_generator import (
    PdfkitPdfGenerator
)

FAKER = Faker()
FAKER.add_provider(PdfFileProvider)

file = FAKER.pdf_file(pdf_generator_cls=PdfkitPdfGenerator)

Using DynamicTemplate:

from faker_file.base import DynamicTemplate
from faker_file.contrib.pdf_file.pdfkit_snippets import (
    add_h1_heading,
    add_h2_heading,
    add_h3_heading,
    add_h4_heading,
    add_h5_heading,
    add_h6_heading,
    add_heading,
    add_page_break,
    add_paragraph,
    add_picture,
    add_table,
)

# Create a file with lots of elements
file = FAKER.pdf_file(
    pdf_generator_cls=PdfkitPdfGenerator,
    content=DynamicTemplate(
        [
            (add_h1_heading, {}),
            (add_paragraph, {}),
            (add_h2_heading, {}),
            (add_h3_heading, {}),
            (add_h4_heading, {}),
            (add_h5_heading, {}),
            (add_h6_heading, {}),
            (add_paragraph, {}),
            (add_picture, {}),
            (add_page_break, {}),
            (add_h6_heading, {}),
            (add_table, {}),
            (add_paragraph, {}),
        ]
    )
)
encoding: str = 'utf-8'
generate(content: str | DynamicTemplate, data: Dict[str, Any], provider: Faker | Generator | Provider, **kwargs) bytes[source]

Generate PDF.

handle_kwargs(**kwargs) None[source]

Handle kwargs.

faker_file.providers.pdf_file.generators.reportlab_generator module

Module contents