Read Properties of Paragraphs Introduction
This article shows how you can read the formatting properties of paragraphs from PowerPoint presentations using Aspose.Slides for Cloud API. You can use our REST API with any language: .NET, Java, PHP, Ruby, Python, С++, and much more.
API
Type
Description
Resource
/slides/{name}/slides/{slideIndex}/shapes/{shapeIndex}/paragraphs
GET
Reads properties of paragraphs in a shape.
GetParagraphs
Request Parameters
Name
Type
Location
Required
Description
name
string
path
true
The presentation file name.
slideIndex
integer
path
true
The 1-based index of the presentation slide.
shapeIndex
integer
path
true
The 1-based index of the shape.
password
string
header
false
The password to open the presentation.
folder
string
query
false
The folder where the presentation file is located.
storage
string
query
false
The storage where the presentation file is located.
subShape
string
query
false
Sub-shape path (e.g. “3”, “3/shapes/2)
In case of Amazon S3 storage folder path starts with Amazon S3 bucket name.
cURL Example
Read information about paragraphs from a shape at index 3 on a slide at index 1 in example.pptx. The storage is ‘Main’. The folder is ‘Data’.
SDK Source
The Aspose for Cloud SDKs can be downloaded from the following page: Available SDKs .
SDK Examples
Read the number of paragraphs in a shape at index 3 on a slide at index 1 in example.pptx. The storage is ‘Main’. The folder is ‘Data’.
C#
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-dotnet
using System ;
using System.IO ;
using Aspose.Slides.Cloud.Sdk ;
namespace SlidesCloudApp
{
class Test
{
static void Main ()
{
var slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
var fileName = "example.pptx" ;
var folderName = "Data" ;
var storageName = "Main" ;
var filePath = Path . Combine ( folderName , fileName );
var slideIndex = 1 ;
var shapeIndex = 3 ;
string password = null ;
try
{
using ( var fileStream = File . OpenRead ( fileName ))
{
slidesApi . UploadFile ( filePath , fileStream , storageName );
}
var paragraphs = slidesApi . GetParagraphs ( fileName , slideIndex , shapeIndex , password , folderName , storageName );
var paragraphCount = paragraphs . ParagraphLinks . Count ;
Console . WriteLine ( paragraphCount );
}
catch ( ApiException e )
{
Console . WriteLine ( e );
}
}
}
}
Java
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-java
import com.aspose.slides.api.SlidesApi ;
import java.io.File ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
public class Main {
public static void main ( String [] args ) {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
String fileName = "example.pptx" ;
String folderName = "Data" ;
String storageName = "Main" ;
String filePath = Paths . get ( folderName , fileName ). toString (). replace ( '\\' , '/' );
int slideIndex = 1 ;
int shapeIndex = 3 ;
String password = null ;
try {
byte [] fileData = Files . readAllBytes ( new File ( fileName ). toPath ());
slidesApi . uploadFile ( filePath , fileData , storageName );
Paragraphs paragraphs = slidesApi . getParagraphs ( fileName , slideIndex , shapeIndex , password , folderName , storageName , null );
int paragraphCount = paragraphs . getParagraphLinks (). size ();
System . out . println ( paragraphCount );
} catch ( Exception e ) {
e . printStackTrace ();
}
}
}
PHP
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-php
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "my_client_id" );
$configuration -> setAppKey ( "my_client_key" );
$slidesApi = new SlidesApi ( null , $configuration );
$fileName = "example.pptx" ;
$folderName = "Data" ;
$storageName = "Main" ;
$filePath = join ( "/" , array ( $folderName , $fileName ));
$slideIndex = 1 ;
$shapeIndex = 3 ;
$password = null ;
try {
$fileStream = fopen ( $fileName , 'r' );
$slidesApi -> uploadFile ( $filePath , $fileStream , $storageName );
$paragraphs = $slidesApi -> getParagraphs ( $fileName , $slideIndex , $shapeIndex , $password , $folderName , $storageName );
$paragraphCount = count ( $paragraphs -> getParagraphLinks ());
echo $paragraphCount ;
}
catch ( ApiException $e ) {
echo $e ;
}
Ruby
Python
# For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-python
import asposeslidescloud
import os
from asposeslidescloud.configuration import Configuration
from asposeslidescloud.apis.slides_api import SlidesApi
from asposeslidescloud.rest import ApiException
configuration = Configuration ()
configuration . app_sid = "my_client_id"
configuration . app_key = "my_client_key"
slidesApi = SlidesApi ( configuration )
fileName = "example.pptx"
folderName = "Data"
storageName = "Main"
filePath = os . path . join ( folderName , fileName )
slideIndex = 1
shapeIndex = 3
password = None
try :
with open ( fileName , "rb" ) as reader :
document = reader . read ()
slidesApi . upload_file ( filePath , document )
paragraphs = slidesApi . get_paragraphs ( fileName , slideIndex , shapeIndex , password , folderName , storageName )
paragraphCount = len ( paragraphs . paragraph_links )
print ( paragraphCount )
except ApiException as e :
print ( e )
Node.js
// https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-nodejs
const api = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const path = require ( "path" );
const slidesApi = new api . SlidesApi ( "my_client_id" , "my_client_key" );
const fileName = "example.pptx" ;
const folderName = "Data" ;
const storageName = "Main" ;
const filePath = path . join ( folderName , fileName );
const slideIndex = 1 ;
const shapeIndex = 3 ;
const password = null ;
const readStream = fs . createReadStream ( fileName );
slidesApi . uploadFile ( filePath , readStream , storageName ). then (() => {
slidesApi . getParagraphs ( fileName , slideIndex , shapeIndex , password , folderName , storageName ). then ( paragraphs => {
const paragraphCount = paragraphs . body . paragraphLinks . length ;
console . log ( paragraphCount );
});
});
Android
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-android
import com.aspose.slides.api.SlidesApi ;
import java.io.File ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
public class Main {
public static void main ( String [] args ) {
var slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
var fileName = "example.pptx" ;
var folderName = "Data" ;
var storageName = "Main" ;
var filePath = Paths . get ( folderName , fileName ). toString (). replace ( '\\' , '/' );
var slideIndex = 1 ;
var shapeIndex = 3 ;
String password = null ;
try {
var fileData = Files . readAllBytes ( new File ( fileName ). toPath ());
slidesApi . uploadFile ( filePath , fileData , storageName );
var paragraphs = slidesApi . getParagraphs ( fileName , slideIndex , shapeIndex , password , folderName , storageName , null );
var paragraphCount = paragraphs . getParagraphLinks (). size ();
System . out . println ( paragraphCount );
} catch ( Exception e ) {
e . printStackTrace ();
}
}
}
C++
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-cpp
#include <asposeslidescloud/api/SlidesApi.h>
using namespace utility :: conversions ;
using namespace asposeslidescloud :: api ;
int main ()
{
auto configuration = std :: make_shared < ApiConfiguration > ();
configuration -> setAppSid ( to_string_t ( "my_client_id" ));
configuration -> setAppKey ( to_string_t ( "my_client_key" ));
auto slidesApi = std :: make_shared < SlidesApi > ( configuration );
auto fileName = to_string_t ( "example.pptx" );
auto folderName = to_string_t ( "Data" );
auto storageName = to_string_t ( "Main" );
auto filePath = folderName + to_string_t ( "/" ) + fileName ;
auto slideIndex = 1 ;
auto shapeIndex = 3 ;
auto password = utility :: string_t ();
try
{
auto fileStream = std :: make_shared < std :: ifstream > ( fileName , std :: ios :: binary );
auto uploadContent = std :: make_shared < HttpContent > ();
uploadContent -> setData ( fileStream );
slidesApi -> uploadFile ( filePath , uploadContent , storageName ). wait ();
auto paragraphs = slidesApi -> getParagraphs (
fileName , slideIndex , shapeIndex , password , folderName , storageName ). get ();
auto paragraphCount = paragraphs -> getParagraphLinks (). size ();
std :: cout << paragraphCount ;
}
catch ( const std :: exception & e )
{
std :: cout << e . what ();
}
return 0 ;
}
Perl
Swift
Go