{"id":1548,"url":"https://github.com/nRewik/SimplePDF","last_synced_at":"2025-08-06T14:31:22.941Z","repository":{"id":62455463,"uuid":"49810969","full_name":"nRewik/SimplePDF","owner":"nRewik","description":"Create a simple PDF effortlessly. :smile:","archived":false,"fork":false,"pushed_at":"2023-02-21T18:08:59.000Z","size":452,"stargazers_count":253,"open_issues_count":26,"forks_count":53,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-12-01T03:49:30.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nRewik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-01-17T09:33:18.000Z","updated_at":"2024-07-31T08:56:38.000Z","dependencies_parsed_at":"2024-01-02T21:01:52.596Z","dependency_job_id":"eace9aff-68b3-4615-a3f4-b41e351c0feb","html_url":"https://github.com/nRewik/SimplePDF","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nRewik%2FSimplePDF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nRewik%2FSimplePDF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nRewik%2FSimplePDF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nRewik%2FSimplePDF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nRewik","download_url":"https://codeload.github.com/nRewik/SimplePDF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905547,"owners_count":17989781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:49.542Z","updated_at":"2024-12-09T14:31:16.674Z","avatar_url":"https://github.com/nRewik.png","language":"Swift","funding_links":[],"categories":["Media","Libs","PDF [🔝](#readme)"],"sub_categories":["PDF","Other free courses","Utility"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./Assets/simple_pdf_logo.png\" alt=\"Simple PDF\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"https://img.shields.io/badge/platform-iOS%208.0%2B-blue.svg?style=flat-square\" alt=\"Platform: iOS 8.0+\" /\u003e\n    \u003ca href=\"https://developer.apple.com/swift\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/language-Swift%204-f48041.svg?style=flat-square\" alt=\"Language: Swift 4\" /\u003e\n    \u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/cocoapods/v/SimplePDF.svg?style=flat-square\" alt=\"Cocoapods\" /\u003e\n\u003c/p\u003e\n\n\nSimplePDF is a wrapper of UIGraphics PDF context written in Swift.\n\nYou can:\n- [x] add texts, images, spaces and lines, table\n- [x] set up page layout, adjust content alignment\n- [x] generate PDF data/file.\n\nIn summary, you can create a simple PDF effortlessly. :smile:\n\n## Example\n\n```swift\nlet A4paperSize = CGSize(width: 595, height: 842)\nlet pdf = SimplePDF(pageSize: A4paperSize)\n\npdf.addText(\"Hello World!\")\n// or\n// pdf.addText(\"Hello World!\", font: myFont, textColor: myTextColor)\n\npdf.addImage( anImage )\n\nlet dataArray = [[\"Test1\", \"Test2\"],[\"Test3\", \"Test4\"]]\npdf.addTable(rowCount: 2, columnCount: 2, rowHeight: 20.0, columnWidth: 30.0, tableLineWidth: 1.0, font: UIFont.systemFontOfSize(5.0), dataArray: dataArray)\n\nlet pdfData = pdf.generatePDFdata()\n\n// save as a local file\ntry? pdfData.writeToFile(path, options: .DataWritingAtomic)\n```\n\nSee the result [example.pdf](Assets/example.pdf), which is generated from [ExampleCode.swift](ExampleCode.swift).\n\n## Installation\n\nvia [Cocoapods](https://cocoapods.org)\n\n```ruby\nuse_frameworks!\npod 'SimplePDF'\n```\n\n## Usage\n\n```swift\nimport SimplePDF\n```\n\n### Page Setup\n\n![page setup](Assets/page_setup.png)\n\n```swift\nlet A4paperSize = CGSize(width: 595, height: 842)\nlet pdf = SimplePDF(pageSize: A4paperSize, pageMargin: 20.0)\n// or define all margins extra\nlet pdf = SimplePDF(pageSize: A4paperSize, pageMarginLeft: 35, pageMarginTop: 50, pageMarginBottom: 40, pageMarginRight: 35)\n```\n\n### Write Something\n\n```swift\npdf.addText( \"some text\" )\npdf.addImage( UIImage )\npdf.addAttributedText( NSAttributedString )\npdf.addLineSeparator(height: 30) // or pdf.addLineSeparator() default height is 1.0\npdf.addLineSpace(20)\n```\n\n### Layout\nYou can layout horizontally and vertically\n```swift\n// Start a horizonal arrangement\npdf.beginHorizontalArrangement()\n// Add space from the left\npdf.addHorizontalSpace(60)            \n\n// now add your text, table, image, ...\n\n// finishe the horizontal arrangement so you can continue vertically\npdf.endHorizontalArrangement()\n\n// adds a vertical space\npdf.addVerticalSpace(70)\n```\n\n### Table Definitions\nDefine the layout of tables with definitions\n```swift\nlet tableDef = TableDefinition(alignments: [.left, .left],\n                               columnWidths: [100, 300],\n                               fonts: [UIFont.systemFont(ofSize: 20),\n                                       UIFont.systemFont(ofSize: 16)],\n                               textColors: [UIColor.black,\n                                            UIColor.blue])\n         \nlet data = [] // my data\n         \npdf.addTable(data.count, \n             columnCount: 2, \n             rowHeight: 25, \n             tableLineWidth: 0, // this is taken from the definition\n             tableDefinition: tableDef, \n             dataArray: data)\n```\n\n### Utilities\n\n```swift\npdf.beginNewPage() // Begin a new page\n```\n\nThese following commands will affect everything you write after you call.\n\n```swift\npdf.setContentAlignment(.Center) // .Left, .Center, .Right\n```\n\n### Generate PDF data\n\n```swift\nlet pdfData = pdf.generatePDFdata()\n\n// write to file\ntry? pdfData.writeToFile(path, options: .DataWritingAtomic)\n\n// or upload to Internet\n// For example, Alamofire.upload(...)\n```\n\n## License\nSimplePDF is available under the [MIT License](LICENSE).\n\n## Authors\nNutchaphon Rewik\n\n[![my twitter][1.1]][1]\n\n[1.1]: https://img.shields.io/badge/Twitter-@nRewik-blue.svg?style=flat-square\n[1]: https://www.twitter.com/nRewik\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnRewik%2FSimplePDF","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FnRewik%2FSimplePDF","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnRewik%2FSimplePDF/lists"}