# stbe-ge/ios-htmltopdf architecture

> Architecture diagram of the GitHub repository stbe-ge/ios-htmltopdf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stbe-ge/ios-htmltopdf
- Repository: https://github.com/stbe-ge/ios-htmltopdf

## Overview

##### Flow and Interactions

- Input → UIWebView (Content Loading)
- UIWebView → PDF Generation Engine
- Configuration Settings → PDF Generation Engine
- PDF Generation Engine → File System
- Completion → Delegate/Block Callbacks

##### Specific Elements

a) Configuration Options (Top):
- Page Size Settings (e.g., A4)
- Margin Controls

b) Callback Mechanisms (Bottom):
- Delegate Pattern
- Block-based Callbacks
- Both options with different line styles

##### Technical Details

a) Key Classes:
- NDHTMLtoPDF (Main Class)
- NDHTMLtoPDFDelegate (Protocol)

b) Important Methods:
- createPDFWithURL:pathForPDF:delegate:pageSize:margins:
- createPDFWithHTML:pathForPDF:delegate:pageSize:margins:

##### Additional Elements

- Version compatibility information

##### Notes for Clarity

- Asynchronous nature of the operations
- Relationship with iOS UIKit framework
- Where file system interactions occur
- Points where memory management is crucial

Remember to indicate that this is an iOS-specific library and show its dependencies on the iOS framework, particularly UIWebView, which is central to its operation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef input fill:#2ecc71,stroke:#27ae60,color:white
    classDef process fill:#e67e22,stroke:#d35400,color:white
    classDef output fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white

    %% Configuration Section
    subgraph Config
        PS[Page Size Settings]:::config
        MC[Margin Controls]:::config
    end

    %% Input Section
    subgraph Input
        URL[URL Input]:::input
        HTML[HTML String Input]:::input
    end

    %% Core Processing
    subgraph Processing
        CORE[NDHTMLtoPDF Core]:::core
        WV[UIWebView]:::process
        PG[PDF Generation Engine]:::process
    end

    %% Output Section
    subgraph Output
        PDF[PDF File Output]:::output
        CB[Callbacks/Delegate]:::output
    end

    %% Demo Application Components
    subgraph DemoApp
        AD[App Delegate]:::process
        VC[View Controller]:::process
        UI[UI Interface]:::process
    end

    %% Connections
    URL --> CORE
    HTML --> CORE
    PS --> CORE
    MC --> CORE
    CORE --> WV
    WV --> PG
    PG --> PDF
    PG --> CB

    %% Error Handling
    ERR[Error Handler]:::error
    CORE -.-> ERR
    ERR -.-> CB

    %% Click Events
    click CORE "https://github.com/StBe-GE/iOS-htmltopdf/blob/master/NDHTMLtoPDF.h"
    click AD "https://github.com/StBe-GE/iOS-htmltopdf/blob/master/HTMLtoPDF-Demo/HTMLtoPDF-Demo/NDAppDelegate.h"
    click VC "https://github.com/StBe-GE/iOS-htmltopdf/blob/master/HTMLtoPDF-Demo/HTMLtoPDF-Demo/NDViewController.h"
    click UI "https://github.com/StBe-GE/iOS-htmltopdf/blob/master/HTMLtoPDF-Demo/HTMLtoPDF-Demo/en.lproj"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Input Sources]:::input
        L3[Processing]:::process
        L4[Output]:::output
        L5[Configuration]:::config
        L6[Error Handling]:::error
    end
```
