PowerPoint Slides Manipulation using Cloud APIs

Why PowerPoint Presentations?

PowerPoint templates preview

PowerPoint presentations are one of the popular and most widely used formats of data and information presentations during board and general meetings. Also, in the eLearning world, PowerPoint is among the popular knowledge-sharing formats. The presentation format has changed the way people present ideas and information to an audience. The Presentation files store collection of records to accommodate presentation data such as slides, shapes, text, animations, video, audio, and embedded objects.

As per your requirements, you use the Presentation software such as Microsoft PowerPoint, Apache OpenOffice Impress, Apple Keynote, etc, to create fliers, envelopes, business cards, invitations, certificates, forms, calendars, and even books. The common Presentation file extensions and their associated file formats include PPTXPPT, and ODP.

Features offered by Aspose.Slides Cloud

In order to compile a compelling presentation, you must first understand all that your presentation processing API has to offer. Aspose.Slides Cloud enables you to create well-designed, impactful slides within Presentations. The concept of slides is quite phenomenal where related information is grouped on a particular slide. You may add beautiful timelines and charts to your presentation using API.

At slide level, the API offers the features to Add, Remove, Copy, Move, get slides count, dimensions, and information regarding other objects in a slide. Please consider visiting the following link for information regarding features offered by Aspose.Slides Cloud API.

Add, Move, Delete, Copy Slides

While manipulating PowerPoint presentations, one of the most popular operations performed by users includes the addition of new empty slides, the movement of slide to a new location in presentation, Copy existing slide to a new location or delete an existing slide from the presentations file. When dealing with files, we get an option to perform operations on files stored on a local file system or a file stored in cloud storage.

In the following examples, we will be dealing with the attached sample presentation which initially contains one single master slide.

Preview of input Presentation file
Image 1:- Preview of the source Presentation file

Add an empty slide

As shown in the code snippet below, a single method PostSlidesAddRequest(..) is used to add a new slide to the presentation file. The first parameters accept the Presentation file name, the second argument takes the index where the slide needs to be added. In case the index parameter is not specified, then the slide is added at the end of already present slides in the presentation. The third one is password information for the file, and so on. All the parameters except the input file name are optional.

Preview after adding new blank slide
Image 2:- Preview after adding a blank slide on 2nd index

Move Slide

The API provides a simple method to rearrange the position of the slide within the presentation file. You simply need to provide the location/name of an input file, index of the slide which you need to move, and a third argument pointing to the index where you need to move the file. As per the code snippet below, the slide from the 2nd index is moved to 1st.

Preview after reordering 2nd slide to new position
Image 2:- Preview after reOrdering 2nd slide to 1st index

Delete Slide

Among the CRUD operations, Delete also possesses its importance because we sometimes stumble upon a requirement to remove unnecessary or outdated information. So in order to cater to this requirement. the API is fully capable of handling such requests. You get the option to delete all slides in a presentation using DeleteSlidesCleanSlidesList(..) method or remove a slide at a specific index using DeleteSlideByIndex(..) method which accepts two arguments i.e. input presentation file name and index of the slide to be removed.

Preview after deleting slide at index 2
Image 4:- Preview after removing slide on the 2nd index.
Posted in Aspose.Slides Cloud Product Family | Tagged , , , , | Leave a comment

Conditional Formatting in Microsoft Excel Spreadsheet using C#

While learning about visualizing data in Excel spreadsheets, we have already learned about Working with Charts in Excel Workbook. Now, let us explore another feature of Conditional Formatting in Excel files. It is a useful and effective way of presenting the information.

In this article, we will be learning the following features related to Conditional Formatting:

  • Add Conditional Formatting in Excel Spreadsheet
  • Delete Conditional Formatting in Excel Spreadsheet
  • Update Conditional Formatting in Excel Spreadsheet

Add Conditional Formatting in Excel Spreadsheet

You can specify different parameters of the condition including the Type, Operator, Style, Cell Area, etc and then call the API. Following C# code demonstrates how you can add conditional formatting in Excel worksheet:

This code snippet will add the conditional formatting to the specified cell area. You can notice changed background color of cells that contain the value under a specific range.

Conditional Formatting Excel

Moreover, Microsoft Excel offers three presets for Conditional Formatting, Data Bars, Color Scales, and Icon Sets. The following screenshot shows these presets. Fortunately, all of these presets are supported by Aspose.Cells Cloud API. Such features elevate the API to be the best fit for processing Excel spreadsheet files.

Conditional Formatting in Excel

Delete Conditional Formatting in Excel Spreadsheet

You can delete any conditional formatting from an Excel workbook. Simply set the index of formatting and call the API. However, the index is zero-based so zero should be passed to delete first formatting and so on. Following C# code snippet deletes first conditional formatting from specified worksheet of the specific workbook:

Furthermore, you can also delete all conditional formattings from a worksheet in a single API call. Simply omit or comment out the index variable and the API will delete all of the formattings from the specified worksheet.

Update Conditional Formatting in Excel Spreadsheet

You can update existing conditional formattings in an Excel file. For instance, let us update the Condition Area in the formatting we had added in the very first example of this article. You can notice in that screenshot as well that the area is set as A1:C10. Let us continue that example and further include E6:G8 cells. Following code snippet can be used to update the condition area:

The below screenshot highlights how the same condition is extended to another area specified in the code snippet.

Update Conditional Formatting Excel

The highlighted area on this screenshot is the example of how the updating of the Condition Area works. The cells in range E6:G8 are now appended to the condition area.

To sum up, we have explored a few of the possibilities that you can utilize in your applications. You can further refer to API references, API documentation, and different SDKs of Aspose.Cells for Cloud API. We look forward to your feedback or suggestions at Free Support Forums. Cheers!

Related Post

Create, Edit or Convert Excel Files without using MS Excel

Posted in Aspose.Cells Cloud Product Family | Tagged , | Leave a comment

Add, Delete and Manipulate Charts in Excel file using C#

Charts are used to reflect information in easy to understand manner. Spreadsheets are used by almost all offices to manage data but they are not so easy to read. This is why a Chart, often known as a graph in Excel, is helpful to present an overview of the data. Aspose.Cells for Cloud API is rich with Chart manipulation APIs. In this article, we will be learning the following features:

  • Add Chart in Excel Spreadsheet
  • Delete Chart in Excel Spreadsheet
  • Update Existing Chart in Excel Spreadsheet

The API can be called from any platform using any programming language. Different SDKs are available including Python, PHP, Ruby, Perl, Go, Swift, and many more. You can choose and use it among any of those as per your convenience. Here we will be using C# code for these examples.

Add Chart in Excel Spreadsheet

You can insert a chart or graph in an Excel workbook with Aspose.Cells Cloud API. Simply specify the necessary properties of the chart, like Chart Type, Chart Area, and then make the API call. Below is a sample code which adds a Pie Chart to a worksheet:

This code snippet will create a chart as displayed in the following screenshot:

Add Chart in Excel

Delete Chart from Excel Spreadsheet

You can delete or remove an existing chart from an XLSX or XLS file with Aspose.Cells Cloud API. Simply specify the file name, worksheet name, and chart index. Subsequently, call the API and respective chart will be deleted from the worksheet. However, the data will remain unaffected in the cells as it is, only the chart will be deleted. Following code snippet can be used for the same purpose:

The below screenshot shows output worksheet where data stays the same and the chart is deleted.

Update a Chart in Excel Spreadsheet

Since we have already considered two of the chart manipulation features above, let us check out another feature of updating an existing chart. Here we will be updating the title of the chart by specifying the name of Excel file, name of the worksheet, and index of the chart as in following C# code snippet:

The output of this code snippet can be observed in the screenshot below. The chart title is the same as specified by us.

These are a few of the many chart manipulation features offered by the API. You can sign up for free and test the APIs in their full capacity. In case of any query, please write to us at Free Support Forums.

Related Post

Create, Edit or Convert Excel Files

Posted in Aspose.Cells Cloud Product Family | Tagged , , , , , , , , , , | Leave a comment

Add, Delete, or Update Bookmarks in PDF Documents

