Swiftpack.co - aspose-html-cloud/aspose-html-cloud-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by aspose-html-cloud.
aspose-html-cloud/aspose-html-cloud-swift v22.11.1
Swift library for communicating with the Aspose.HTML Cloud API
⭐️ 0
🕓 3 weeks ago
.package(url: "https://github.com/aspose-html-cloud/aspose-html-cloud-swift.git", from: "v22.11.1")

Aspose HTML Cloud SDK

This repository contains Aspose.HTML Cloud SDK source code. This SDK allows you to work with Aspose.HTML Cloud REST APIs in your applications quickly and easily.

See API Reference for full API specification.

How to use the SDK?

The complete source code is available in this repository folder, you can either directly use it in your project.

Requirements

  • mac OS X 10.12.6
  • XCode 9.2
  • Swift 5.1 and later
  • Alamofire 4.9.1 and later

Prerequisites

To use Aspose HTML for Cloud SDK you need to register an account with Aspose Cloud and lookup/create App Key and SID at Cloud Dashboard. There is free quota available. For more details, see Aspose Cloud Pricing.

Installation & Usage

Getting Started

Before create configuration, then use HtmlAPI or StorageAPI (see tests)

Possible conversions:

  • HTML -> PDF, XPS, DOCX, MD, MHTML, JPEG, BMP, PNG, TIFF, GIF
  • EPUB -> PDF, XPS, DOCX, JPEG, BMP, PNG, TIFF, GIF
  • MD -> PDF, XPS, DOCX, HTML, MHTML, JPEG, BMP, PNG, TIFF, GIF
  • MHTML -> PDF, XPS, DOCX, JPEG, BMP, PNG, TIFF, GIF
  • SVG -> PDF, XPS, JPEG, BMP, PNG, TIFF, GIF
  • JPEG, BMP, PNG, TIFF, GIF -> SVG

Example:

import Alamofire
import Foundation
import XCTest
import AsposeHtmlCloud

static let fm = FileManager.default
let resourceDir = fm.homeDirectoryForCurrentUser.appendingPathComponent("Documents/Aspose.HTML.Cloud.SDK.Swift/Tests/AsposeHtmlCloudTests/Resources")
let resultDir = fm.homeDirectoryForCurrentUser.appendingPathComponent("Documents/Aspose.HTML.Cloud.SDK.Swift/Tests/AsposeHtmlCloudTests/TestResult")

func url(forResource fileName: String) -> URL {
	return resourceDir.appendingPathComponent(fileName)
}

func fileExist(name: String) -> Bool {
	return FileManager.default.fileExists(atPath: name)
}

ClientAPI.setConfig(
	basePath: "https://api.aspose.cloud/v4.0", 
	authPath: "https://api.aspose.cloud/connect/token", 
	apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
	appSID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", 
	debugging: true
)

let fileName = "test1.html"
let src = url(forResource: fileName).absoluteString
let format = "jpeg"

let expectation = self.expectation(description: "testConvert to \(format)")
let dst = resultDir.appendingPathComponent("LocToLocDoc.\(format)").absoluteString
HtmlAPI.convertLocalToLocal(src: src, dst: dst, options: nil) { (data, error) in

	guard error == nil else {
		XCTFail("Error get convert html to \(format)). Error=\(error!.localizedDescription)")
		return
	}
	let resultPath = data!.file!
	XCTAssertTrue(fileExist(name: resultPath))
	expectation.fulfill()
}
self.waitForExpectations(timeout: testTimeout, handler: nil)

Documentation for API Endpoints

All URIs are relative to https://api.aspose.cloud/v4.0

ConversionApi

Class Method Description
HtmlAPI convertLocalToLocal Convert a document from local disk to a local disk.
HtmlAPI convertLocalToStorage Convert a document from local disk to user's storage.
HtmlAPI convertStorageToLocal Convert a document from user's storage to local disk.
HtmlAPI convertStorageToStorage Convert a document from user's storage to user's storage.
HtmlAPI convertUrlToLocal Convert the HTML document by URL to local disk.
HtmlAPI convertUrlToStorage Convert the HTML document by URL to user's storage.
HtmlAPI convert Convert a document to the specified format.

VectorizationApi

Class Method Description
HtmlAPI vectorizeLocalToLocal Vectorize an image to the SVG format from local disk to a local disk.
HtmlAPI vectorizeLocalToStorage Vectorize an image to the SVG format from local disk to user's storage.
HtmlAPI vectorizeStorageToLocal Vectorize an image to the SVG format from user's storage to local disk.
HtmlAPI vectorizeStorageToStorage Vectorize an image to the SVG format from user's storage to user's storage.
HtmlAPI vectorize Vectorize an image to the SVG format.

Documentation For Authorization

oauth

Examples

Test uses StorageApi for upload(download) file to(from) remote storage.

Documentation for Storage API Endpoints

All URIs are relative to https://api.aspose.cloud/v4.0

Class Method Description
StorageAPI deleteFile Delete file
StorageAPI downloadFile Download file
StorageAPI uploadFile Upload file
StorageAPI createFolder Create the folder
StorageAPI deleteFolder Delete folder
StorageAPI getFilesList Get all files and folders within a folder
StorageAPI getDiscUsage Get disc usage
StorageAPI objectExists Check if file or folder exists
StorageAPI storageExists Check if storage exists

Documentation for Models

Tests contain various examples of using the Aspose.HTML and Aspose.Storage SDK.

GitHub

link
Stars: 0
Last commit: 4 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics