GithubHelp home page GithubHelp logo

nazar-41 / pdf-generator Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 11.48 MB

Swift package that converts your View to PDF file which you can save in your Documents File or share. Requires SwiftUI and iOS 13+

Swift 100.00%
swift swiftui

pdf-generator's Introduction

PDF-Generator

Native Swift Package for iOS Applications.

Setup time: 1 minute

Sample project: https://github.com/nazar-41/PDF-Generator/tree/main/Example

Setup☕ (Swift Package Manager)

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Starscream as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .Package(url: "https://github.com/nazar-41/pdf-generator", branch: .main)
]

Import the framework

First thing is to import the framework. See the Installation instructions on how to add the framework to your project.

import PDF_Generator

How to use

import SwiftUI
import PDF_Generator

struct ContentView: View {
    
    @State private var showSheet: Bool = false
    
    var body: some View {
        
        VStack{
        
            //MARK: Button that opens Share Sheet on click
            GeneratingButtonView(showSheet: $showSheet, buttonLabel: convertButton, convertingView: convertingView)
            
            ScrollView(showsIndicators: true) {
                VStack{
                    ForEach(1..<20){item in
                        Text("\(item)")
                            .frame(maxWidth: .infinity, maxHeight: 50)
                            .padding(.vertical)
                            .background(.gray.opacity(0.3))
                            .cornerRadius(20)
                            .padding(.horizontal)
                    }
                }
                .padding(.top, 50)
            }
        }
    }
    
    
    //MARK: Button View that converts given View to the PDF file
    private var convertButton: AnyView{
        let buttonView = Image(systemName: "square.and.arrow.up").font(.system(size: 50))
        
        return AnyView(buttonView)
    }
    
    
    //MARK: View that you wanna convert to PDF
    private var convertingView: AnyView{
        let view = ContentView()
        
        return AnyView(view)
    }
}

pdf-generator's People

Contributors

nazar-41 avatar

Stargazers

 avatar  avatar Eziz avatar Seydulla Narkulyyev avatar Resul Shamuhammedov avatar devler avatar

Watchers

 avatar

Forkers

liyongjiaoya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.