Bookmarks make navigation easier in large documents. Readers can easily jump between different pages and sections, instead of scrolling through the whole document. Aspose.PDF Cloud API offers many PDF manipulation features. Working with Bookmarks is one of the commonly used features of the API. In this blog, we will be learning the following use cases:

  • Add bookmarks in PDF documents
  • Delete bookmarks in PDF document
  • Update bookmarks in PDF document

Aspose.PDF Cloud API supports a lot of programming languages including C#, Java, Python, Go, Ruby, PHP, and many more. Respective SDKs are available for your convenience. You can simply integrate any of the SDKs into your applications as the SDK will take care of minor details related to requests and responses. This enables you to focus on the major features you want to include in your application. Let us move on to bookmark related features in .NET applications:

Add Bookmarks in PDF Document

Sometimes adding bookmarks is necessary criteria while submitting documents, for example, legal filings. In such scenarios, your applications can be sufficient to cater to all of your needs. You simply need to specify the attributes or properties of the Bookmark and send the request to insert the bookmark in the PDF file. Below C# code is a demonstration of using this feature:

Here almost all attributes of Bookmark class are self-explanatory. However, the bookmarkPath parameter points to the parent bookmark in the tree. If you want to add a bookmark to the root, you must specify an empty string as the path. Following is a screenshot of the output PDF document with a bookmark added by the above code snippet.

Bookmarks in PDF

Delete Bookmark in PDF Document

It is important to note here that deleting a parent bookmark will delete all of its child bookmarks as well. However, deleting a bookmark does not delete any text or any part of the document. Let us learn this by an example in C# language:

You can notice that we simply need to specify bookmarkPath property, as explained above, before calling the API.

Update Bookmarks in PDF Document

You may need to update bookmarks in PDF documents by renaming a bookmark, update destination, or the appearance. The API is advanced enough to support these features as well. Below code snippet can be used to update bookmarks:

Curious for other features offered by the API? You can explore some of the possibilities in API documentation. If you want to test the API in its full capacity, then Sign Up for free and use the API with the generous free trial. If you have got any inquiry then feel free to get in touch with us via Free Support Forums.

Related Post

Split PDF File into Multiple Files using C# .NET

Posted in Aspose.PDF Cloud Product Family | Tagged , , , , , , | Leave a comment

Add Watermark or Delete Watermark in Word (DOCX/DOC) Documents

Microsoft Word (DOCX/DOC) documents are frequently used to exchange information. Sometimes a watermark is added on the document to show ownership or purpose of the document. There could be different possible use cases, whereas we will be learning following scenarios in this blog post:

  • Insert Watermark Text in Word Document (DOCX/DOC)
  • Insert Watermark Image in Word Document (DOCX/DOC)
  • Remove Watermark from Word Document (DOCX/DOC)

Insert Watermark Text in Microsoft Word Document (DOCX/DOC)

With Aspose.Words Cloud API, you only need to set text and the rotation angle, where the rotation angle works in the clockwise direction. Following C# code snippet inserts text in all pages of the DOCX or DOC document.

Below screenshot shows output file in Print Preview window:

Text Watermark in Word Document

Add Watermark Image in Word Document (DOCX/DOC)

Images are also used as watermark in Microsoft Word Documents. If you want to set an image watermark then below code snippet can be used to achieve these requirements.

This API call will set the image at the specified angle in the middle of the page. The following is a screenshot of Print Preview for the output document after inserting image.

Image Watermark Word Document DOCX

Delete Watermark from Microsoft Word Document (DOCX/DOC)

Aspose.Words Cloud API offers the most exclusive features to manipulate word documents. You can delete watermarks with single API call. Below code snippet can be used to remove it efficiently:

It is important to note here that the API will remove the most recent or last watermark applied to the document. Therefore, in case there is more than one appearance or kind of it in a document, let us say an image and some text, then you would need to call the API twice.

This is a detailed overview of the feature. Many other features are also offered by the API. You can get familiar with those and stay updated by visiting Blogs section. In case of any concerns, you can always get in touch with us. Write to us at Free Support Forums and we would love to help you.

