page 146

With the help of Spire.Presentation, we can add shapes to the presentation slides easily. This example shows you how to add a round corner rectangle to presentation slide and set the radius of the round corner rectangle in C#.

using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

namespace RoundRectangle
{
    class Program
    {
        static void Main(string[] args)
        {          
            Presentation presentation = new Presentation();

            //Insert a round corner rectangle and set its radious
            presentation.Slides[0].Shapes.InsertRoundRectangle(0, 60, 90, 100, 200, 36);

            //Append a round corner rectangle and set its radious
            IAutoShape shape = presentation.Slides[0].Shapes.AppendRoundRectangle(260, 90, 100, 200, 80);
            //Set the color and fill style of shape
            shape.Fill.FillType = FillFormatType.Solid;
            shape.Fill.SolidColor.Color = Color.SeaGreen;
            shape.ShapeStyle.LineColor.Color = Color.White;
            //Rotate the shape to 90 degree
            shape.Rotation = 90;  
            
            //Save the document to file    
            presentation.SaveToFile("Result.pptx", FileFormat.Pptx2013);
                                                                              
        }
    }
}

Effective screenshot of the round corner rectangle on presentation slide:

Add a round corner rectangle to presentation slide in C#

Get Bookmark Text in Java

2019-08-08 08:48:58 Written by Koohji

This article demonstrates how to get the text inside a bookmark in a Word document using Spire.Doc for Java.

import com.spire.doc.Document;
import com.spire.doc.documents.BookmarksNavigator;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.documents.TextBodyPart;
import com.spire.doc.fields.TextRange;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

public class GetBookmarkText {

    public static void main(String[] args) throws FileNotFoundException {

        //create a Document object
        Document doc = new Document();

        //load a sample Word file
        doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.docx");

        //get the specific bookmark
        BookmarksNavigator navigator = new BookmarksNavigator(doc);
        navigator.moveToBookmark("MyBookmark");

        //get the bookmark content
        TextBodyPart textBodyPart = navigator.getBookmarkContent();

        //declare a String variable
        String text = "";

        //loop through body items
        for (Object item : textBodyPart.getBodyItems()) {

            //determine if an item is a paragraph
            if (item instanceof Paragraph) {
                Paragraph paragraph = (Paragraph) item;

                //loop through the child objects of the paragraph
                for (Object childObj : paragraph.getChildObjects()) {

                    //determine if a child object is a text range
                    if (childObj instanceof TextRange) {

                        //get text from the text range
                        TextRange textRange = (TextRange) childObj;
                        text = text + textRange.getText();
                    }
                }
            }
        }

        //write the bookmark text to a .txt file
        PrintWriter printWriter = new PrintWriter("output/BookmarkText.txt");
        printWriter.println(text);
        printWriter.close();
    }
}

Get Bookmark Text in Java

We can format Word document in a multi-column newsletter layout by adding columns. This article demonstrates how to add multiple columns to a Word document and specify the column width and the spacing between columns using Spire.Doc for Java.

import com.spire.doc.*;
import com.spire.doc.documents.*;

public class CreateMutiColumnWordDocument {
    public static void main(String[] args){
        //create a Document object
        Document document = new Document();
        //add a section 
        Section section = document.addSection();

        //add 3 columns to the section
        section.addColumn(100, 20);
        section.addColumn(100, 20);
        section.addColumn(100, 20);

        //add a paragraph to the section
        Paragraph paragraph = section.addParagraph();
        //add a paragraph to the section
        paragraph = section.addParagraph();
        String text = "Spire.Doc for Java is a professional Java Word API that enables Java applications "
        +"to create, convert, manipulate and print Word documents without using Microsoft Office.";
        //add text to the paragraph
        paragraph.appendText(text);
        //add column break to the paragraph
        paragraph.appendBreak(BreakType.Column_Break);

        //add a paragraph to the section
        paragraph = section.addParagraph();
        //add text to the paragraph
        paragraph.appendText(text);
        //add column break to the paragraph
        paragraph.appendBreak(BreakType.Column_Break);

        //add a paragraph to the section
        paragraph = section.addParagraph();
        //add text to the paragraph
        paragraph.appendText(text);

        //add line between columns
        section.getPageSetup().setColumnsLineBetween(true);

        //save the resultant document
        document.saveToFile("Muti-Column Document.docx", FileFormat.Docx_2013);

    }
}

Output:

Create a Multi-Column Word Document in Java

page 146

Coupon Code Copied!

Christmas Sale

Celebrate the season with exclusive savings

Save 10% Sitewide

Use Code:

View Campaign Details