Split a document into parts Aspose provides a powerful API to split Word documents. It’s a common document automation task when you need to break a large document into a number of smaller ones to handle them separately.
For example, you must have been in a situation when you have a massive DOCX file, requiring urgent team work. In this case, it is pretty necessary to divide a Word document into sub-documents to speed up the collaborative workflow.
Task to split a DOCX document by hand with manual copying and pasting may be a long, labor-intensive, sub-optimal approach. Instead, you can improve your efficiency dramatically with this API by breaking Word document into files, while specifying operation parameters as you need.
Using this API you can easily split a DOC , DOT , DOCX , DOTX , RTF , ODT , OTT , TXT document and save the results to DOC , DOCX , PDF , ODT , RTF , HTML , JPEG , PNG and many other file formats.
Usage examples with cURL and Postman
You can carry out REST API interactions using cURL
and Postman
. Please read these instructions to receive a personal JWT_TOKEN
for authorization.
cURL Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v "https://api.aspose.cloud/v4.0/words/online/put/split?format=text&destFileName=SplitDocument.text&from=1&to=2" \
-X PUT \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer ####################" \
-F Document="@Sample.docx"
To get a JWT token use this instruction
Postman Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{
"info": {
"name": "SplitDocumentOnline",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "clientSecret",
"value": "{{CLIENT_SECRET}}",
"type": "string"
},
{
"key": "clientId",
"value": "{{CLIENT_ID}}",
"type": "string"
},
{
"key": "addTokenTo",
"value": "header",
"type": "string"
},
{
"key": "client_authentication",
"value": "body",
"type": "string"
},
{
"key": "accessTokenUrl",
"value": "https://api.aspose.cloud/connect/token",
"type": "string"
},
{
"key": "grant_type",
"value": "client_credentials",
"type": "string"
},
{
"key": "tokenName",
"value": "Access Token",
"type": "string"
}
]
},
"item": [
{
"name": "splitRequest",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "PUT",
"header": [
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "Document",
"type": "file",
"src": "Sample.docx"
}
]
},
"url": {
"raw": "https://api.aspose.cloud/v4.0/words/online/put/split?format=text&destFileName=SplitDocument.text&from=1&to=2",
"protocol": "https",
"host": [
"api",
"aspose",
"cloud"
],
"path": [
"v4.0",
"words",
"online",
"put",
"split"
],
"query": [
{
"key": "Format",
"value": "text",
"description": ""
},
{
"key": "DestFileName",
"value": "SplitDocument.text",
"description": ""
},
{
"key": "From",
"value": "1",
"description": ""
},
{
"key": "To",
"value": "2",
"description": ""
}
]
}
},
"response": []
}
],
"variable": [
]
}
To get a JWT token use this instruction
Server Response
Copy {
"SplitResult" : {
"SourceDocument" : {
"Href" : "test_doc.docx" ,
"Rel" : "self"
},
"Pages" : [
{
"Href" : "test_doc_page2.pdf" ,
"Rel" : "page"
},
{
"Href" : "test_doc_page3.pdf" ,
"Rel" : "page"
}
]
}
}
Aspose.Words Cloud SDK Family
Using SDK is the best way to speed up the development. Please go to the GitHub repository to explore a wide family of our Cloud SDKs. These powerful libraries take care of all low-level programming details and let you focus on your primary tasks.
Usage examples in Python, Java, C#, etc.
The following code samples show how to interact with the REST API using almost any mainstream programming language.
You can find a lot of other examples in Python , Java , C# , JavaScript , PHP , C++ , Golang , Ruby , Swift , Dart on GitHub. All codes are thoroughly tested and ready for production use.
Split DOCX to PDFs
The following code examples demonstrate how to split all pages in a Word document.
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os
import asposewordscloud
import asposewordscloud.models.requests
from asposewordscloud.rest import ApiException
from shutil import copyfile
words_api = WordsApi(client_id = '####-####-####-####-####', client_secret = '##################')
request_document = open('Sample.docx', 'rb')
split_request = asposewordscloud.models.requests.SplitDocumentOnlineRequest(document=request_document, format='text', dest_file_name='SplitDocument.text', _from=1, to=2)
words_api.split_document_online(split_request)
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.aspose.words.cloud.*;
import com.aspose.words.cloud.api.*;
import com.aspose.words.cloud.model.*;
import com.aspose.words.cloud.model.requests.*;
import com.aspose.words.cloud.model.responses.*;
import java.nio.file.Files;
import java.nio.file.Paths;
ApiClient apiClient = new ApiClient(/*clientId*/ "####-####-####-####-####", /*clientSecret*/ "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);
byte[] requestDocument = Files.readAllBytes(Paths.get("Sample.docx").toAbsolutePath());
SplitDocumentOnlineRequest splitRequest = new SplitDocumentOnlineRequest(requestDocument, "text", null, null, null, "SplitDocument.text", 1, 2, null, null);
wordsApi.splitDocumentOnline(splitRequest);
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "fs";
const clientId = "####-####-####-####-####";
const secret = "##################";
const wordsApi = new WordsApi(clientId, secret);
const requestDocument = fs.createReadStream("Sample.docx");
const splitRequest = new model.SplitDocumentOnlineRequest({
document: requestDocument,
format: "text",
destFileName: "SplitDocument.text",
from: 1,
to: 2
});
wordsApi.splitDocumentOnline(splitRequest)
.then((splitRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of splitRequest: ", splitRequestResult);
});
C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Aspose.Words.Cloud.Sdk;
using Aspose.Words.Cloud.Sdk.Model;
using Aspose.Words.Cloud.Sdk.Model.Requests;
var config = new Configuration { ClientId = "####-####-####-####-####", ClientSecret = "##################" };
var wordsApi = new WordsApi(config);
using var requestDocument = File.OpenRead("Sample.docx");
var splitRequest = new SplitDocumentOnlineRequest(requestDocument, "text", destFileName: "SplitDocument.text", from: 1, to: 2);
await wordsApi.SplitDocumentOnline(splitRequest);
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php
use Aspose\Words\WordsApi;
use Aspose\Words\Model\Requests\{SplitDocumentOnlineRequest};
$clientId = '####-####-####-####-####';
$secret = '##################';
$wordsApi = new WordsApi($clientId, $secret);
$requestDocument = "Sample.docx";
$splitRequest = new SplitDocumentOnlineRequest(
$requestDocument, "text", NULL, NULL, NULL, "SplitDocument.text", 1, 2, NULL, NULL);
$wordsApi->splitDocumentOnline($splitRequest);
C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "aspose_words_cloud.h"
using namespace aspose::words::cloud;
auto config = std::make_shared<ApiConfiguration>(/*clientId*/ L"####-####-####-####-####", /*clientSecret*/ L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);
auto requestDocument = std::shared_ptr<std::istream>(new std::ifstream(std::filesystem::path(L"Sample.docx"), std::istream::binary));
std::shared_ptr<requests::SplitDocumentOnlineRequest> splitRequest(
new requests::SplitDocumentOnlineRequest(
requestDocument, std::make_shared<std::wstring>(L"text"), std::make_shared<std::wstring>(L"SplitDocument.text"), std::make_shared<int32_t>(1), std::make_shared<int32_t>(2)));
wordsApi->splitDocumentOnline(splitRequest);
Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{
"ClientId" : " ####-####-####-####-####" ,
"ClientSecret" : " ##################" ,
"BaseUrl" : " https://api.aspose.cloud"
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models")
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("Sample.docx")
splitRequestOptions := map[string]interface{}{"destFileName": "SplitDocument.text",
"from": int32(1),
"to": int32(2),}
splitRequest := &models.SplitDocumentOnlineRequest{
Document: requestDocument,
Format: ToStringPointer("text"),
Optionals: splitRequestOptions,
}
_, _, _ = wordsApi.SplitDocumentOnline(ctx, splitRequest)
Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
request_document = File.open('Sample.docx')
split_request = SplitDocumentOnlineRequest.new(document: request_document, format: 'text', dest_file_name: 'SplitDocument.text', from: 1, to: 2)
@words_api.split_document_online(split_request)
Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsposeWordsCloud
let config = Configuration(clientId: "####-####-####-####-####", clientSecret: "##################");
let api = try WordsAPI(configuration: config);
let requestDocument = InputStream(url: URL(string: "Sample.docx"))!;
let splitRequest = SplitDocumentOnlineRequest(document: requestDocument, format: "text", destFileName: "SplitDocument.text", from: 1, to: 2);
_ = try api.splitDocumentOnline(request: splitRequest);
Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io';
import 'package:aspose_words_cloud/aspose_words_cloud.dart';
final clientId = "####-####-####-####-####";
final clientSecret = "##################";
final config = Configuration(clientId, clientSecret);
final wordsApi = WordsApi(config);
final requestDocument = (await File('Sample.docx').readAsBytes()).buffer.asByteData();
final splitRequest = SplitDocumentOnlineRequest(requestDocument, 'text', destFileName: 'SplitDocument.text', from: 1, to: 2);
await wordsApi.splitDocumentOnline(splitRequest);
Split specific pages to PDFs
The following code examples demonstrate how to split specific pages of a Word document.
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os
import asposewordscloud
import asposewordscloud.models.requests
from asposewordscloud.rest import ApiException
from shutil import copyfile
words_api = WordsApi(client_id = '####-####-####-####-####', client_secret = '##################')
request_document = open('Sample.docx', 'rb')
split_request = asposewordscloud.models.requests.SplitDocumentOnlineRequest(document=request_document, format='pdf', _from=1, to=2)
words_api.split_document_online(split_request)
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.aspose.words.cloud.*;
import com.aspose.words.cloud.api.*;
import com.aspose.words.cloud.model.*;
import com.aspose.words.cloud.model.requests.*;
import com.aspose.words.cloud.model.responses.*;
import java.nio.file.Files;
import java.nio.file.Paths;
ApiClient apiClient = new ApiClient(/*clientId*/ "####-####-####-####-####", /*clientSecret*/ "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);
byte[] requestDocument = Files.readAllBytes(Paths.get("Sample.docx").toAbsolutePath());
SplitDocumentOnlineRequest splitRequest = new SplitDocumentOnlineRequest(requestDocument, "pdf", null, null, null, null, 1, 2, null, null);
wordsApi.splitDocumentOnline(splitRequest);
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "fs";
const clientId = "####-####-####-####-####";
const secret = "##################";
const wordsApi = new WordsApi(clientId, secret);
const requestDocument = fs.createReadStream("Sample.docx");
const splitRequest = new model.SplitDocumentOnlineRequest({
document: requestDocument,
format: "pdf",
from: 1,
to: 2
});
wordsApi.splitDocumentOnline(splitRequest)
.then((splitRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of splitRequest: ", splitRequestResult);
});
C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Aspose.Words.Cloud.Sdk;
using Aspose.Words.Cloud.Sdk.Model;
using Aspose.Words.Cloud.Sdk.Model.Requests;
var config = new Configuration { ClientId = "####-####-####-####-####", ClientSecret = "##################" };
var wordsApi = new WordsApi(config);
using var requestDocument = File.OpenRead("Sample.docx");
var splitRequest = new SplitDocumentOnlineRequest(requestDocument, "pdf", from: 1, to: 2);
await wordsApi.SplitDocumentOnline(splitRequest);
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php
use Aspose\Words\WordsApi;
use Aspose\Words\Model\Requests\{SplitDocumentOnlineRequest};
$clientId = '####-####-####-####-####';
$secret = '##################';
$wordsApi = new WordsApi($clientId, $secret);
$requestDocument = "Sample.docx";
$splitRequest = new SplitDocumentOnlineRequest(
$requestDocument, "pdf", NULL, NULL, NULL, NULL, 1, 2, NULL, NULL);
$wordsApi->splitDocumentOnline($splitRequest);
C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "aspose_words_cloud.h"
using namespace aspose::words::cloud;
auto config = std::make_shared<ApiConfiguration>(/*clientId*/ L"####-####-####-####-####", /*clientSecret*/ L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);
auto requestDocument = std::shared_ptr<std::istream>(new std::ifstream(std::filesystem::path(L"Sample.docx"), std::istream::binary));
std::shared_ptr<requests::SplitDocumentOnlineRequest> splitRequest(
new requests::SplitDocumentOnlineRequest(
requestDocument, std::make_shared<std::wstring>(L"pdf"), std::make_shared<int32_t>(1), std::make_shared<int32_t>(2)));
wordsApi->splitDocumentOnline(splitRequest);
Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{
"ClientId" : " ####-####-####-####-####" ,
"ClientSecret" : " ##################" ,
"BaseUrl" : " https://api.aspose.cloud"
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models")
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("Sample.docx")
splitRequestOptions := map[string]interface{}{"from": int32(1),
"to": int32(2),}
splitRequest := &models.SplitDocumentOnlineRequest{
Document: requestDocument,
Format: ToStringPointer("pdf"),
Optionals: splitRequestOptions,
}
_, _, _ = wordsApi.SplitDocumentOnline(ctx, splitRequest)
Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
request_document = File.open('Sample.docx')
split_request = SplitDocumentOnlineRequest.new(document: request_document, format: 'pdf', from: 1, to: 2)
@words_api.split_document_online(split_request)
Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsposeWordsCloud
let config = Configuration(clientId: "####-####-####-####-####", clientSecret: "##################");
let api = try WordsAPI(configuration: config);
let requestDocument = InputStream(url: URL(string: "Sample.docx"))!;
let splitRequest = SplitDocumentOnlineRequest(document: requestDocument, format: "pdf", from: 1, to: 2);
_ = try api.splitDocumentOnline(request: splitRequest);
Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io';
import 'package:aspose_words_cloud/aspose_words_cloud.dart';
final clientId = "####-####-####-####-####";
final clientSecret = "##################";
final config = Configuration(clientId, clientSecret);
final wordsApi = WordsApi(config);
final requestDocument = (await File('Sample.docx').readAsBytes()).buffer.asByteData();
final splitRequest = SplitDocumentOnlineRequest(requestDocument, 'pdf', from: 1, to: 2);
await wordsApi.splitDocumentOnline(splitRequest);
Split specific pages to any Supported Format
The following code examples demonstrate how to split a Word document to any format.
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os
import asposewordscloud
import asposewordscloud.models.requests
from asposewordscloud.rest import ApiException
from shutil import copyfile
words_api = WordsApi(client_id = '####-####-####-####-####', client_secret = '##################')
request_document = open('Sample.docx', 'rb')
split_request = asposewordscloud.models.requests.SplitDocumentOnlineRequest(document=request_document, format='png', _from=1, to=2)
words_api.split_document_online(split_request)
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.aspose.words.cloud.*;
import com.aspose.words.cloud.api.*;
import com.aspose.words.cloud.model.*;
import com.aspose.words.cloud.model.requests.*;
import com.aspose.words.cloud.model.responses.*;
import java.nio.file.Files;
import java.nio.file.Paths;
ApiClient apiClient = new ApiClient(/*clientId*/ "####-####-####-####-####", /*clientSecret*/ "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);
byte[] requestDocument = Files.readAllBytes(Paths.get("Sample.docx").toAbsolutePath());
SplitDocumentOnlineRequest splitRequest = new SplitDocumentOnlineRequest(requestDocument, "png", null, null, null, null, 1, 2, null, null);
wordsApi.splitDocumentOnline(splitRequest);
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "fs";
const clientId = "####-####-####-####-####";
const secret = "##################";
const wordsApi = new WordsApi(clientId, secret);
const requestDocument = fs.createReadStream("Sample.docx");
const splitRequest = new model.SplitDocumentOnlineRequest({
document: requestDocument,
format: "png",
from: 1,
to: 2
});
wordsApi.splitDocumentOnline(splitRequest)
.then((splitRequestResult) => {
// tslint:disable-next-line:no-console
console.log("Result of splitRequest: ", splitRequestResult);
});
C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Aspose.Words.Cloud.Sdk;
using Aspose.Words.Cloud.Sdk.Model;
using Aspose.Words.Cloud.Sdk.Model.Requests;
var config = new Configuration { ClientId = "####-####-####-####-####", ClientSecret = "##################" };
var wordsApi = new WordsApi(config);
using var requestDocument = File.OpenRead("Sample.docx");
var splitRequest = new SplitDocumentOnlineRequest(requestDocument, "png", from: 1, to: 2);
await wordsApi.SplitDocumentOnline(splitRequest);
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php
use Aspose\Words\WordsApi;
use Aspose\Words\Model\Requests\{SplitDocumentOnlineRequest};
$clientId = '####-####-####-####-####';
$secret = '##################';
$wordsApi = new WordsApi($clientId, $secret);
$requestDocument = "Sample.docx";
$splitRequest = new SplitDocumentOnlineRequest(
$requestDocument, "png", NULL, NULL, NULL, NULL, 1, 2, NULL, NULL);
$wordsApi->splitDocumentOnline($splitRequest);
C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "aspose_words_cloud.h"
using namespace aspose::words::cloud;
auto config = std::make_shared<ApiConfiguration>(/*clientId*/ L"####-####-####-####-####", /*clientSecret*/ L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);
auto requestDocument = std::shared_ptr<std::istream>(new std::ifstream(std::filesystem::path(L"Sample.docx"), std::istream::binary));
std::shared_ptr<requests::SplitDocumentOnlineRequest> splitRequest(
new requests::SplitDocumentOnlineRequest(
requestDocument, std::make_shared<std::wstring>(L"png"), std::make_shared<int32_t>(1), std::make_shared<int32_t>(2)));
wordsApi->splitDocumentOnline(splitRequest);
Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{
"ClientId" : " ####-####-####-####-####" ,
"ClientSecret" : " ##################" ,
"BaseUrl" : " https://api.aspose.cloud"
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models")
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("Sample.docx")
splitRequestOptions := map[string]interface{}{"from": int32(1),
"to": int32(2),}
splitRequest := &models.SplitDocumentOnlineRequest{
Document: requestDocument,
Format: ToStringPointer("png"),
Optionals: splitRequestOptions,
}
_, _, _ = wordsApi.SplitDocumentOnline(ctx, splitRequest)
Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
request_document = File.open('Sample.docx')
split_request = SplitDocumentOnlineRequest.new(document: request_document, format: 'png', from: 1, to: 2)
@words_api.split_document_online(split_request)
Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsposeWordsCloud
let config = Configuration(clientId: "####-####-####-####-####", clientSecret: "##################");
let api = try WordsAPI(configuration: config);
let requestDocument = InputStream(url: URL(string: "Sample.docx"))!;
let splitRequest = SplitDocumentOnlineRequest(document: requestDocument, format: "png", from: 1, to: 2);
_ = try api.splitDocumentOnline(request: splitRequest);
Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io';
import 'package:aspose_words_cloud/aspose_words_cloud.dart';
final clientId = "####-####-####-####-####";
final clientSecret = "##################";
final config = Configuration(clientId, clientSecret);
final wordsApi = WordsApi(config);
final requestDocument = (await File('Sample.docx').readAsBytes()).buffer.asByteData();
final splitRequest = SplitDocumentOnlineRequest(requestDocument, 'png', from: 1, to: 2);
await wordsApi.splitDocumentOnline(splitRequest);
See also