Related Post

Convert Word to HTML and Vice Versa

Posted in Aspose.Words Cloud Product Family | Tagged , , , , , | Leave a comment

Split Word DOC/DOCX Pages to Multiple Documents in C#

Split word files

You may need to split huge word files into smaller files. Aspose.Words Cloud API can enhance your applications with the ability to split Microsoft Word Documents without needing any 3rd party application. A generous trial quota is awarded when you sign up for free. This lets you evaluate the API in its full capacity before purchasing the API.

Aspose.Words Cloud API supports several programming languages. Different SDKs are available that you can integrate into your applications to test API features in different programming languages. Here we will be considering a few basic examples using C# language. Let us explore the following use cases:

  • Split Word documents DOC/DOCX to multiple files
  • Split Specific Pages of Large Word (DOC/DOCX) documents
  • Split Specific Pages of Word File to PDF

Before we start these examples, let us learn how a file can be uploaded to Cloud Storage. Following code snippet contains the method which uploads a file:

Split Word Documents (DOC/DOCX) to Multiple Files

Splitting a word document to separate pages is now possible with only one API call. Simply set the parameters and perform the operation. Below code demonstrates this feature where few lines of code can achieve these requirements:

The SplitDocumentRequest supports setting some optional parameters including page range values, password if source word file is encrypted, a bool value to specify if you need output files as single ZIP file, as well as fonts location if some custom fonts are being used in the document.

Split Specific Pages of Word Documents

The example we have discussed above splits the whole document to separate pages because the page range is not specified with to and from parameters. Now, let us move forward with a scenario where you want to select specific pages only. It is suitable for scenarios when you do not want to share or print some confidential information. Following code snippet splits page number 3 to 5 and saves the output as a single ZIP file.

Split Specific Pages of Word File to PDF

Aspose.Words Cloud API supports splitting Microsoft Word files into different formats. Instead of first splitting some pages and then converting to the required format, the API supports direct saving of those pages to several file-formats including images, HTML, PDF, and several others. Following code snippet splits page numbers 2 to 6 and saves the output as PDF documents.

This code snippet is efficient enough to split as well as convert a page to a specific format with a single API call. Such exciting features make this API the best fit for all of your document processing needs. If you have any questions about the API, please reach out to us at Free Support Forums. We would love to assist you!

Related Article

Split PDF File into Multiple Files using C# .NET

Posted in Aspose.Words Cloud Product Family | Tagged , , , , , , , , , | Leave a comment

Split PDF File into Multiple Files using C# .NET

Split PDF C# csharp

Splitting a PDF document is a quite famous use case in file format manipulation. For instance, the finance management system of some organization creates a report containing many salary slips of their employees, then they need to split the PDF file to multiple files and email to the respective department for further processing. Aspose.PDF Cloud API is the perfect solution for PDF file manipulations.

A unique competitive edge for Aspose.PDF Cloud API is that it has been designed keeping in view the user-perspective. Since the skill set of all users is not the same, thus several SDKs are available in different languages including .NET, Java, PHP, Python, Ruby, and other programming languages. This leverages you to focus on what matters the most, because minor details like handling of requests and responses are managed by the SDK. However, in this article, we will be checking out the following use cases using C# language.

  • Split whole PDF file into separate PDF files
  • Split specific pages of a PDF document

One can also term this feature as cutting PDF documents or PDF cutter feature using C# language. However, before we proceed to splitting PDF files, it is important to note that you can configure several 3rd party Cloud Storages. Let us now upload a sample PDF document to Cloud Storage using following simple code snippet:

After the file is uploaded to Cloud Storage, let us move on to the code that works as PDF cutter or PDF splitter.

Split whole PDF file to multiple files

You may need to split all pages into separate PDF documents. For instance, n number of PDF documents will be generated if the original document contains n Pages. Follow the below steps in order to split a complete PDF file with single API call:

  1. Upload PDF file to Cloud Storage
  2. Call PostSplitDocument API while setting necessary parameters
  3. Output PDF files will be saved in configured cloud storage

