Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist contains code snippets related to conversion of Word document to PDF using Aspose.Words Cloud SDK for Dart
This Gist contains code snippets related to conversion of Word document to PDF using Aspose.Words Cloud SDK for Dart
import 'package:flutter/material.dart';
import 'package:aspose_words_cloud/aspose_words_cloud.dart';
import 'dart:io';
import 'dart:typed_data';
void main() {
// call the conversion method
ConversionApp();
}
void ConversionApp()
{
// define Client ID and Client Secret details as per account
var clientId = "b1a1b925-cbd0-40c3-b7d5-075c93601243";
var clientSecret = "343ebf767f3f53537a45ced31d6be34f";
// Configure words api client
var configuration = Configuration(clientId, clientSecret);
// create an instance of WordsApi
var wordsApi = WordsApi(configuration);
// Load file from local storage
var localFileContent = (File('/Users/nayyershahbaz/Downloads/GetStyles.docx').readAsBytesSync());
var uploadRequest = UploadFileRequest(ByteData.view(localFileContent.buffer), 'fileStoredInCloud.docx');
// upload file to Cloud storage
wordsApi.uploadFile(uploadRequest);
// Create SaveOptions object
var saveOptionsData = SaveOptionsData()
// save the output format as PDF
..saveFormat = 'pdf'
// name for resultant PDF
..fileName = 'destStoredInCloud.pdf';
// create SaveAs request
var saveAsRequest = SaveAsRequest('fileStoredInCloud.docx', saveOptionsData);
// Save file as PDF format
wordsApi.saveAs(saveAsRequest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment