Automate document generation in Swift, create print-ready reports of any complexity with Swift SDK. This Cloud-based solution is built around templates, data sources and a powerful LINQ-syntax, giving Swift developers the flexibility to fit precise technical and business requirements.
Using this Swift library, you can programmatically build highly customized reports on any operating system. Richly formatted documents like contracts, orders, invoices, shipment reports, sales proposals, inventories can be assembled on the fly as a part of your Swift software.
The importance of Document Automation and Report Generation has grown immensely over the past decades. Almost every company has a need to generate documents and deliver them to partners or customers on time. Moreover, it is usually a decisive factor in financial success. Implementing such technologies can result in significant financial savings by reducing manual data entry, human error, proofreading and paperwork. For these reasons, document automation and reporting tools are an integral part of many modern software solutions that aim to provide advanced analytical features to users.
Generally speaking, report generation is a process that combines text, data and graphics into a single entity and exports the result in a convenient visual form to the required document format, such as DOCX, PDF, ODT, HTML, PPTX, XLSX, etc.
GroupDocs Assembly for Swift is a Cloud-based solution for generating documents using templates and data sources. The document template acts as a base-frame, which, in addition to the standard content (text, tables, charts, etc.), includes special placeholder fields for inserting values from the data source. Not only individual values can be inserted, but also entire arrays of data in the form of tables and graphs.
The template also contains programming constructs - document generation rules - that control data selection and condition processing. Binding data to a document template uses LINQ-expression syntax, which allows developers to process data in a generic way, regardless of the type of data source used. In this way, our Swift Cloud SDK gives you flexibility in content generation and a powerful set of methods for data processing.
This product also supports Mail Merge functionality in case you want to create and send batches of personalized letters to customers. You just need to insert Mail Merge fields to the document template and pass it to the Cloud API together with a data source.
Regardless of the scale and type of document automation you are going to implement, there are three steps to build a report in Swift:
Designing templates is a difficult task. In addition to a clear understanding of the requirements for the final document, analytical and programming skills are required. A good template design should reflect the customer's view on a particular issue. The most effective approach is to combine tabular data and graphics in the right balance, determined by business requirements.
As mentioned above, the template structure usually contains some fixed blocks of content (text, images, logos, etc.) mixed with special programming constructs that control document assembly logic. These document generation rules are defined with a special expression syntax, which enables developers to do the following:
You can learn more about template syntax in our Developer Guide.
GroupDocs Assembly for Swift does not require any external software or third-party tools to be installed. This is a Cloud-based solution, where all programming interactions are performed over the network using the REST API.
For more information on supported I/O formats, please visit our Documentation.
All GroupDocs products are fully compliant with industry security standards: data transfer is carried out using the SSL protocol, which eliminates the possibility of information being intercepted by third parties. To connect to GroupDocs Cloud Services, you need to use personal access keys. Please refer to the Quick Start guide.
The following code example shows how to generate reports using Swift.
import GroupDocsAssemblyCloud; let assemblyApi = AssemblyApi(appSid: "####-####-####-####-####", appKey: "##################"); let fileName = "Input1.docx"; let dataFile = "Input2.docx"; let requestFileContent = InputStream(url: URL(string: fileName))!; let uploadDocumentRequest = UploadFileRequest(fileContent: requestFileContent, path: fileName); _ = try api.uploadFile(request: uploadDocumentRequest); let templateFileInfo = TemplateFileInfo(); templateFileInfo.setFilePath(filePath: fullName); let reportData = try String(contentsOf: dataFile, encoding: .utf8) let assembleOptions = AssembleOptions(); assembleOptionsData.setTemplateFileInfo(templateFileInfo: templateFileInfo); assembleOptionsData.setSaveFormat(saveFormat: "docx"); assembleOptionsData.setReportData(reportData: reportData); let request = AssembleDocumentRequest(assembleOptions: assembleOptions); let actual = try assemblyApi.assembleDocument(request: request);
You can use Swift package manager and Cocoapods dependency manager to install GroupDocs.Assembly Cloud SDK for Swift. Detailed information on installing the package is given in the "Installation and Usage" section.
As an alternative, you can clone GroupDocs.Assembly Cloud SDK for Swift source code from GitHub and use it in your project.
Please follow these Instructions to quickly get the necessary security credentials and access our REST API.
Swift 4.2 or newer
Refer to the Repository Documentation to see more details.