Below C# code snippet is a demonstration of how to split whole PDF document to multiple files.

Split Specific Pages of PDF to Separate Files

You can also split specific pages of a PDF document to separate files as per your requirements. Below C# code can be used to process specific pages of the PDF document.

This code snippet creates separate PDF documents for page number 2,3, and 4 because of the values specified in API request. Those output PDF documents will be saved in the respective folder at Cloud Drive.

It elaborates on the simple yet efficient API features of Aspose.PDF Cloud API, where you only need to sign up for free and evaluate robust features with simple API calls.

Related Article

Convert HTML to PDF

Posted in Aspose.PDF Cloud Product Family | Tagged , , , , , , , , | Leave a comment

Using cURL commands to Process Header and Footer of MS Word document on macOS

cURL commands are an excellent way of transferring data with URLs. cURL commands are recommended to use APIs from command line terminals. It not just only allows us to make regular requests, but we can also post forms data, authenticate users, save responses to files and other related file manipulation operations. In simple words, curl is a command-line utility for transferring data from or to a server designed to work without user interaction. With curl, you can download or upload data using one of the supported protocols including HTTP, HTTPS, SCP, SFTP, and FTP.

Nevertheless, it also facilitates us to test RESTfull APIs.

cURL commands used

GET

The simplest and most common request/operation made using HTTP is to GET a URL. When using this command, we send a request and retrieve resources from a specific URL (a document in our case).

POST

The default request is a GET but if we have a requirement of using the same cURL command for submitting forms data, we need to use POST request. Therefore in this article, we will use the same POST command to submit text content. Please note that in order to post data, we use -d (or — data) parameter with the cURL command.

PUT

We may stumble upon a requirement to update existing data, so for that purpose, a PUT method is used. In order to accomplish this requirement, we need to use -X PUT in cURL command where X needs to be in upper case.

For further information, please visit cURL tutorial.

Note: when using cURL commands, ensure you do not put an extra space after the backslash \ else, the command will not be executed and errors will be displayed.

Setting up cURL on Mac

In this article, we are going to use cURL commands on macOS to insert and update Header Footer objects inside MS Word document using a terminal application. So in order to get started, the first thing is to install cURL on macOS. Open the Terminal application under Others category from the launchpad or, Press Command+Space and type Terminal and press enter/return key. The easiest way to install cURL is using Homebrew and for that reason, first, you need to set up homebrew on your mac machine. Type following command on command line terminal and press Enter key.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

Now get the brew package for cURL using the following command.

 brew install curl 

Done! You can now use curl.

Authorize Aspose.Cloud account

In order to get started with Aspose.Cloud APIs, the first step is to authenticate your account and get JWT in response. If you do not have an account, you may create one on Aspose.Cloud dashboard or signup through your existing Google or GitHub account and start using our Cloud APIs.

// First get JSON Web Token for authentication
// Get App Key and App SID from https://dashboard.aspose.cloud/
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=[APP_SID]&client_secret=[APP_KEY]" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Aspose.Words Cloud

Aspose offers APIs to manipulate MS Word documents and you get an option to either use Cloud APIs, On-Premise APIs or, Cross-platform Apps to process Word documents. In this blog, we have emphasized over Cloud APIs which provide us the capabilities to create, manipulate and transform MS Word documents in the Cloud. No specific software download or installation required to work with MS Word files.

The Aspose.Cloud Product family provides a set of cloud SDKs targetting popular programming languages including .NET, Java, PHP, Python, Node.js, Android, C++, Ruby, Swift and Go. All these SDKs are a wrapper around Aspose.Words Cloud REST API and cURL commands are one of the simplest and easiest ways to access REST APIs over command prompt/terminal.

In this blog, we are emphasizing on using cURL commands to manipulate the Header and Footer section inside MS Word files while accessing Aspose.Words Cloud API.

Upload Word document

Once the authentication has been performed, the next step is to upload the file to cloud storage. By using the following cURL command, the file is uploaded to default storage under InputFolder.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/storage/file/InputFolder" \
-H "accept: application/json" \
-H "authorization: Bearer <jwt token>" \
-F document=@BusinessLetter2.docx
Console output when file is uploaded to Cloud Storage
Success message when a file is uploaded to cloud storage.

Now in order to confirm the file presence on cloud storage, open My Files tab over dashboard.aspose.cloud, we can notice that a new folder named InputFolder containing BusinessLetter2.docx is appearing in the list.

Newly Created folder and file uploaded on Cloud Storage

Insert Header object

After uploading the document, we can either insert a new Header or Footer object or access an existing object and update its properties. Currently, Aspose.Words Cloud API supports the following types of Header and Footer objects.

The following command shows how to insert HeaderFirst object inside Word document already available in Cloud storage under InputFolder.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/BusinessLetter2.docx/headersfooters?folder=InputFolder" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <jwt token>" \
-d "'HeaderFirst'" \
-H "Content-Type: application/json"

Once the above command is executed, the console lists the sections inside Word document.

The header and Footer sections usually contain text, images, etc and in the following command, we are going to insert a sample text inside the first paragraph inside the header object created above.

curl -v -X POST "https://api.aspose.cloud/v4.0/words/BusinessLetter2.docx/sections/0/headersFooters/1/paragraphs?folder=InputFolder" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <jwt token>" \
-d "{ 'Text': 'Aspose.Words Cloud .NET SDK' }" \
-H "Content-Type: application/json"
Console output after Text is inserted in the Header object. Observe the path of the text inserted.

Update Text Formatting of the Header object

Once the text is inserted, we can update the text font properties. Since a word document may contain many text instances, so in order to update the text, we need to provide the exact path. So if we need to update the font properties for the above-inserted text which is inserted over sections/0/headersfooters/1/paragraphs/0/runs/0, then we need to use the following command.

Please note that now that we are going to update the font properties of an already placed objects, so we need to use the PUT command.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/BusinessLetter2.docx/sections/0/headersFooters/1/paragraphs/0/runs/0/font?folder=InputFolder" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <jwt token>" \
-d "{ 'Bold':true, 'Size': 21.0, 'Name': 'Calibri',  'Color': { 'Web': '#f54269', 'Alpha': 0 } }" \
-H "Content-Type: application/json"

Insert PageNumber in Footer

One of the important usages of Header and Footer objects is to display page number information and while using Aspose.Words Cloud, we can easily accomplish this requirement. The API also provides the capabilities to specify the location where PageNumber stamp needs to be displayed. As shown in command below, we have specified to add PageNumber information to be rendered on the Top-Right location of the page and also display it over the first page of the document.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/BusinessLetter2.docx/PageNumbers?folder=InputFolder" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <jwt token>" \
-d "{ 'Format': '{PAGE} of {NUMPAGES}', 'Alignment': 'right', 'IsTop': false, 'SetPageNumberOnFirstPage': true }" \
-H "Content-Type: application/json"

Similar to font properties update to Header instance, we can also update the font properties of Footer object which contains PageNumber information. As the page number information is comprised of three-run objects (runs/0, runs/2, and runs/3), so we need to update the font update command three times for each run instance.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/BusinessLetter2.docx/sections/0/headersFooters/3/paragraphs/1/runs/3/font?folder=InputFolder" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <jwt token>" \
-d "{ 'Bold':true, 'Size': 21.0, 'Name': 'Arial', 'Shadow': true, 'Color': { 'Web': '#f5b642', 'Alpha': 0 } }" \
-H "Content-Type: application/json"

Once all the above commands are executed, the resultant document will look similar to the preview above.

For your reference, the sample documents are also attached

Posted in Aspose.Words Cloud Product Family, Nayyer Shahbaz | Tagged , , , , , , , | Leave a comment

Add or Update header and footer in a Word Document using REST APIs

A quick view of MS Word document transformation.

A header is the top margin of each page, and a footer is the bottom margin of each page. Headers and footers are useful for including information that you want to display on every page of a document such as your name, dates, the title of the document, page numbers or disclaimers to documents. When using MS Word, it provides the capabilities to add Header and Footers based on predefined layouts or enable you to add custom headers and footers. Most built-in headers contain some placeholder text and either, you can keep the placeholder text or replace it with your own data feed. When updating the information in the Header or Footer section, the content inside the main body of the document is grayed out which indicates that these objects are totally isolated from the rest of the page content and the operation which you perform on these objects is specific to these areas.

Aspose.Words Cloud API provides the capabilities to load MS Word files from Cloud storage, as well as it allows the user to pass the input file directly in the request body and the API returns the updated file in the response object. It provides the features to Read, Add, Update or Delete specific or all Header and Footer objects. Furthermore, you may also specify to render different headers/footers for the first page and for odd/even pages. The API also enables you to set formatting information such as font and paragraph properties for the header/footer text. You also get the leverage to insert dynamic page numbers into the header/footer section. Last but not the least, you may consider using table objects to make one part of the header/footer text-align to the left edge and the other to the right edge.

Scope of Article

Our Aspose.Words Cloud SDK for .NET allows you to work with Aspose.Words Cloud REST APIs quickly and easily, as it takes care of a lot of low-level details regarding making requests and handling responses and lets you focus on writing code specific to your business requirements. In this article, we are going to use Aspose.Words Cloud SDK for .NET in Visual Studio for Mac. This post defines the steps to insert one Header object where custom formatting will be defined. Then the formatting of exiting Footer content is updated and PageNumber information is inserted at Bottom-Right position. All these operations will be performed in the cloud.

In order to get started, first, you need to install Visual Studio on your system. Create a sample solution and add NuGet reference of Aspose.Words Cloud SDK for .NET. So in order to add a reference, right-click on the solution and select Manage NuGet Packages… menu option. Enter Aspose.Words-Cloud in the search text field. Select the option and click the Add package button.

Once the NuGet package is added, Aspose.Words.Cloud.Sdk reference appears in the solution. There are some benefits of using cloud APIs in contrast to on-premise (aspose.com) APIs. The reason being, you do not need to manually keep track and update the API versions and you do not need to pay for the whole license. Simply create an account on Aspose.Cloud dashboard or signup through your existing Google or GitHub account and start using our Cloud APIs. Another amazing feature of Cloud APIs is that you can use them on any platform using any supported language.

As indicated above, the article emphasizes on options regarding the addition and update of Header and Footer objects inside MS Word document. For the sake of testing, we have used an existing MS Word document template with the name Business Letter. The document needs to be uploaded to Aspose cloud storage and all the manipulation and document processing will be performed over the cloud. Once all processing is completed, we can also download the resultant file copy from the Cloud storage.

using Aspose.Words.Cloud.Sdk;
using Aspose.Words.Cloud.Sdk.Model;
using Aspose.Words.Cloud.Sdk.Model.Requests;

In order to use Aspose.Cloud APIs, you need to use App Key and App SID information in your code. These keys are comprised of Alphanumeric digits. These are unique codes associated with your subscription account. In order to get these details, please click My Apps tab on Aspose.Cloud dashboard. Once we have the Keys, we need to initialize Aspose.Words API object.

string MyAppKey = "f6axxxxxxxxxxxxxxxxxx";     // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "478e4827-xxxxx-xxxx-xxxx-xxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
// create an object of WordsApi while passing AppKey and AppSid information
WordsApi wordsApi = new WordsApi(MyAppKey, MyAppSid);

Insert Header object

In order to add the header object inside the MS Word file, we need to perform the following operations in sequence.

  1. Create an object of InsertHeaderFooterRequest where we pass HeaderFooterLink type as an argument.
  2. Insert HeaderFooterRequest object to WordsApi object using InsertHeaderFooter (…) method.
  3. Create a Run object which holds sample Text information.
  4. Create InsertRunRequest object where we pass the reference of paragraph(SectionPath) in HeaderFooter object, where Run text needs to be added.
    Then call InsertRun (…) method of WordsApi, which adds the RunRequest to HeaderFooter object.

The HeaderFooter.TypeEnum can be either of the following values.

Image showing preview of recently added Header

Update Text formatting of Newly inserted Header

Once the Header object is added, we can update the text formatting of the content inside it. In order to fulfill this requirement, we need to perform the following steps.

  1. Create an object of Font class, where we specify Font name, size, color information.
  2. In order to make the text more presentable, mark Engrave property as True.
  3. Create an object of UpdateRunFontRequest class where we pass the input file, Font, SectionPath and runIndex as an argument.
  4. Finally, use UpdateRunFont(..) method and add UpdateRunFontRequest object to WordsApi instance.
Image showing preview of Header after text formatting has been applied.

Update formatting of existing Footer object

The API also offers the feature to update the formatting of content inside the existing Header / Footer object. In order to fulfill this requirement, we can use the above-specified code lines but the only difference is the change of headerfooter index to 2. See the following code line.

// Apply formatting to first paragraph of HeaderFooter object
var FooterDocumentParagraphRunFontRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UpdateRunFontRequest("BusinessLetter.docx", 
FooterFontDto, "sections/0/headersfooters/2/paragraphs/0", FooterrunIndex);
Image displaying the change in Footer text formatting.

Add PageNumber information in Footer Section

Page numbers provide very useful information such as the current page and the total number of pages in a document. The following steps define how to accomplish the requirements.

  1. First create an object of PageNumber class, where we define, Alignment of text, the format of the text, location to render PageNumber information and also, specify if PageNumber needs to be rendered on the first page or not.
  2. Create InsertPageNumbersRequest object and pass PageNumber object as an argument.
  3. Finally, call InsertPageNumbers(..) method to add InsertPageNumbersRequest to WordsApi instance.
Image displaying a preview of MS Word file with Page number in Footer section.

Apart from Aspose.Words Cloud SDK for .NET, we also have Cloud SDKs available for Java, PHP, Ruby, Python, Go, Swift, C++, Node.Js, Android. For further details, please visit Aspose.Words Cloud.

Posted in Aspose.Words Cloud Product Family, Nayyer Shahbaz | Tagged , , , | Leave a comment

Convert an Image to Grayscale with RESTful API

Image to Grayscale

Images are widely used to represent information. Considering the demand and requests, we have introduced a most awaited feature of image to grayscale conversion in Aspose.Imaging Cloud API February 2020 release.

You can convert, edit or manipulate BMP, GIF, JPEG, PSD, TIFF, WEBP, PNG, and other supported file formats‘ images. Organizations with huge databases of pictures prefer to keep grayscale images for size considerations. For instance, some law enforcement agencies would consider facial features and geometry as important or efficient as compared to color. Let us take a look at available APIs for true color image to grayscale conversion with Aspose.Imaging Cloud API.

APIDescription
GET /imaging/{name}/grayscale Grayscale an existing image
POST /imaging/grayscaleGrayscales an image. Image data is passed as zero-indexed multipart/form-data content or as raw body stream

Following is a C# code snippet to convert a sample image to grayscale:

This code snippet uploads the input file from local storage to Cloud storage and then converts the RGB image to grayscale image. The API saves output grayscale image in Cloud storage that looks like below screenshot:

Input Image

Output Image

Greyscale image

Let us check out another scenario where the source file is passed in request and the response contains converted grayscale image which is saved in local storage. This approach does not need uploading or downloading the image from Cloud storage. Below is the C# code snippet based on this workflow:

Wondering about working with the same feature in other programming languages? No worries, Aspose.Imaging Cloud SDKs are available for all popular languages so you can conveniently call the API from your favorite platforms. Moreover, we have also ported images to grayscale conversion examples to the supported languages including Python, Java, PHP, Node.js, and Ruby.

Aspose.Imaging Cloud API can take your applications a step forward to the next level. Many other fixes and maintenances are also part of this release; including some exception fixes and improvements for multi-page images export. You may take an overview at Release Notes for more details. You can Sign Up for free and start learning the API today. We maintain API documentation for basic scenarios. You can also reach out to us at Free Support Forum if you need any further help.

Related Post:

Reverse Image Search and Image Deskewing with Aspose.Imaging Cloud

Posted in Aspose.Imaging Cloud Product Family | Tagged , , , , , , | Leave a comment