diff --git a/README.md b/README.md index 1f9c3b3..7ff7684 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Syncfusion File Formats Java Documentation -This is the GitHub repository for the technical product documentation for Syncfusion File Formats Java components. This documentation is published to http://help.syncfusion.com/java-file-formats +This is the GitHub repository for the technical product documentation for Syncfusion File Formats Java components. This documentation is published at http://help.syncfusion.com/java-file-formats ## Contributions Welcome! -We welcome the [pull request](https://docs.github.com/en/github/managing-files-in-a-repository/editing-files-in-another-users-repository) for improving the File Formats Java Components user guide documentation. Your contribution towards this will be greatly appreciated. \ No newline at end of file +We welcome [pull requests](https://docs.github.com/en/github/managing-files-in-a-repository/editing-files-in-another-users-repository) for improving the File Formats Java Components user guide documentation. Your contributions towards this will be greatly appreciated. \ No newline at end of file diff --git a/java-file-formats/Installation/Installation-errors.md b/java-file-formats/Installation/Installation-errors.md index 8b4ebce..9ec70c5 100644 --- a/java-file-formats/Installation/Installation-errors.md +++ b/java-file-formats/Installation/Installation-errors.md @@ -1,7 +1,7 @@ --- layout: post title: Installation Errors in FileFormats - Syncfusion -description: Learn here about the common installation errors and solution to those errors in Syncfusion FileFormats Components installation. +description: Learn here about the common installation errors and solutions to those errors in Syncfusion FileFormats Components installation. platform: java-file-formats control: Installation and Deployment documentation: ug @@ -29,11 +29,11 @@ This article describes the most common installation errors, as well as the cause ### Reason -You are attempting to use a Trial unlock key to unlock the licensed installer. +You are attempting to use a trial unlock key to unlock the licensed installer. ### Suggested solution -Only a licensed unlock key can unlock a licensed installer. So, to unlock the Licensed installer, use the Licensed unlock key. To generate the licensed unlock key, refer to [this](http://syncfusion.com/kb/2326) article. +Only a licensed unlock key can unlock a licensed installer. So, to unlock the licensed installer, use the licensed unlock key. To generate the licensed unlock key, refer to [this](http://syncfusion.com/kb/2326) article. ## License has expired @@ -88,30 +88,30 @@ You can choose from the options listed below. 1. You can get a new license [here](https://www.syncfusion.com/sales/products). 2. Contact your account administrator. -3. Send an email to to request a license. -4. You can reach out to our sales team by emailing . +3. Send an email to to request a license. +4. You can reach out to our sales team by emailing . ## Unable to install because of another installation ### Problem -**Error Message:** Another installation is in progress. You cannot start this installation without completing all other currently active installations. Click cancel to end this installer or retry to attempt after currently active installation completed to install again. +**Error Message:** Another installation is in progress. You cannot start this installation without completing all other currently active installations. Click cancel to end this installer or retry to attempt after the currently active installation is completed to install again. ![Warning Message](Errors/Installation_Errors_img4.png) ### Reason -You are trying to install when another installation is already running in your machine. +You are trying to install when another installation is already running on your machine. ### Suggested solution -Open and kill the msiexec process in the task manager and then continue to install Syncfusion®. If the problem is still present, restart the computer and try Syncfusion® installer. +Open and kill the msiexec process in the task manager and then continue to install Syncfusion®. If the problem is still present, restart the computer and try the Syncfusion® installer again. 1. Open the Windows Task Manager. 2. Browse the Details tab. -3. Select the msiexec.exe and click **End task**. +3. Select msiexec.exe and click **End task**. ![Task Manager](Errors/Installation_Errors_img5.png) @@ -121,13 +121,13 @@ Open and kill the msiexec process in the task manager and then continue to insta #### Offline: -**Error Message:** Controlled folder access seems to be enabled in your machine. The provided install or samples location (e.g., Public Documents) is protected by the controlled folder access settings. +**Error Message:** Controlled folder access seems to be enabled on your machine. The provided install or samples location (e.g., Public Documents) is protected by the controlled folder access settings. ![Warning Message](Errors/Installation_Errors_img7.png) #### Online: -**Error Message:** Controlled folder access seems to be enabled in your machine. The provided install, samples, or download location (e.g., Public Documents) is protected by the controlled folder access settings. +**Error Message:** Controlled folder access seems to be enabled on your machine. The provided install, samples, or download location (e.g., Public Documents) is protected by the controlled folder access settings. ![Warning Message](Errors/Installation_Errors_img8.png) @@ -139,10 +139,10 @@ You have enabled controlled folder access settings on your computer. **Suggestion 1:** -1. We will ship our demos in the public documents folder by default. -2. You have controlled folder access enabled on your machine, so our demos cannot be installed in the documents folder. If you need to install our demos in the Documents folder, follow the steps in this [link](https://support.microsoft.com/en-us/windows/allow-an-app-to-access-controlled-folders-b5b6627a-b008-2ca2-7931-7e51e912b034) and disable the controlled folder access. -3. You can enable this option after the installing our Syncfusion® setup. +1. We will ship our demos in the public documents folder by default. +2. You have controlled folder access enabled on your machine, so our demos cannot be installed in the documents folder. If you need to install our demos in the Documents folder, follow the steps in this [link](https://support.microsoft.com/en-us/windows/allow-an-app-to-access-controlled-folders-b5b6627a-b008-2ca2-7931-7e51e912b034) and disable the controlled folder access. +3. You can enable this option after installing our Syncfusion® setup. **Suggestion 2:** -1. If you do not want to disable controlled folder access, you can install our demos in another directory. +1. If you do not want to disable controlled folder access, you can install our demos in another directory. \ No newline at end of file diff --git a/java-file-formats/Installation/available-syncfusion-java-packages.md b/java-file-formats/Installation/available-syncfusion-java-packages.md index 6181bb8..389fb5b 100644 --- a/java-file-formats/Installation/available-syncfusion-java-packages.md +++ b/java-file-formats/Installation/available-syncfusion-java-packages.md @@ -1,34 +1,34 @@ --- -title: Available Syncfusion Java packages | Syncfusion -description: This section demonstrates the Java packages (Jar files) available in Syncfusion (Syncfusion Jars for Java) +title: Available Syncfusion Java Packages | Syncfusion +description: This section demonstrates the Java packages (JAR files) available in Syncfusion (Syncfusion JARs for Java). platform: java-file-formats control: general documentation: UG --- -# Available Syncfusion® Java packages +# Available Syncfusion® Java Packages -Below are the Java packages available in syncfusion®. +Below are the Java packages available in Syncfusion®. - - + + +This JAR contains the core features needed for creating, reading, and editing a Word document programmatically.

+This JAR contains common functionalities required for the Syncfusion® file format libraries.

+This JAR is used for converting Word documents into Syncfusion® Document Text (*.SFDT) format documents.

Jar files

Short description

JAR Files

Short Description

syncfusion-docio

-This jar contains the core features needed for creating, reading, and editing a Word document programmatically.

syncfusion-javahelper

-This jar contains common functionalities required for the syncfusion® file format libraries.

syncfusion-ej2-wordprocessor

-This jar used for converting Word documents into Syncfusion® Document Text (*.SFDT) format documents.

\ No newline at end of file diff --git a/java-file-formats/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md b/java-file-formats/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md index 31ae573..442e7e8 100644 --- a/java-file-formats/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md +++ b/java-file-formats/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md @@ -1,13 +1,13 @@ --- title: Download Syncfusion Java packages from Apache Maven | Syncfusion -description: This section demonstrates how to configure and download required Jars from Apache Maven (Jar configuration) +description: This section demonstrates how to configure and download required JARs from Apache Maven (JAR configuration) platform: java-file-formats control: general documentation: UG --- # Configure to download Syncfusion® Java packages from Apache Maven -You can easily download the Syncfusion® packages for Java using the [maven repository](https://jars.syncfusion.com/). +You can easily download the Syncfusion® packages for Java using the [Maven repository](https://jars.syncfusion.com/). The following command shows how to mention the repository in Apache Maven. @@ -35,4 +35,4 @@ The following command shows how to refer to the Syncfusion - + \ No newline at end of file diff --git a/java-file-formats/Installation/web-installer/how-to-download.md b/java-file-formats/Installation/web-installer/how-to-download.md index 639c5b7..911fba7 100644 --- a/java-file-formats/Installation/web-installer/how-to-download.md +++ b/java-file-formats/Installation/web-installer/how-to-download.md @@ -1,7 +1,7 @@ --- layout: post -title: Downloading Syncfusion FileFormats web installer - Syncfusion -description: Learn here about how to download Syncfusion FileFormats web installer from our Syncfusion website with license. +title: Downloading Syncfusion FileFormats Web Installer - Syncfusion +description: Learn here about how to download Syncfusion FileFormats web installer from our Syncfusion website with a license. platform: java-file-formats control: Installation and Deployment documentation: ug @@ -10,10 +10,10 @@ documentation: ug # Downloading Syncfusion® FileFormats Web Installer -[DocIO](https://www.syncfusion.com/word-framework/net),[PDF](https://www.syncfusion.com/pdf-framework/net),[Presentation](https://www.syncfusion.com/powerpoint-framework/net), and [XlsIO](https://www.syncfusion.com/excel-framework/net) controls will be included in the Syncfusion® FileFormats installer. You can either download the licensed installer or try our trial installer depending on your license. +[DocIO](https://www.syncfusion.com/word-framework/net), [PDF](https://www.syncfusion.com/pdf-framework/net), [Presentation](https://www.syncfusion.com/powerpoint-framework/net), and [XlsIO](https://www.syncfusion.com/excel-framework/net) controls are included in the Syncfusion® FileFormats installer. You can either download the licensed installer or try our trial installer depending on your license. - - Trial Installer - - Licensed Installer + - Trial Installer + - Licensed Installer ## Download the Trial Version @@ -21,58 +21,58 @@ documentation: ug Our 30-day trial can be downloaded in two ways. * Download Free Trial Setup - * Start Trials if using components through [maven repository](https://jars.syncfusion.com) + * Start Trials if using components through [Maven Repository](https://jars.syncfusion.com) ### Download Free Trial Setup -1. You can evaluate our 30-day free trial by visiting the [Download Free Trial](https://www.syncfusion.com/downloads) page and select the FileFormats platform. -2. After completing the required form or logging in with your registered Syncfusion® account, you can download the FileFormats trial installer from the confirmation page. (as shown in below screenshot.) +1. You can evaluate our 30-day free trial by visiting the [Download Free Trial](https://www.syncfusion.com/downloads) page and selecting the FileFormats platform. +2. After completing the required form or logging in with your registered Syncfusion® account, you can download the FileFormats trial installer from the confirmation page (as shown in the screenshot below). ![Trial and downloads of Syncfusion® Essential Studio®](images/trial-confirmation.png) 3. With a trial license, only the latest version’s trial installer can be downloaded. -4. After downloading, the Syncfusion® FileFormats trial installer can be unlocked using either the trial unlock key or the Syncfusion® registered login credential. More information on generating an unlock key can be found in [this](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) article. -5. Before the trial expires, you can download the trial installer at any time from your registered account’s [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page (as shown in below screenshot.) +4. After downloading, the Syncfusion® FileFormats trial installer can be unlocked using either the trial unlock key or the Syncfusion® registered login credentials. More information on generating an unlock key can be found in [this](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) article. +5. Before the trial expires, you can download the trial installer at any time from your registered account’s [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page (as shown in the screenshot below). 6. Click the Download (element 1 in the screenshot below) button to get the Syncfusion® Essential Studio® FileFormats web installer. ![Trial and downloads of Syncfusion® Essential Studio®](images/trial-download.png) -### Start Trials if using components through [maven repository](https://jars.syncfusion.com) +### Start Trials if Using Components Through [Maven Repository](https://jars.syncfusion.com) -1. You can start your 30-day free trial for FileFormats from the [Start Trial](https://www.syncfusion.com/account/manage-trials/start-trials) page from your account. +1. You can start your 30-day free trial for FileFormats from the [Start Trial](https://www.syncfusion.com/account/manage-trials/start-trials) page in your account. ![Trial and downloads of Syncfusion® Essential Studio®](images/start-trial-download.png) -2. To access this page, you must sign up\log in with your Syncfusion® account. +2. To access this page, you must sign up/log in with your Syncfusion® account. 3. Begin your trial by selecting the FileFormats product. N> If you've already used the trial products and they haven't expired, you won't be able to start the trial for the same product again. -4. After you've started the trial, go to the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page to get the latest version trial installer. You can generate the [unlock key](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) and [license key](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) here at any time before the trial period expires. (as shown in below screenshot.) +4. After you've started the trial, go to the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page to get the latest version trial installer. You can generate the [unlock key](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) and [license key](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) here at any time before the trial period expires (as shown in the screenshot below). ![License and downloads of Syncfusion® Essential® Studio](images/start-trial-download-installer.png) 5. You can find your current active trial products on the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page. -## Download the License Version +## Download the Licensed Version -1. Syncfusion® licensed products will be available in the [License & Downloads](https://www.syncfusion.com/account/downloads) page under your registered Syncfusion® account. +1. Syncfusion® licensed products will be available on the [License & Downloads](https://www.syncfusion.com/account/downloads) page under your registered Syncfusion® account. 2. You can view all the licenses (both active and expired) associated with your account. 3. Click the Download (element 1 in the screenshot below) button to download the respective product’s installer. 4. The most recent version of the installer will be downloaded from this page. 5. To download older version installers, go to [Downloads Older Versions](https://www.syncfusion.com/account/downloads/studio) (element 2 in the screenshot below). -6. You can download other platform\add-on installers by going to More Downloads Options (element 3 in the screenshot below). +6. You can download other platform/add-on installers by going to More Download Options (element 3 in the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/license-download.png) -7. Before the license expires, you can download the installer at any time from your registered account’s [License & Downloads](https://www.syncfusion.com/account/downloads) page (See the screenshot below.) +7. Before the license expires, you can download the installer at any time from your registered account’s [License & Downloads](https://www.syncfusion.com/account/downloads) page (see the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/start-trial-download-web-installer.png) -8. After downloading, the Syncfusion® FileFormats web installer can be unlocked using Syncfusion® registered login credential. +8. After downloading, the Syncfusion® FileFormats web installer can be unlocked using Syncfusion® registered login credentials. - N> For Syncfusion® trial and licensed products, there is no separate web installer. Based on your account license, Syncfusion® trial or licensed products will be installed via web installer. + N> For Syncfusion® trial and licensed products, there is no separate web installer. Based on your account license, Syncfusion® trial or licensed products will be installed via the web installer. -You can also refer to the [**Web installer**](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-install) links for step-by-step installation guidelines. \ No newline at end of file +You can also refer to the [**Web Installer**](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-install) links for step-by-step installation guidelines. \ No newline at end of file diff --git a/java-file-formats/Installation/web-installer/how-to-install.md b/java-file-formats/Installation/web-installer/how-to-install.md index 9de3306..6b28f27 100644 --- a/java-file-formats/Installation/web-installer/how-to-install.md +++ b/java-file-formats/Installation/web-installer/how-to-install.md @@ -82,8 +82,6 @@ The steps below show how to install Essential Studio& * Check the **Create Desktop Shortcut** checkbox to add a desktop shortcut for Syncfusion® Control Panel * Check the **Create Start Menu Shortcut** checkbox to add a shortcut to the start menu for Syncfusion® Control Panel - - 8. After reading the License Terms and Conditions, check the **I agree to the License Terms and Privacy Policy** check box. Click the Next button. 9. The login wizard will appear. You must enter your Syncfusion® email address and password. If you do not already have a Syncfusion® account, you can create one by clicking on **Create an Account**. If you have forgotten your password, click **Forgot Password** to create a new one. Click the Install button. diff --git a/java-file-formats/Licensing/how-to-generate.md b/java-file-formats/Licensing/how-to-generate.md index 8c120e6..fe4e2b8 100644 --- a/java-file-formats/Licensing/how-to-generate.md +++ b/java-file-formats/Licensing/how-to-generate.md @@ -1,36 +1,36 @@ --- layout: post title: Overview of Syncfusion license generation - Syncfusion -description: Learn here about how to generate Syncfusion FileFormat license key for syncfusion FileForamt application for license validation. +description: Learn here about how to generate Syncfusion FileFormat license key for Syncfusion FileFormat application for license validation. platform: java-file-formats control: Essential Studio documentation: ug --- -# Generate Syncfusion® FileFormat License key +# Generate Syncfusion® FileFormat License Key -License keys for Java can be generated from the [License & Downloads](https://syncfusion.com/account/downloads) or [Trial & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) section from your Syncfusion account. +License keys for Java can be generated from the [License & Downloads](https://syncfusion.com/account/downloads) or [Trial & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) section of your Syncfusion account. ![Get License Key](licensing-images/generate-license.png) I> * Syncfusion® license keys are **version and platform-specific**. For example, you must generate separate keys for the front-end (JavaScript) and server-side (Java). Refer to this [KB](https://www.syncfusion.com/kb/8976/how-to-generate-license-key-for-licensed-products) to generate the license key for the required version and platform. -* Refer this [KB](https://www.syncfusion.com/kb/8951/which-version-syncfusion-license-key-should-i-use-in-my-application) to know about which version of the Syncfusion® license key should be used in the application. +* Refer to this [KB](https://www.syncfusion.com/kb/8951/which-version-syncfusion-license-key-should-i-use-in-my-application) to learn which version of the Syncfusion® license key should be used in the application. -## Claim License key +## Claim License Key Syncfusion® License keys can also be generated from the **"Claim License Key"** page based on the trial or valid license associated with your Syncfusion® account. -You can get the license key, based on license availability in your Syncfusion® account. +You can obtain the license key based on license availability in your Syncfusion® account. ### Active License -If you have a Syncfusion® account associated with valid license, license key will be generated from claim license key page. +If you have a Syncfusion® account associated with a valid license, the license key will be generated from the "Claim License Key" page. ![Active License](licensing-images/active-license.png) ### Active Trial -If you have a Syncfusion® account associated with valid trial license, license key will be generated from claim license key page with expiry date. +If you have a Syncfusion® account associated with a valid trial license, the license key will be generated from the "Claim License Key" page with an expiry date. ![Active Trial](licensing-images/active-trial.png) @@ -40,9 +40,9 @@ If you have a Syncfusion® account with an e ![Expired License](licensing-images/expired-license.png) -### No Trial or No License or Expired trial +### No Trial, No License, or Expired Trial -If the Syncfusion® account is not associated with a trial, license, or expired trial, you can try to claim either a trial or a valid license from claim license page. +If the Syncfusion® account is not associated with a trial, license, or expired trial, you can try to claim either a trial or a valid license from the "Claim License" page. ![No Trial or No License](licensing-images/no-active-trial-or-license.png) diff --git a/java-file-formats/Licensing/how-to-register-in-an-application.md b/java-file-formats/Licensing/how-to-register-in-an-application.md index 587050d..3e7afe5 100644 --- a/java-file-formats/Licensing/how-to-register-in-an-application.md +++ b/java-file-formats/Licensing/how-to-register-in-an-application.md @@ -1,13 +1,13 @@ --- layout: post title: Overview of Syncfusion license registration - Syncfusion -description: Learn here about how to register Syncfusion FileForamt license key for FileForamt application for license validation. +description: Learn here about how to register Syncfusion FileFormat license key for FileFormat application for license validation. platform: java-file-formats control: Essential Studio documentation: ug --- -# Register Syncfusion® License key in FileForamt application +# Register Syncfusion® License Key in FileFormat Application The generated license key is just a string that needs to be registered before any Syncfusion® control is initiated. The following code is used to register the license. @@ -17,25 +17,25 @@ Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY {% endhighlight %} {% endtabs %} -N> * Place the license key between double quotes. Also, ensure that Syncfusion.Licensing.dll is referenced in your project where the license key is being registered. -* Syncfusion® license validation is done offline during application execution and does not require internet access. Apps registered with a Syncfusion® license key can be deployed on any system that does not have an internet connection. +N> * Place the license key between double quotes. Also, ensure that Syncfusion.Licensing.dll is referenced in your project where the license key is being registered. +* Syncfusion® license validation is done offline during application execution and does not require internet access. Apps registered with a Syncfusion® license key can be deployed on any system that does not have an internet connection. ### Java -Recommended place to register the license for Java platform is given below. +The recommended place to register the license for the Java platform is given below. -Import ‘syncfusion.licensing' package and register the license key in the **main method** of your console application. +Import the ‘syncfusion.licensing’ package and register the license key in the **main method** of your console application. {% tabs %} -{% highlight JAVA %} -// Refer the licensing package +{% highlight java %} +// Refer to the licensing package import com.syncfusion.licensing.*; static void main() { -// Register Syncfusion license -SyncfusionLicenseProvider.registerLicense("YOUR LICENSE KEY"); + // Register Syncfusion license + SyncfusionLicenseProvider.registerLicense("YOUR LICENSE KEY"); } {% endhighlight %} {% endtabs %} -N> License key registration is not required for Java before v19.1. \ No newline at end of file +N> License key registration is not required for Java versions prior to v19.1. \ No newline at end of file diff --git a/java-file-formats/Licensing/licensing-errors.md b/java-file-formats/Licensing/licensing-errors.md index 03ee650..659155c 100644 --- a/java-file-formats/Licensing/licensing-errors.md +++ b/java-file-formats/Licensing/licensing-errors.md @@ -1,7 +1,7 @@ --- layout: post title: Overview of Syncfusion licensing errors - Syncfusion -description: Learn here about Syncfusion common licensing errors which appears on license validation in Syncfusion FileFormat applications. +description: Learn here about Syncfusion common licensing errors which appear during license validation in Syncfusion FileFormat applications. platform: java-file-formats control: Essential Studio documentation: ug @@ -9,59 +9,59 @@ documentation: ug # Syncfusion® Licensing Errors -Licensing error popup is displayed with various messages under different circumstances. Here are some ways to resolve different issues. +A licensing error popup is displayed with various messages under different circumstances. Here are some ways to resolve different issues. -## Licensing errors +## Licensing Errors -### License key not registered\Trial Expired +### License Key Not Registered/Trial Expired The following error message will be shown if a Syncfusion® license key has not been registered in your application or if the trial key has expired after 30 days. -**Error message :** This application was built using a trial version of Syncfusion® Essential Studio®. You should include the valid license key to remove the license validation message permanently. +**Error Message:** This application was built using a trial version of Syncfusion® Essential Studio®. You should include the valid license key to remove the license validation message permanently. **Solution:** -* Generate a valid license key from here [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform or License keys can also be generated from the Claim License Key page by clicking the **"Claim License"** button from Syncfusion® licensing warning message. Refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate#Claim-License-Key) for more details. +* Generate a valid license key from here: [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. License keys can also be generated from the Claim License Key page by clicking the **"Claim License"** button from the Syncfusion® licensing warning message. Refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate#Claim-License-Key) for more details. * In your application, register the generated license key. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) for information on registering the license key. -### Invalid key +### Invalid Key -If the application is registered with an invalid key, another version of license key, or another platform's license key, the following error message will pop up when launching the application. +If the application is registered with an invalid key, another version of a license key, or another platform's license key, the following error message will pop up when launching the application. **Error Message:** The included Syncfusion® license key is invalid. **Solution:** -* Generate a valid license key from here [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform or License keys can also be generated from the Claim License Key page by clicking the **"Claim License"** button from Syncfusion® licensing warning message. Refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate#Claim-License-Key) for more details. +* Generate a valid license key from here: [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. License keys can also be generated from the Claim License Key page by clicking the **"Claim License"** button from the Syncfusion® licensing warning message. Refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate#Claim-License-Key) for more details. * In your application, register the generated license key. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) for information on registering the license key. -## Licensing errors from version 16.2.0* to 20.3.0* +## Licensing Errors from Version 16.2.0* to 20.3.0* -### License key not registered +### License Key Not Registered The following error message will be shown if a Syncfusion® license key has not been registered in your application. -**Error message:** This application was built using a trial version of Syncfusion® Essential Studio®. Please include a valid license to permanently remove this license validation message. You can also obtain a free 30 day evaluation license to temporarily remove this message during the evaluation period. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#license-key-not-registered) for more information. +**Error Message:** This application was built using a trial version of Syncfusion® Essential Studio®. Please include a valid license to permanently remove this license validation message. You can also obtain a free 30-day evaluation license to temporarily remove this message during the evaluation period. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#license-key-not-registered) for more information. **Solution:** -* Generate a valid license key from here [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. +* Generate a valid license key from here: [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. * In your application, register the generated license key. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) for information on registering the license key. -### Invalid key +### Invalid Key -If the application is registered with an invalid key, another version of license key, or another platform's license key, the following error message will pop up when launching the application. +If the application is registered with an invalid key, another version of a license key, or another platform's license key, the following error message will pop up when launching the application. -This error message will be shown if the license key is invalid. It is possible that the key is for another platform or for an older version. +**Error Message:** The included Syncfusion® license key is invalid. -**Error Message:** The included Syncfusion® license is invalid. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#invalid-key) for more information. + **Solution:** -* Generate a valid license key from here [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. +* Generate a valid license key from here: [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. * In your application, register the generated license key. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) for information on registering the license key. @@ -77,11 +77,11 @@ The following error message will be shown if the trial key has expired after 30 If the application is registered with another platform's license key, the following error message will pop up when launching the application. -**Error Message:**The included Syncfusion® license is invalid (Platform mismatch). Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#platform-mismatch) for more information. +**Error Message:** The included Syncfusion® license is invalid (Platform mismatch). Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#platform-mismatch) for more information. **Solution:** -* Generate a valid license key from here [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. +* Generate a valid license key from here: [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. * In your application, register the generated license key. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) for information on registering the license key. @@ -89,32 +89,24 @@ If the application is registered with another platform's license key, the follow If the application is registered with another version's license key, the following error message will pop up when launching the application. -**Error Message:**The included Syncfusion® license ({Registered Version}) is invalid for version {Required version}. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#version-mismatch) for more information. +**Error Message:** The included Syncfusion® license ({Registered Version}) is invalid for version {Required version}. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/licensing-errors#version-mismatch) for more information. **Solution:** -* Generate a valid license key from here [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. Kindly follow the [KB](https://www.syncfusion.com/kb/8976/how-to-generate-license-key-for-licensed-products) to generate license key. +* Generate a valid license key from here: [Licensed users](https://www.syncfusion.com/account/downloads) or [Trial users](https://www.syncfusion.com/account/manage-trials/downloads) for a specific version and platform. Kindly follow the [KB](https://www.syncfusion.com/kb/8976/how-to-generate-license-key-for-licensed-products) to generate a license key. * In your application, register the generated license key. Please refer to this [help topic](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) for information on registering the license key. -### Could not load Syncfusion.Licensing.dll assembly version...? +### Could Not Load Syncfusion.Licensing.dll Assembly Version...? -Please ensure that all Syncfusion® NuGet packages including [Syncfusion.Licensing](https://www.nuget.org/packages/Syncfusion.Licensing) were installed properly, and assembly references are upgraded to the required version. Also, verify that the csproj and packages.config/web.config files references have been referred with the updated version. +Please ensure that all Syncfusion® NuGet packages, including [Syncfusion.Licensing](https://www.nuget.org/packages/Syncfusion.Licensing), were installed properly, and assembly references are upgraded to the required version. Also, verify that the csproj and packages.config/web.config file references have been updated to the required version. -To avoid run-time errors, set copy local to true. Copy Local determines whether a reference is copied to the project output path. +To avoid runtime errors, set Copy Local to true. Copy Local determines whether a reference is copied to the project output path. ![Set copy local to true](licensing-images/SetCopyLocalTrue.png) -Set “CopyLocal” as True for Syncfusion.Licensing.dll along with all other Syncfusion® assemblies and ensure that the Syncfusion.Licensing.dll assembly is also present in the output folder or deployment folder of the application. +Set "CopyLocal" as True for Syncfusion.Licensing.dll along with all other Syncfusion® assemblies and ensure that the Syncfusion.Licensing.dll assembly is also present in the output folder or deployment folder of the application. ![Output folder](licensing-images/OutputFolder.png) -Refer to this knowledge base articles to set [copy local](https://www.syncfusion.com/kb/4808/how-to-resolve-server-error-could-not-load-or-assembly-when-publishing-an-application) as true. - - - - - - - - +Refer to this knowledge base article to set [Copy Local](https://www.syncfusion.com/kb/4808/how-to-resolve-server-error-could-not-load-or-assembly-when-publishing-an-application) as true. \ No newline at end of file diff --git a/java-file-formats/Licensing/overview.md b/java-file-formats/Licensing/overview.md index 99a1210..36ccd9f 100644 --- a/java-file-formats/Licensing/overview.md +++ b/java-file-formats/Licensing/overview.md @@ -1,7 +1,7 @@ --- layout: post -title: Overview of Syncfusion license and unlock keys - Syncfusion -description: Learn here about the Syncfusion license and unlock keys and difference between license and unlock keys. +title: Overview of Syncfusion License and Unlock Keys - Syncfusion +description: Learn about the Syncfusion license and unlock keys, along with the difference between the license and unlock keys. platform: java-file-formats control: Essential Studio documentation: ug @@ -10,27 +10,27 @@ documentation: ug # Syncfusion® Licensing Overview -Starting from v19.1.0.x, if you reference Syncfusion® Java packages from trial installer or from [maven repository](https://jars.syncfusion.com) you must also include the Java platforms license key in your projects for the corresponding version. +Starting from v19.1.0.x, if you reference Syncfusion® Java packages from the trial installer or the [Maven repository](https://jars.syncfusion.com), you must also include the Java platform's license key in your projects for the corresponding version. -## Difference between unlock key and license key +## Difference Between Unlock Key and License Key -Please note that this license key is different from the installer unlock key that you might have used in the past and needs to be separately generated from Syncfusion website. Refer [this](https://www.syncfusion.com/kb/8950/difference-between-the-unlock-key-and-licensing-key) KB article to know more about difference between the Syncfusion® Unlock Key and the Syncfusion® License Key. +Please note that this license key is different from the installer unlock key that you might have used in the past and needs to be separately generated from the Syncfusion website. Refer to [this](https://www.syncfusion.com/kb/8950/difference-between-the-unlock-key-and-licensing-key) KB article to learn more about the difference between the Syncfusion® Unlock Key and the Syncfusion® License Key. -Trial message will be displayed as watermark in the generated documents, if Java packages referred from trial installer or from [maven repository](https://jars.syncfusion.com) +A trial message will be displayed as a watermark in the generated documents if Java packages are referenced from the trial installer or the [Maven repository](https://jars.syncfusion.com). **Example** ![IO Licensing Message](licensing-images/io-licensing-message.png) -## Registering Syncfusion® license keys in Build server +## Registering Syncfusion® License Keys in Build Server -| Source of Syncfusion® assemblies | Details | License Key needs to be registered? | Where to get license key from | +| Source of Syncfusion® Assemblies | Details | License Key Needs to Be Registered? | Where to Get License Key From | | ------------- | ------------- | ------------- | ------------- | -| **NuGet package** | If the Syncfusion® assemblies used in Build Server were from the Syncfusion® NuGet packages, then no need to install any Syncfusion® installer. We can directly use the required Syncfusion® NuGet packages at [nuget.org](http://nuget.org/).

But, if using NuGet packages from the [nuget.org](https://www.nuget.org/packages?q=syncfusion), then we should register the Syncfusion® license key in the application.| Yes | Use any developer license to [generate](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) keys for Build Environments as well. | -| **Trial installer** | If the Syncfusion® assemblies used in Build Server were from Trial Installer, we should register the license key in the application for the corresponding version and platforms, to avoid trial license warning. | Yes | Use any developer trial license to [generate](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) keys for Build Environments as well. | -| **Licensed installer** |If the Syncfusion® assemblies used in Build Server were from Licensed Installer, then there is no need to register the license keys.

You can [download](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-download#download-the-license-version) and [install](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-install) the licensed version of our installer. | No | Not applicable | +| **NuGet Package** | If the Syncfusion® assemblies used in the Build Server were from the Syncfusion® NuGet packages, there is no need to install any Syncfusion® installer. We can directly use the required Syncfusion® NuGet packages from [nuget.org](http://nuget.org).

However, if using NuGet packages from [nuget.org](https://www.nuget.org/packages?q=syncfusion), then we should register the Syncfusion® license key in the application. | Yes | Use any developer license to [generate](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) keys for Build Environments as well. | +| **Trial Installer** | If the Syncfusion® assemblies used in the Build Server were from the Trial Installer, we should register the license key in the application for the corresponding version and platforms to avoid a trial license warning. | Yes | Use any developer trial license to [generate](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) keys for Build Environments as well. | +| **Licensed Installer** | If the Syncfusion® assemblies used in the Build Server were from the Licensed Installer, then there is no need to register the license keys.

You can [download](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-download#download-the-license-version) and [install](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-install) the licensed version of our installer. | No | Not applicable | ## See Also * [How to Generate Syncfusion® FileFormats License Key?](https://help.syncfusion.com/java-file-formats/licensing/how-to-generate) -* [How to Register Syncfusion® License Key in FileFormats Application?](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) +* [How to Register Syncfusion® License Key in FileFormats Application?](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) \ No newline at end of file diff --git a/java-file-formats/System-Requirements.md b/java-file-formats/System-Requirements.md index 6da9d96..b14f23d 100644 --- a/java-file-formats/System-Requirements.md +++ b/java-file-formats/System-Requirements.md @@ -1,7 +1,7 @@ --- layout: post title: System Requirements in FileFormats - Syncfusion -description: Checkout and learn here all about the system requirements needed to use Syncfusion FileFormats Components. +description: Check out and learn here all about the system requirements needed to use Syncfusion FileFormats Components. platform: java-file-formats control: System Requirements documentation: ug @@ -9,18 +9,18 @@ documentation: ug --- # System Requirements for FileFormats Components -The system requirements for using our Syncfusion® FileFormats platform are as follows +The system requirements for using our Syncfusion® FileFormats platform are as follows: ### Operating Systems #### Windows * Windows 10 (x86, x64). -* Windows 8, 8.1(x86, x64). -* Windows 7 SP1(x86, x64). -* Windows Vista SP2(x86, x64). +* Windows 8, 8.1 (x86, x64). +* Windows 7 SP1 (x86, x64). +* Windows Vista SP2 (x86, x64). * Windows Server 2019 (x64). -* Windows Server 2016(x64). +* Windows Server 2016 (x64). * Windows Server 2012 R2 (x64). * Windows Server 2012 (x64). * Windows Server 2008 R2 SP1 (x64). @@ -31,18 +31,17 @@ The system requirements for using our Syncfusion® #### Linux -* Ubuntu Linux 12.04 LTS and later (x64, x82). -* Suse Linux Enterprise Server 10 SP2 and later (x64, x82). -* Red Hat Enterprise Linux 5.5 and later (x64, x82). -* Oracle Linus 5.5 and later (x64, x82). +* Ubuntu Linux 12.04 LTS and later (x64, x86). +* SUSE Linux Enterprise Server 10 SP2 and later (x64, x86). +* Red Hat Enterprise Linux 5.5 and later (x64, x86). +* Oracle Linux 5.5 and later (x64, x86). ### Hardware Environment -* Processor: x86 or x64 -* RAM: 512 MB (minimum), 1 GB (recommended) -* Hard disk: up to 8.5 GB of available space may be required. However, 750 MB free space is required in boot drive even if you are installing in other drive. +* Processor: x86 or x64. +* RAM: 512 MB (minimum), 1 GB (recommended). +* Hard disk: Up to 8.5 GB of available space may be required. However, 750 MB of free space is required on the boot drive even if you are installing on another drive. -### Supported Java versions - -Syncfusion® Java libraries supports Java SE 8.0(1.8) or above versions. +### Supported Java Versions +Syncfusion® Java libraries support Java SE 8.0 (1.8) or above versions. \ No newline at end of file diff --git a/java-file-formats/Upgrade/how-to-upgrade.md b/java-file-formats/Upgrade/how-to-upgrade.md index 6240382..eea28e8 100644 --- a/java-file-formats/Upgrade/how-to-upgrade.md +++ b/java-file-formats/Upgrade/how-to-upgrade.md @@ -1,7 +1,7 @@ --- layout: post -title: Upgrading Syncfusion FileFormats installer to a latest version -description: Learn here about the how upgrade Syncfusion FileFormats installer to a latest version from website and control panel. +title: Upgrading Syncfusion FileFormats Installer to the Latest Version +description: Learn here how to upgrade the Syncfusion FileFormats Installer to the latest version from the website and control panel. platform: java-file-formats control: Essential Studio documentation: ug @@ -9,31 +9,29 @@ documentation: ug # Upgrading Syncfusion® FileFormats -Syncfusion® releases new volumes once every three months, with exciting new features. There will be one Service Pack release for these volume releases. Service Pack releases are provided to address major bug fixes in the volume releases. +Syncfusion® releases new volumes once every three months, with exciting new features. There is one Service Pack release for these volume releases. Service Pack releases are provided to address major bug fixes in the volume releases. You can upgrade to our latest version from any installed Syncfusion® version. -See our **Upgrade Guide** for [PDF](https://help.syncfusion.com/upgrade-guide/file-formats/PDF),[XlsIO](https://help.syncfusion.com/upgrade-guide/file-formats/xlsio), [Presentation](https://help.syncfusion.com/upgrade-guide/file-formats/presentation) and [DocIO](https://help.syncfusion.com/upgrade-guide/file-formats/docio) FileFormats controls to learn more about the “Breaking Changes, Bug Fixes, Features and Knows Issues” between your current version and the latest version you are trying to upgrade. +See our **Upgrade Guide** for [PDF](https://help.syncfusion.com/upgrade-guide/file-formats/PDF), [XlsIO](https://help.syncfusion.com/upgrade-guide/file-formats/xlsio), [Presentation](https://help.syncfusion.com/upgrade-guide/file-formats/presentation), and [DocIO](https://help.syncfusion.com/upgrade-guide/file-formats/docio) FileFormats controls to learn more about the “Breaking Changes, Bug Fixes, Features, and Known Issues” between your current version and the latest version you are trying to upgrade. -## Upgrading to the latest version +## Upgrading to the Latest Version The most recent version of Syncfusion® FileFormats can be downloaded and installed by clicking on the "Latest Version: {Version}" link at the top of the Syncfusion® FileFormats Control Panel. ![Control Panel](Upgrade-images/upgrade-control-panel.png) -You can also upgrade to the latest version just by downloading and installing the products you require from [this](https://www.syncfusion.com/downloads/latest-version) link. The existing installed versions are not required to be uninstalled. +You can also upgrade to the latest version simply by downloading and installing the products you require from [this](https://www.syncfusion.com/downloads/latest-version) link. The existing installed versions do not need to be uninstalled. +It is not necessary to install the Volume release before installing the Service Pack release. As releases for Volume and Service Packs work independently, you can install the latest version with major bug fixes directly. -It is not required to install the Volume release before installing the Service Pack release. As releases for Volume and Service Packs work independently, you can install the latest version with major bug fixes directly. +## Upgrade from Trial Version to Licensed Version +To upgrade from the trial version, there are two possible solutions: -## Upgrade from trial version to license version +* Uninstall the trial version and install the fully licensed build from the [License & Downloads](https://www.syncfusion.com/account/downloads) section of our website. +* If you are using Syncfusion® controls from the [Maven repository](https://jars.syncfusion.com), replace the currently used trial license key with a paid license key that can be generated from the [License & Downloads](https://www.syncfusion.com/account/downloads) section of our website. Refer to [this](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) topic for more information regarding registering the license in the application. -To upgrade from trial version, there are two possible solutions. - -* Uninstall the trial version and install the fully licensed build from the [License & Downloads](https://www.syncfusion.com/account/downloads) section of our website. -* If you are using Syncfusion® controls from [maven repository](https://jars.syncfusion.com), replace the currently used trial license key with a paid license key that can be generated from the [License & Downloads](https://www.syncfusion.com/account/downloads) section of our website. Refer to [this](https://help.syncfusion.com/java-file-formats/licensing/how-to-register-in-an-application) topic for more information regarding registering the license in the application. - -N> License registration is not required if you reference Syncfusion® Java packages from Licensed installer. These licensing changes applicable to all evaluators who refers the Syncfusion® Java packages from evaluation installer and those who use Syncfusion® controls from [maven repository](https://jars.syncfusion.com). +N> License registration is not required if you reference Syncfusion® Java packages from a licensed installer. These licensing changes are applicable to all evaluators who refer to the Syncfusion® Java packages from the evaluation installer and those who use Syncfusion® controls from the [Maven repository](https://jars.syncfusion.com). diff --git a/java-file-formats/introduction.md b/java-file-formats/introduction.md index 37a4ad8..8392e1f 100644 --- a/java-file-formats/introduction.md +++ b/java-file-formats/introduction.md @@ -13,14 +13,14 @@ Essential® File Formats for Java includes a ## How to best read this user guide -* The best way to get started would be to read the “Getting Started” section for the component you would like to start first. The “Getting Started” section gives enough information, so it is recommended to read this section end-to-end before starting to write a code. All other information can be referred as needed. +* The best way to get started would be to read the “Getting Started” section for the component you would like to start with first. The “Getting Started” section provides enough information, so it is recommended to read this section end-to-end before starting to write code. All other information can be referred to as needed. * After learning the basics about the component, integrate the component into your application. A good starting point is to refer to the code examples in the sample browser and in this user guide. It is very likely that you can find a code example that resembles your intended usage scenario. ## Additional help resources -The [Knowledge Base](https://support.syncfusion.com/kb) section contains responses for common questions asked by the customers. This would be a good place to search for the topics that are not covered in the User Guide. +The [Knowledge Base](https://support.syncfusion.com/kb) section contains responses to common questions asked by customers. This would be a good place to search for topics that are not covered in the User Guide. -Similar to the Knowledge Base, the [Forum](https://www.syncfusion.com/forums/) section also contains responses to the questions that are asked by other customers. +Similar to the Knowledge Base, the [Forum](https://www.syncfusion.com/forums/) section also contains responses to questions that are asked by other customers. ## Create a support incident @@ -49,4 +49,4 @@ Java class library used to create, read, edit, and convert Microsoft Word files ## Quick Start links: -[Create Word file in Java without Microsoft Office](https://help.syncfusion.com/java-file-formats/word-library/getting-started) +[Create Word file in Java without Microsoft Office](https://help.syncfusion.com/java-file-formats/word-library/getting-started) \ No newline at end of file diff --git a/java-file-formats/word-library/Installation/Installation-errors.md b/java-file-formats/word-library/Installation/Installation-errors.md index 8b4ebce..8c6c623 100644 --- a/java-file-formats/word-library/Installation/Installation-errors.md +++ b/java-file-formats/word-library/Installation/Installation-errors.md @@ -1,7 +1,7 @@ --- layout: post title: Installation Errors in FileFormats - Syncfusion -description: Learn here about the common installation errors and solution to those errors in Syncfusion FileFormats Components installation. +description: Learn here about the common installation errors and solutions to those errors in Syncfusion FileFormats Components installation. platform: java-file-formats control: Installation and Deployment documentation: ug @@ -29,18 +29,18 @@ This article describes the most common installation errors, as well as the cause ### Reason -You are attempting to use a Trial unlock key to unlock the licensed installer. +You are attempting to use a trial unlock key to unlock the licensed installer. -### Suggested solution +### Suggested Solution -Only a licensed unlock key can unlock a licensed installer. So, to unlock the Licensed installer, use the Licensed unlock key. To generate the licensed unlock key, refer to [this](http://syncfusion.com/kb/2326) article. +Only a licensed unlock key can unlock a licensed installer. So, to unlock the licensed installer, use the licensed unlock key. To generate the licensed unlock key, refer to [this](http://syncfusion.com/kb/2326) article. ## License has expired ### Problem -**Error Message:** Your license for Syncfusion® Essential Studio® for FileFormats has been expired since {date}. Please renew your subscription and try again. +**Error Message:** Your license for Syncfusion® Essential Studio® for FileFormats has expired since {date}. Please renew your subscription and try again. **Online Installer** @@ -50,26 +50,27 @@ Only a licensed unlock key can unlock a licensed installer. So, to unlock the Li This error message will appear if your license has expired. -### Suggested solution +### Suggested Solution -You can choose from the options listed below. +You can choose from the options listed below: 1. You can renew your subscription [here](https://www.syncfusion.com/account/my-renewals). 2. You can get a new license [here](https://www.syncfusion.com/sales/products). 3. You can reach out to our sales team by emailing . 4. You can also extend the 30-day trial period after your license has expired. + ## Unable to find a valid license or trial ### Problem **Error Message:** Sorry, we are unable to find a valid license or trial for Essential Studio® for FileFormats under your account. -**Offline installer** +**Offline Installer** ![Alert Message](Errors/Installation_Errors_img3.png) -**Online installer** +**Online Installer** ![Warning Message](Errors/Installation_Errors_img6.png) @@ -82,52 +83,54 @@ The following are possible causes of this error: * You are not the license holder of your license * Your account administrator has not yet assigned you a license. -### Suggested solution +### Suggested Solution -You can choose from the options listed below. +You can choose from the options listed below: 1. You can get a new license [here](https://www.syncfusion.com/sales/products). 2. Contact your account administrator. -3. Send an email to to request a license. -4. You can reach out to our sales team by emailing . +3. Send an email to to request a license. +4. You can reach out to our sales team by emailing . + ## Unable to install because of another installation ### Problem -**Error Message:** Another installation is in progress. You cannot start this installation without completing all other currently active installations. Click cancel to end this installer or retry to attempt after currently active installation completed to install again. +**Error Message:** Another installation is in progress. You cannot start this installation without completing all other currently active installations. Click cancel to end this installer or retry to attempt after the currently active installation is completed. ![Warning Message](Errors/Installation_Errors_img4.png) ### Reason -You are trying to install when another installation is already running in your machine. +You are trying to install when another installation is already running on your machine. -### Suggested solution +### Suggested Solution -Open and kill the msiexec process in the task manager and then continue to install Syncfusion®. If the problem is still present, restart the computer and try Syncfusion® installer. +Open and kill the msiexec process in the Task Manager and then continue to install Syncfusion®. If the problem persists, restart the computer and try running the Syncfusion® installer again. 1. Open the Windows Task Manager. 2. Browse the Details tab. -3. Select the msiexec.exe and click **End task**. +3. Select the msiexec.exe and click **End Task**. ![Task Manager](Errors/Installation_Errors_img5.png) + ## Unable to install due to controlled folder access ### Problem #### Offline: -**Error Message:** Controlled folder access seems to be enabled in your machine. The provided install or samples location (e.g., Public Documents) is protected by the controlled folder access settings. +**Error Message:** Controlled folder access seems to be enabled on your machine. The provided install or samples location (e.g., Public Documents) is protected by the controlled folder access settings. ![Warning Message](Errors/Installation_Errors_img7.png) #### Online: -**Error Message:** Controlled folder access seems to be enabled in your machine. The provided install, samples, or download location (e.g., Public Documents) is protected by the controlled folder access settings. +**Error Message:** Controlled folder access seems to be enabled on your machine. The provided install, samples, or download location (e.g., Public Documents) is protected by the controlled folder access settings. ![Warning Message](Errors/Installation_Errors_img8.png) @@ -135,14 +138,14 @@ Open and kill the msiexec process in the task manager and then continue to insta You have enabled controlled folder access settings on your computer. -### Suggested solution +### Suggested Solution **Suggestion 1:** -1. We will ship our demos in the public documents folder by default. -2. You have controlled folder access enabled on your machine, so our demos cannot be installed in the documents folder. If you need to install our demos in the Documents folder, follow the steps in this [link](https://support.microsoft.com/en-us/windows/allow-an-app-to-access-controlled-folders-b5b6627a-b008-2ca2-7931-7e51e912b034) and disable the controlled folder access. -3. You can enable this option after the installing our Syncfusion® setup. +1. We will ship our demos in the Public Documents folder by default. +2. You have controlled folder access enabled on your machine, so our demos cannot be installed in the Documents folder. If you need to install our demos in the Documents folder, follow the steps in this [link](https://support.microsoft.com/en-us/windows/allow-an-app-to-access-controlled-folders-b5b6627a-b008-2ca2-7931-7e51e912b034) and disable the controlled folder access. +3. You can enable this option again after installing our Syncfusion® setup. **Suggestion 2:** -1. If you do not want to disable controlled folder access, you can install our demos in another directory. +1. If you do not want to disable controlled folder access, you can install our demos in another directory. \ No newline at end of file diff --git a/java-file-formats/word-library/Installation/available-syncfusion-java-packages.md b/java-file-formats/word-library/Installation/available-syncfusion-java-packages.md index 6181bb8..6508c2f 100644 --- a/java-file-formats/word-library/Installation/available-syncfusion-java-packages.md +++ b/java-file-formats/word-library/Installation/available-syncfusion-java-packages.md @@ -1,6 +1,6 @@ --- title: Available Syncfusion Java packages | Syncfusion -description: This section demonstrates the Java packages (Jar files) available in Syncfusion (Syncfusion Jars for Java) +description: This section demonstrates the Java packages (JAR files) available in Syncfusion (Syncfusion JARs for Java) platform: java-file-formats control: general documentation: UG @@ -8,12 +8,12 @@ documentation: UG # Available Syncfusion® Java packages -Below are the Java packages available in syncfusion®. +Below are the Java packages available in Syncfusion®. - + @@ -21,14 +21,14 @@ Below are the Java packages available in syncfusion&r +This JAR contains the core features needed for creating, reading, and editing a Word document programmatically.

+This JAR contains common functionalities required for the Syncfusion® file format libraries.

+This JAR is used for converting Word documents into Syncfusion® Document Text (*.SFDT) format documents.

Jar files

JAR files

Short description

syncfusion-docio

-This jar contains the core features needed for creating, reading, and editing a Word document programmatically.

syncfusion-javahelper

-This jar contains common functionalities required for the syncfusion® file format libraries.

syncfusion-ej2-wordprocessor

-This jar used for converting Word documents into Syncfusion® Document Text (*.SFDT) format documents.

\ No newline at end of file diff --git a/java-file-formats/word-library/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md b/java-file-formats/word-library/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md index 31ae573..442e7e8 100644 --- a/java-file-formats/word-library/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md +++ b/java-file-formats/word-library/Installation/configure-to-download-syncfusion-java-packages-from-apache-maven.md @@ -1,13 +1,13 @@ --- title: Download Syncfusion Java packages from Apache Maven | Syncfusion -description: This section demonstrates how to configure and download required Jars from Apache Maven (Jar configuration) +description: This section demonstrates how to configure and download required JARs from Apache Maven (JAR configuration) platform: java-file-formats control: general documentation: UG --- # Configure to download Syncfusion® Java packages from Apache Maven -You can easily download the Syncfusion® packages for Java using the [maven repository](https://jars.syncfusion.com/). +You can easily download the Syncfusion® packages for Java using the [Maven repository](https://jars.syncfusion.com/). The following command shows how to mention the repository in Apache Maven. @@ -35,4 +35,4 @@ The following command shows how to refer to the Syncfusion® Java packages from Gradle -You can easily download the Syncfusion® packages for Java using the [maven repository](https://jars.syncfusion.com/). +You can easily download the Syncfusion® packages for Java using the [Maven repository](https://jars.syncfusion.com/). The following command shows how to mention the repository in Gradle. @@ -29,9 +29,9 @@ The following command shows how to refer to the Syncfusion® FileFormats offline installer +# Downloading Syncfusion® FileFormats Offline Installer -[DocIO](https://www.syncfusion.com/word-framework/net),[PDF](https://www.syncfusion.com/pdf-framework/net),[Presentation](https://www.syncfusion.com/powerpoint-framework/net), and [XlsIO](https://www.syncfusion.com/excel-framework/net) controls will be included in the Syncfusion® FileFormats installer. You can either download the licensed installer or try our trial installer depending on your license. +[DocIO](https://www.syncfusion.com/word-framework/net), [PDF](https://www.syncfusion.com/pdf-framework/net), [Presentation](https://www.syncfusion.com/powerpoint-framework/net), and [XlsIO](https://www.syncfusion.com/excel-framework/net) controls are included in the Syncfusion® FileFormats installer. You can either download the licensed installer or try our trial installer depending on your license. - - Trial Installer - - Licensed Installer + - Trial Installer + - Licensed Installer ## Download the Trial Version -Our 30-day trial can be downloaded in two ways. +Our 30-day trial can be downloaded in two ways: * Download Free Trial Setup - * Start Trials if using components through [maven repository](https://jars.syncfusion.com) + * Start Trials if using components through [Maven repository](https://jars.syncfusion.com) ### Download Free Trial Setup -1. You can evaluate our 30-day free trial by visiting the [Download Free Trial](https://www.syncfusion.com/downloads) page and select the FileFormats platform. -2. After completing the required form or logging in with your registered Syncfusion® account, you can download the FileFormats trial installer from the confirmation page. (as shown in below screenshot.) +1. You can evaluate our 30-day free trial by visiting the [Download Free Trial](https://www.syncfusion.com/downloads) page and selecting the FileFormats platform. +2. After completing the required form or logging in with your registered Syncfusion® account, you can download the FileFormats trial installer from the confirmation page (as shown in the screenshot below). + + + ![Trial and downloads of Syncfusion® Essential Studio®](images/trial-confirmation.png) - + 3. With a trial license, only the latest version’s trial installer can be downloaded. -4. After downloading, the Syncfusion® FileFormats trial installer can be unlocked using either the trial unlock key or the Syncfusion® registered login credential. More information on generating an unlock key can be found in [this](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) article. -5. Before the trial expires, you can download the trial installer at any time from your registered account’s [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page (as shown in below screenshot.) - +4. After downloading, the Syncfusion® FileFormats trial installer can be unlocked using either the trial unlock key or the Syncfusion® registered login credentials. More information on generating an unlock key can be found in [this](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) article. +5. Before the trial expires, you can download the trial installer at any time from your registered account’s [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page (as shown in the screenshot below). + ![Trial and downloads of Syncfusion® Essential Studio®](images/trial-download.png) -6. Click the More Download Options (element 2 in the above screenshot) button to get the Essential Studio® FileFormats Offline trial installer which is available in EXE and ZIP format. +6. Click the More Download Options (element 2 in the above screenshot) button to get the Essential Studio® FileFormats Offline Trial Installer, which is available in EXE and ZIP formats. ![License and downloads of Syncfusion® Essential Studio®](images/start-trial-download-offline-installer.png) - -### Start Trials if using components through [maven repository](https://jars.syncfusion.com) + +### Start Trials if Using Components Through [Maven Repository](https://jars.syncfusion.com) 1. You can start your 30-day free trial for FileFormats from the [Start Trial](https://www.syncfusion.com/account/manage-trials/start-trials) page from your account. - + ![Trial and downloads of Syncfusion® Essential Studio®](images/start-trial-download.png) - -2. To access this page, you must sign up\log in with your Syncfusion® account. -3. Begin your trial by selecting the FileFormats product. + +2. To access this page, you must sign up/log in with your Syncfusion® account. +3. Begin your trial by selecting the FileFormats product. N> If you've already used the trial products and they haven't expired, you won't be able to start the trial for the same product again. -4. After you've started the trial, go to the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page to get the latest version trial installer. You can generate the [unlock key](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) and [license key](https://help.syncfusion.com/document-processing/licensing/how-to-generate) here at any time before the trial period expires. (as shown in below screenshot.) +4. After you've started the trial, go to the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page to get the latest version trial installer. You can generate the [unlock key](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) and [license key](https://help.syncfusion.com/document-processing/licensing/how-to-generate) here at any time before the trial period expires (as shown in the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/start-trial-download-installer.png) 5. You can find your current active trial products on the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page. -## Download the License Version +## Download the Licensed Version -1. Syncfusion® licensed products will be available in the [License & Downloads](https://www.syncfusion.com/account/downloads) page under your registered Syncfusion® account. +1. Syncfusion® licensed products are available on the [License & Downloads](https://www.syncfusion.com/account/downloads) page under your registered Syncfusion® account. 2. You can view all the licenses (both active and expired) associated with your account. 3. Click the Download (element 1 in the screenshot below) button to download the respective product’s installer. 4. The most recent version of the installer will be downloaded from this page. 5. To download older version installers, go to [Downloads Older Versions](https://www.syncfusion.com/account/downloads/studio) (element 2 in the screenshot below). -6. You can download other platform\add-on installers by going to More Downloads Options (element 3 in the screenshot below). +6. You can download other platform/add-on installers by going to More Downloads Options (element 3 in the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/license-download.png) - -7. For Windows OS, EXE and Zip formats are available for download. They are both Offline Installers. - + +7. For Windows OS, EXE and ZIP formats are available for download. They are both Offline Installers. + ![License and downloads of Syncfusion® Essential Studio®](images/start-trial-download-offline-installer.png) -You can also refer to the [**Offline installer**](https://help.syncfusion.com/java-file-formats/installation/offline-installer/how-to-install) links for step-by-step installation guidelines. \ No newline at end of file +You can also refer to the [**Offline Installer**](https://help.syncfusion.com/java-file-formats/installation/offline-installer/how-to-install) links for step-by-step installation guidelines. \ No newline at end of file diff --git a/java-file-formats/word-library/Installation/offline-installer/how-to-install.md b/java-file-formats/word-library/Installation/offline-installer/how-to-install.md index dedc0d1..87ff2eb 100644 --- a/java-file-formats/word-library/Installation/offline-installer/how-to-install.md +++ b/java-file-formats/word-library/Installation/offline-installer/how-to-install.md @@ -1,6 +1,6 @@ --- layout: post -title: Installing Syncfusion FileFormats offline installer-Syncfusion +title: Installing Syncfusion FileFormats Offline Installer - Syncfusion description: Learn here about how to install Syncfusion FileFormats offline installer after downloading from our Syncfusion website. platform: java-file-formats control: Installation and Deployment @@ -8,146 +8,162 @@ documentation: ug --- -# Installing Syncfusion® FileFormats offline installer +# Installing Syncfusion® FileFormats Offline Installer ## Installing with UI The steps below show how to install the Essential Studio® FileFormats installer. -1. Open the Syncfusion® FileFormats offline installer file from downloaded location by double-clicking it. The Installer Wizard automatically opens and extracts the package. +1. Open the Syncfusion® FileFormats offline installer file from the downloaded location by double-clicking it. The Installer Wizard automatically opens and extracts the package. ![Installer extraction wizard](images/Step-by-Step-Installation_img1.png) - N> The Installer wizard extracts the syncfusionessentialfileformats_(version).exe dialog, which displays the package's unzip operation. + N> The Installer Wizard extracts the syncfusionessentialfileformats_(version).exe dialog, which displays the package's unzip operation. -2. To unlock the Syncfusion® offline installer, you have two options: +2. To unlock the Syncfusion® offline installer, you have two options: - * *Login To Install* + * *Login to Install* * *Use Unlock Key* + - - **Login To Install** + **Login to Install** You must enter your Syncfusion® email address and password. If you don't already have a Syncfusion® account, you can sign up for one by clicking **"Create an account"**. If you have forgotten your password, click on **"Forgot Password"** to create a new one. Once you've entered your Syncfusion® email and password, click Next. - ![Login credentials](images/Step-by-Step-Installation_img2.png) + ![Login credentials](images/Step-by-Step-Installation_img2.png) + + **Use Unlock Key** + Unlock keys are used to unlock the Syncfusion® offline installer, and they are platform- and version-specific. You should use either a Syncfusion® licensed or trial unlock key to unlock the Syncfusion® FileFormats installer. + The trial unlock key is only valid for 30 days, and the installer will not accept an expired trial key. - **Use Unlock Key** + - Unlock keys are used to unlock the Syncfusion® offline installer, and they are platform and version specific. You should use either Syncfusion® licensed or trial Unlock key to unlock Syncfusion® FileFormats installer. + - The trial unlock key is only valid for 30 days, and the installer will not accept an expired trial key. + To learn how to generate an unlock key for both trial and licensed products, see [this](https://www.syncfusion.com/kb/2326) Knowledge Base article. - ![Product key](images/Step-by-Step-Installation_img3.png) + ![Product key](images/Step-by-Step-Installation_img3.png) +3. After reading the License Terms and Privacy Policy, check the **"I agree to the License Terms and Privacy Policy"** checkbox. Click the Next button. -3. After reading the License Terms and Privacy Policy, check the **“I agree to the License Terms and Privacy Policy”** check box. Click the Next button. +4. Change the install and sample locations here. You can also change the Additional Settings. Click Next\Install to install with the default settings. -4. Change the install and sample locations here. You can also change the Additional settings. Click Next\Install to install with the default settings. + ![Advanced options](images/Step-by-Step-Installation_img4.png) **Additional Settings** - * Select the **Install Demos** check box to install Syncfusion® samples, or leave the check box unchecked, if you do not want to install Syncfusion® samples - * Select the **Register Syncfusion® Assemblies in GAC** check box to install the latest Syncfusion® assemblies in GAC, or clear this check box when you do not want to install the latest assemblies in GAC. - * Select the **Configure Syncfusion® controls in Visual Studio** check box to configure the Syncfusion® controls in the Visual Studio toolbox, or clear this check box when you do not want to configure the Syncfusion® controls in the Visual Studio toolbox during installation. Note that you must also select the Register Syncfusion® assemblies in GAC check box when you select this check box. - * Select the **Configure Syncfusion® Extensions controls in Visual Studio** checkbox to configure the Syncfusion® Extensions in Visual Studio or clear this check box when you do not want to configure the Syncfusion® Extensions in Visual Studio. - * Check the **Create Desktop Shortcut** checkbox to add a desktop shortcut for Syncfusion® Control Panel - * Check the **Create Start Menu Shortcut** checkbox to add a shortcut to the start menu for Syncfusion® Control Panel - - - - -5. If any previous versions of the current product is installed, the Uninstall Previous Version(s) wizard will be opened. Select **Uninstall** checkbox to uninstall the previous versions and then click the Proceed button. + * Select the **Install Demos** checkbox to install Syncfusion® samples, or leave the checkbox unchecked if you do not want to install Syncfusion® samples. + * Select the **Register Syncfusion® Assemblies in GAC** checkbox to install the latest Syncfusion® assemblies in GAC, or clear this checkbox if you do not want to install the latest assemblies in GAC. + * Select the **Configure Syncfusion® controls in Visual Studio** checkbox to configure the Syncfusion® controls in the Visual Studio toolbox, or clear this checkbox if you do not want to configure the Syncfusion® controls in the Visual Studio toolbox during installation. Note that you must also select the Register Syncfusion® assemblies in GAC checkbox when you select this checkbox. + * Select the **Configure Syncfusion® Extensions controls in Visual Studio** checkbox to configure the Syncfusion® Extensions in Visual Studio, or clear this checkbox if you do not want to configure the Syncfusion® Extensions in Visual Studio. + * Check the **Create Desktop Shortcut** checkbox to add a desktop shortcut for the Syncfusion® Control Panel. + * Check the **Create Start Menu Shortcut** checkbox to add a shortcut to the Start menu for the Syncfusion® Control Panel. +5. If any previous versions of the current product are installed, the Uninstall Previous Version(s) wizard will be opened. Select the **Uninstall** checkbox to uninstall the previous versions and then click the Proceed button. ![Advanced options](images/Step-by-Step-Installation_img7.png) - - - N> From the 2021 Volume 1 release, Syncfusion® has added the option to uninstall previous versions from 18.1 while installing the new version. - - - N> If any version is selected to uninstall, a confirmation screen will appear; if continue is selected, the Progress screen will display the uninstall and install progress, respectively. If none of the versions are chosen to be uninstalled, only the installation progress will be displayed. - - **Confirmation Alert** - - ![Confirmation wizard](images/Step-by-Step-Installation_img8.png) - - **Uninstall Progress:** - - ![Uninstalling wizard](images/Step-by-Step-Installation_img9.png) - - **Install Progress** - - ![Installing wizard](images/Step-by-Step-Installation_img5.png) - - N> The Completed screen is displayed once the FileFormats product is installed. If any version is selected to uninstall, The completed screen will display both install and uninstall status. - - ![Completed wizard](images/Step-by-Step-Installation_img10.png) - -7. After installing, click the **Launch Control Panel** link to open the Syncfusion® Control Panel. - - -8. Click the Finish button. Your system has been installed with the Syncfusion® Essential Studio® FileFormats product. - - N> * You can find the required jars in the FileFormats installed location - * **Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\ {Platform}\ {version}\JarFiles + + N> From the 2021 Volume 1 release, Syncfusion® has added the option to uninstall previous versions from 18.1 while installing the new version. + + N> If any version is selected to uninstall, a confirmation screen will appear. If Continue is selected, the Progress screen will display the uninstall and install progress, respectively. If none of the versions are chosen to be uninstalled, only the installation progress will be displayed. + + **Confirmation Alert** + ![Confirmation wizard](images/Step-by-Step-Installation_img8.png) + + **Uninstall Progress** + ![Uninstalling wizard](images/Step-by-Step-Installation_img9.png) + + **Install Progress** + ![Installing wizard](images/Step-by-Step-Installation_img5.png) + + + + + + + + N> The Completed screen is displayed once the FileFormats product is installed. If any version is selected to uninstall, the Completed screen will display both install and uninstall statuses. + + + + + + + + + + + + + + + + ![Completed wizard](images/Step-by-Step-Installation_img10.png) + + + +7. After installing, click the **Launch Control Panel** link to open the Syncfusion® Control Panel. + +8. Click the Finish button. Your system has been installed with the Syncfusion® Essential Studio® FileFormats product. + + N> * You can find the required JARs in the FileFormats installed location. + * **Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\{Platform}\{version}\JarFiles * **Example:** C:\Program Files (x86)\Syncfusion\Essential Studio\FileFormats\19.1.0.54\JarFiles -## Installing in silent mode +## Installing in Silent Mode The Syncfusion® Essential Studio® FileFormats Installer supports installation and uninstallation via the command line. ### Command Line Installation -To install through the Command Line in Silent mode, follow the steps below. +To install through the Command Line in Silent Mode, follow the steps below. -1. Run the Syncfusion® FileFormats installer by double-clicking it. The Installer Wizard automatically opens and extracts the package. -2. The file syncfusionessentialfileformats_(version).exe file will be extracted into the Temp directory. -3. Run %temp%. The Temp folder will be opened. The syncfusionessentialfileformats_(version).exe file will be located in one of the folders. -4. Copy the extracted syncfusionessentialfileformats_(version).exe file in local drive. -5. Exit the Wizard. -6. Run Command Prompt in administrator mode and enter the following arguments. +1. Run the Syncfusion® FileFormats installer by double-clicking it. The Installer Wizard automatically opens and extracts the package. +2. The file syncfusionessentialfileformats_(version).exe file will be extracted into the Temp directory. +3. Run %temp%. The Temp folder will be opened. The syncfusionessentialfileformats_(version).exe file will be located in one of the folders. +4. Copy the extracted syncfusionessentialfileformats_(version).exe file to a local drive. +5. Exit the Wizard. +6. Run Command Prompt in administrator mode and enter the following arguments. - **Arguments:** “installer file path\SyncfusionEssentialStudio(platform)_(version).exe” /Install silent /UNLOCKKEY:“(product unlock key)” [/log “{Log file path}”] [/InstallPath:{Location to install}] [/InstallSamples:{true/false}] [/InstallAssemblies:{true/false}] [/UninstallExistAssemblies:{true/false}] [/InstallToolbox:{true/false}] + **Arguments:** "installer file path\SyncfusionEssentialStudio(platform)_(version).exe" /Install silent /UNLOCKKEY:"(product unlock key)" [/log "{Log file path}"] [/InstallPath:{Location to install}] [/InstallSamples:{true/false}] [/InstallAssemblies:{true/false}] [/UninstallExistAssemblies:{true/false}] [/InstallToolbox:{true/false}] N> [..] – Arguments inside the square brackets are optional. - **Example:** “D:\Temp\syncfusionessentialfileformats_x.x.x.x.exe” /Install silent /UNLOCKKEY:“product unlock key” /log “C:\Temp\EssentialStudio_Platform.log” /InstallPath:C:\Syncfusion\x.x.x.x /InstallSamples:true /InstallAssemblies:true /UninstallExistAssemblies:true /InstallToolbox:true + **Example:** "D:\Temp\syncfusionessentialfileformats_x.x.x.x.exe" /Install silent /UNLOCKKEY:"product unlock key" /log "C:\Temp\EssentialStudio_Platform.log" /InstallPath:C:\Syncfusion\x.x.x.x /InstallSamples:true /InstallAssemblies:true /UninstallExistAssemblies:true /InstallToolbox:true - -7. Essential Studio® for FileFormats is installed. + +7. Essential Studio® for FileFormats is installed. - N> x.x.x.x should be replaced with the Essential Studio® version and the Product Unlock Key needs to be replaced with the Unlock Key for that version. + N> x.x.x.x should be replaced with the Essential Studio® version, and the Product Unlock Key needs to be replaced with the Unlock Key for that version. ### Command Line Uninstallation -Syncfusion® Essential® FileFormats can be uninstalled silently using the Command Line. +Syncfusion® Essential Studio® FileFormats can be uninstalled silently using the Command Line. -1. Run the Syncfusion® FileFormats installer by double-clicking it. The Installer Wizard automatically opens and extracts the package. -2. The file syncfusionessentialfileformats_(version).exe file will be extracted into the Temp directory. -3. Run %temp%. The Temp folder will be opened. The syncfusionessentialfileformats_(version).exe file will be located in one of the folders. -4. Copy the extracted syncfusionessentialfileformats_(version).exe file in local drive. -5. Exit the Wizard. -6. Run Command Prompt in administrator mode and enter the following arguments. +1. Run the Syncfusion® FileFormats installer by double-clicking it. The Installer Wizard automatically opens and extracts the package. +2. The file syncfusionessentialfileformats_(version).exe file will be extracted into the Temp directory. +3. Run %temp%. The Temp folder will be opened. The syncfusionessentialfileformats_(version).exe file will be located in one of the folders. +4. Copy the extracted syncfusionessentialfileformats_(version).exe file to a local drive. +5. Exit the Wizard. +6. Run Command Prompt in administrator mode and enter the following arguments. - **Arguments:** “Copied installer file path\syncfusionessentialfileformats_(version).exe” /uninstall silent  + - **Example:** “D:\Temp\syncfusionessentialfileformats_x.x.x.x.exe" /uninstall silent + **Arguments:** "Copied installer file path\syncfusionessentialfileformats_(version).exe" /uninstall silent + **Example:** "D:\Temp\syncfusionessentialfileformats_x.x.x.x.exe" /uninstall silent -7. Essential Studio® for WPF is uninstalled. - - +7. Essential Studio® for WPF is uninstalled. \ No newline at end of file diff --git a/java-file-formats/word-library/Installation/web-installer/how-to-download.md b/java-file-formats/word-library/Installation/web-installer/how-to-download.md index d951fe8..3378096 100644 --- a/java-file-formats/word-library/Installation/web-installer/how-to-download.md +++ b/java-file-formats/word-library/Installation/web-installer/how-to-download.md @@ -10,10 +10,10 @@ documentation: ug # Downloading Syncfusion® FileFormats Web Installer -[DocIO](https://www.syncfusion.com/word-framework/net),[PDF](https://www.syncfusion.com/pdf-framework/net),[Presentation](https://www.syncfusion.com/powerpoint-framework/net), and [XlsIO](https://www.syncfusion.com/excel-framework/net) controls will be included in the Syncfusion® FileFormats installer. You can either download the licensed installer or try our trial installer depending on your license. +[DocIO](https://www.syncfusion.com/word-framework/net), [PDF](https://www.syncfusion.com/pdf-framework/net), [Presentation](https://www.syncfusion.com/powerpoint-framework/net), and [XlsIO](https://www.syncfusion.com/excel-framework/net) controls will be included in the Syncfusion® FileFormats installer. You can either download the licensed installer or try our trial installer depending on your license. - - Trial Installer - - Licensed Installer + - Trial Installer + - Licensed Installer ## Download the Trial Version @@ -21,35 +21,35 @@ documentation: ug Our 30-day trial can be downloaded in two ways. * Download Free Trial Setup - * Start Trials if using components through [maven repository](https://jars.syncfusion.com) + * Start Trials if using components through [Maven Repository](https://jars.syncfusion.com) ### Download Free Trial Setup -1. You can evaluate our 30-day free trial by visiting the [Download Free Trial](https://www.syncfusion.com/downloads) page and select the FileFormats platform. -2. After completing the required form or logging in with your registered Syncfusion® account, you can download the FileFormats trial installer from the confirmation page. (as shown in below screenshot.) +1. You can evaluate our 30-day free trial by visiting the [Download Free Trial](https://www.syncfusion.com/downloads) page and selecting the FileFormats platform. +2. After completing the required form or logging in with your registered Syncfusion® account, you can download the FileFormats trial installer from the confirmation page (as shown in the screenshot below). ![Trial and downloads of Syncfusion® Essential Studio®](images/trial-confirmation.png) 3. With a trial license, only the latest version’s trial installer can be downloaded. -4. After downloading, the Syncfusion® FileFormats trial installer can be unlocked using either the trial unlock key or the Syncfusion® registered login credential. More information on generating an unlock key can be found in [this](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) article. -5. Before the trial expires, you can download the trial installer at any time from your registered account’s [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page (as shown in below screenshot.) +4. After downloading, the Syncfusion® FileFormats trial installer can be unlocked using either the trial unlock key or the Syncfusion® registered login credentials. More information on generating an unlock key can be found in [this](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) article. +5. Before the trial expires, you can download the trial installer at any time from your registered account’s [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page (as shown in the screenshot below). 6. Click the Download (element 1 in the screenshot below) button to get the Syncfusion® Essential Studio® FileFormats web installer. ![Trial and downloads of Syncfusion® Essential Studio®](images/trial-download.png) - -### Start Trials if using components through [maven repository](https://jars.syncfusion.com) + +### Start Trials if using components through [Maven Repository](https://jars.syncfusion.com) 1. You can start your 30-day free trial for FileFormats from the [Start Trial](https://www.syncfusion.com/account/manage-trials/start-trials) page from your account. ![Trial and downloads of Syncfusion® Essential Studio®](images/start-trial-download.png) -2. To access this page, you must sign up\log in with your Syncfusion® account. +2. To access this page, you must sign up/log in with your Syncfusion® account. 3. Begin your trial by selecting the FileFormats product. N> If you've already used the trial products and they haven't expired, you won't be able to start the trial for the same product again. -4. After you've started the trial, go to the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page to get the latest version trial installer. You can generate the [unlock key](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) and [license key](https://help.syncfusion.com/document-processing/licensing/how-to-generate) here at any time before the trial period expires. (as shown in below screenshot.) +4. After you've started the trial, go to the [Trials & Downloads](https://www.syncfusion.com/account/manage-trials/downloads) page to get the latest version trial installer. You can generate the [unlock key](https://www.syncfusion.com/kb/8069/how-to-generate-unlock-key-for-essentials-studio-products) and [license key](https://help.syncfusion.com/document-processing/licensing/how-to-generate) here at any time before the trial period expires (as shown in the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/start-trial-download-installer.png) @@ -58,21 +58,21 @@ Our 30-day trial can be downloaded in two ways. ## Download the License Version -1. Syncfusion® licensed products will be available in the [License & Downloads](https://www.syncfusion.com/account/downloads) page under your registered Syncfusion® account. +1. Syncfusion® licensed products will be available on the [License & Downloads](https://www.syncfusion.com/account/downloads) page under your registered Syncfusion® account. 2. You can view all the licenses (both active and expired) associated with your account. 3. Click the Download (element 1 in the screenshot below) button to download the respective product’s installer. 4. The most recent version of the installer will be downloaded from this page. 5. To download older version installers, go to [Downloads Older Versions](https://www.syncfusion.com/account/downloads/studio) (element 2 in the screenshot below). -6. You can download other platform\add-on installers by going to More Downloads Options (element 3 in the screenshot below). +6. You can download other platform/add-on installers by going to More Downloads Options (element 3 in the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/license-download.png) -7. Before the license expires, you can download the installer at any time from your registered account’s [License & Downloads](https://www.syncfusion.com/account/downloads) page (See the screenshot below.) +7. Before the license expires, you can download the installer at any time from your registered account’s [License & Downloads](https://www.syncfusion.com/account/downloads) page (see the screenshot below). ![License and downloads of Syncfusion® Essential Studio®](images/start-trial-download-web-installer.png) -8. After downloading, the Syncfusion® FileFormats web installer can be unlocked using Syncfusion® registered login credential. +8. After downloading, the Syncfusion® FileFormats web installer can be unlocked using Syncfusion® registered login credentials. - N> For Syncfusion® trial and licensed products, there is no separate web installer. Based on your account license, Syncfusion® trial or licensed products will be installed via web installer. + N> For Syncfusion® trial and licensed products, there is no separate web installer. Based on your account license, Syncfusion® trial or licensed products will be installed via the web installer. -You can also refer to the [**Web installer**](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-install) links for step-by-step installation guidelines. \ No newline at end of file +You can also refer to the [**Web Installer**](https://help.syncfusion.com/java-file-formats/installation/web-installer/how-to-install) links for step-by-step installation guidelines. \ No newline at end of file diff --git a/java-file-formats/word-library/Installation/web-installer/how-to-install.md b/java-file-formats/word-library/Installation/web-installer/how-to-install.md index 1e0158a..7fcd441 100644 --- a/java-file-formats/word-library/Installation/web-installer/how-to-install.md +++ b/java-file-formats/word-library/Installation/web-installer/how-to-install.md @@ -1,187 +1,257 @@ --- layout: post -title: Installing Syncfusion FileFormats web installer - Syncfusion -description: Learn here about how to install Syncfusion FileFormats web installer after downloading from our Syncfusion website. +title: Installing Syncfusion FileFormats Web Installer - Syncfusion +description: Learn here about how to install Syncfusion FileFormats Web Installer after downloading it from our Syncfusion website. platform: java-file-formats control: Installation and Deployment documentation: ug --- -# Installing Syncfusion® FileFormats web installer +# Installing Syncfusion® FileFormats Web Installer ## Overview -For the Essential Studio® FileFormats product, Syncfusion® offers a Web Installer. This installer alleviates the burden of downloading a larger installer. You can simply download and run the online installer, which will be smaller in size and will download and install the Essential Studio® products you have chosen. You can get the most recent version of Essential Studio® Web Installer [here](https://www.syncfusion.com/downloads/latest-version). +For the Essential Studio® FileFormats product, Syncfusion® offers a Web Installer. This installer alleviates the burden of downloading a larger installer. You can simply download and run the online installer, which will be smaller in size and will download and install the Essential Studio® products you have chosen. You can get the most recent version of the Essential Studio® Web Installer [here](https://www.syncfusion.com/downloads/latest-version). ## Installation -The steps below show how to install Essential Studio® FileFormats Web Installer. +The steps below show how to install the Essential Studio® FileFormats Web Installer. -1. Open the Syncfusion® Essential Studio® FileFormats Web Installer file from downloaded location by double-clicking it. The Installer Wizard automatically opens and extracts the package. +1. Open the Syncfusion® Essential Studio® FileFormats Web Installer file from the downloaded location by double-clicking it. The Installer Wizard automatically opens and extracts the package. ![Installer Extraction Wizard](images/Step-by-Step-Installation_img1.png) - - N> The installer wizard extracts the syncfusionessentialfileformatswebinstaller_{version}.exe dialog, which displays the package's unzip operation. - -2. The Syncfusion® FileFormats Web Installer's welcome wizard will be displayed. Click the Next button. + N> The installer wizard extracts the syncfusionessentialfileformatswebinstaller_{version}.exe dialog, which displays the package's unzip operation. - ![Welcome wizard](images/Step-by-Step-Installation_img2.png) +2. The Syncfusion® FileFormats Web Installer's welcome wizard will be displayed. Click the Next button. - -3. The Platform Selection Wizard will appear. From the **Available** tab, select the products to be installed. Select the **Install All** checkbox to install all products. - - **Available** - - ![Platform Selection wizard Available](images/Step-by-Step-Installation_img3.png) - - If you have multiple products installed in the same version, they will be listed under the **Installed** tab. You can also select which products to uninstall from the same version. Click the Next button. - - **Installed** - - ![Platform Selection wizard Installed](images/Step-by-Step-Installation_img24.png) - - I> If the required software for the selected product isn't already installed, the **Additional Software Required** alert will appear. You can, however, continue the installation and install the necessary software later. - - **Required Software** - - ![Additional Software Alert](images/Step-by-Step-Installation_img5.png) - - -4. If previous version(s) for the selected products are installed, the Uninstall previous version wizard will be displayed. You can see the list of previously installed versions for the products you've chosen here. To remove all versions, check the **Uninstall All** checkbox. Click the Next button. + ![Welcome Wizard](images/Step-by-Step-Installation_img2.png) - ![Existing Version for install](images/Step-by-Step-Installation_img20.png) - - N> From the 2021 Volume 1 release, Syncfusion® has provided option to uninstall the previous versions from 18.1 while installing the new version. - - -5. Pop up screen will be displayed to get the confirmation to uninstall selected previous versions. +3. The Platform Selection Wizard will appear. From the **Available** tab, select the products to be installed. Select the **Install All** checkbox to install all products. - ![Existing Version for install](images/Step-by-Step-Installation_img21.png) - - -6. The Confirmation Wizard will appear with the list of products to be installed/uninstalled. You can view and modify the list of products that will be installed and uninstalled from this page. + **Available** - ![Confirmation for install/uninstall](images/Step-by-Step-Installation_img15.png) - - N> By clicking the **Download Size and Installation** Size links, you can determine the approximate size of the download and installation - + ![Platform Selection Wizard Available](images/Step-by-Step-Installation_img3.png) + + If you have multiple products installed in the same version, they will be listed under the **Installed** tab. You can also select which products to uninstall from the same version. Click the Next button. + + **Installed** + + ![Platform Selection Wizard Installed](images/Step-by-Step-Installation_img24.png) + + I> If the required software for the selected product isn't already installed, the **Additional Software Required** alert will appear. You can, however, continue the installation and install the necessary software later. -7. The Configuration Wizard will appear. You can change the Download, Install, and Demos locations from here. You can also change the Additional settings on a product-by-product basis. Click Next to install with the default settings. + **Required Software** - ![Install and samples location for install](images/Step-by-Step-Installation_img8.png) + ![Additional Software Alert](images/Step-by-Step-Installation_img5.png) + +4. If previous version(s) for the selected products are installed, the Uninstall Previous Version Wizard will be displayed. You can see the list of previously installed versions for the products you've chosen here. To remove all versions, check the **Uninstall All** checkbox. Click the Next button. + + ![Existing Version for Install](images/Step-by-Step-Installation_img20.png) + + N> From the 2021 Volume 1 release, Syncfusion® has provided the option to uninstall previous versions from 18.1 while installing the new version. + +5. A pop-up screen will be displayed to get confirmation to uninstall selected previous versions. + - **Additional settings** + + + ![Existing Version for Install](images/Step-by-Step-Installation_img21.png) + +6. The Confirmation Wizard will appear with the list of products to be installed/uninstalled. You can view and modify the list of products that will be installed and uninstalled from this page. + - * Select the **Install Demos** check box to install Syncfusion® samples, or leave the check box unchecked, if you do not want to install Syncfusion® samples - * Select the **Register Syncfusion® Assemblies in GAC** check box to install the latest Syncfusion® assemblies in GAC, or clear this check box when you do not want to install the latest assemblies in GAC. - * Select the **Configure Syncfusion® controls in Visual Studio** check box to configure the Syncfusion® controls in the Visual Studio toolbox, or clear this check box when you do not want to configure the Syncfusion® controls in the Visual Studio toolbox during installation. Note that you must also select the Register Syncfusion® assemblies in GAC check box when you select this check box. - * Select the **Configure Syncfusion® Extensions controls in Visual Studio** checkbox to configure the Syncfusion® Extensions in Visual Studio or clear this check box when you do not want to configure the Syncfusion® Extensions in Visual Studio. - * Check the **Create Desktop Shortcut** checkbox to add a desktop shortcut for Syncfusion® Control Panel - * Check the **Create Start Menu Shortcut** checkbox to add a shortcut to the start menu for Syncfusion® Control Panel + + + + + + + + + + + + + + + + + + + + ![Confirmation for Install/Uninstall](images/Step-by-Step-Installation_img15.png) + + + + + + N> By clicking the **Download Size** and **Installation Size** links, you can determine the approximate size of the download and installation. + + + +7. The Configuration Wizard will appear. You can change the Download, Install, and Demos locations from here. You can also change additional settings on a product-by-product basis. Click Next to install with the default settings. + + + -8. After reading the License Terms and Conditions, check the **I agree to the License Terms and Privacy Policy** check box. Click the Next button. + ![Install and Samples Location for Install](images/Step-by-Step-Installation_img8.png) -9. The login wizard will appear. You must enter your Syncfusion® email address and password. If you do not already have a Syncfusion® account, you can create one by clicking on **Create an Account**. If you have forgotten your password, click **Forgot Password** to create a new one. Click the Install button. + + + **Additional Settings** + + + + + + + - ![Login wizard install](images/Step-by-Step-Installation_img9.png) - - I> The products you have chosen will be installed based on your Syncfusion® License (Trial or Licensed). + * Select the **Install Demos** checkbox to install Syncfusion® samples, or leave the checkbox unchecked if you do not want to install Syncfusion® samples. + * Select the **Register Syncfusion® Assemblies in GAC** checkbox to install the latest Syncfusion® assemblies in GAC, or clear this checkbox if you do not want to install the latest assemblies in GAC. + * Select the **Configure Syncfusion® Controls in Visual Studio** checkbox to configure the Syncfusion® controls in the Visual Studio toolbox, or clear this checkbox if you do not want to configure the Syncfusion® controls in the Visual Studio toolbox during installation. Note that you must also select the Register Syncfusion® Assemblies in GAC checkbox when you select this checkbox. + * Select the **Configure Syncfusion® Extensions Controls in Visual Studio** checkbox to configure the Syncfusion® Extensions in Visual Studio or clear this checkbox if you do not want to configure the Syncfusion® Extensions in Visual Studio. + * Check the **Create Desktop Shortcut** checkbox to add a desktop shortcut for the Syncfusion® Control Panel. + * Check the **Create Start Menu Shortcut** checkbox to add a shortcut to the start menu for the Syncfusion® Control Panel. -10. The download and installation\uninstallation progress will be displayed as shown below. +8. After reading the License Terms and Conditions, check the **I agree to the License Terms and Privacy Policy** checkbox. Click the Next button. - ![Download and Installation progress install](images/Step-by-Step-Installation_img10.png) +9. The Login Wizard will appear. You must enter your Syncfusion® email address and password. If you do not already have a Syncfusion® account, you can create one by clicking **Create an Account**. If you have forgotten your password, click **Forgot Password** to create a new one. Click the Install button. -11. When the installation is finished, the **Summary** wizard will appear. Here you can see the list of products that have been installed successfully and those that have failed. To close the Summary wizard, click Finish. + ![Login Wizard Install](images/Step-by-Step-Installation_img9.png) + + + + I> The products you have chosen will be installed based on your Syncfusion® License (Trial or Licensed). + +10. The download and installation/uninstallation progress will be displayed as shown below. + + ![Download and Installation Progress Install](images/Step-by-Step-Installation_img10.png) + +11. When the installation is finished, the **Summary Wizard** will appear. Here you can see the list of products that have been successfully installed and those that have failed. To close the Summary Wizard, click Finish. ![Installation Summary](images/Step-by-Step-Installation_img11.png) - - * To open the Syncfusion® Control Panel, click **Launch Control Panel**. + + * To open the Syncfusion® Control Panel, click **Launch Control Panel**. 12. After installation, there will be two Syncfusion® control panel entries, as shown below. The Essential Studio® entry will manage all Syncfusion® products installed in the same version, while the Product entry will only uninstall the specific product setup. ![Control Panel](images/Step-by-Step-Installation_img19.png) - - N> * You can find the required jars in the FileFormats installed location - * **Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\ {Platform}\ {version}\JarFiles - * **Example:** C:\Program Files (x86)\Syncfusion\Essential Studio\FileFormats\19.1.0.54\JarFiles - + + N> * You can find the required jars in the FileFormats installed location + * **Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\{Platform}\{version}\JarFiles + * **Example:** C:\Program Files (x86)\Syncfusion\Essential Studio\FileFormats\19.1.0.54\JarFiles + ## Uninstallation -Syncfusion® FileFormats installer can be uninstalled in two ways. +Syncfusion® FileFormats Installer can be uninstalled in two ways: + + * Uninstall the FileFormats using the Syncfusion® FileFormats Web Installer. + * Uninstall the FileFormats from the Windows Control Panel. + +Follow either one of the options below to uninstall the Syncfusion® Essential Studio® FileFormats Installer. - * Uninstall the FileFormats using the Syncfusion® FileFormats web installer - * Uninstall the FileFormats from Windows Control Panel +**Option 1: Uninstall the FileFormats using the Syncfusion® FileFormats Web Installer** + -Follow either one of the option below to uninstall Syncfusion® Essential Studio® FileFormats installer. +Syncfusion® provides the option to uninstall products of the same version directly from the Web Installer application. Select the products to be uninstalled from the list, and the Web Installer will uninstall them one by one. -**Option 1: Uninstall the FileFormats using the Syncfusion® FileFormats web installer** + -Syncfusion® provides the option to uninstall products of the same version directly from the Web Installer application. Select the products to be uninstalled from the list, and Web Installer will uninstall them one by one. +![Platform Selection Wizard Installed](images/Step-by-Step-Installation_img4.png) -![Platform Selection wizard Installed](images/Step-by-Step-Installation_img4.png) +**Option 2: Uninstall the FileFormats from the Windows Control Panel** - -**Option 2: Uninstall the FileFormats from Windows Control Panel** - -You can uninstall all the installed products by selecting the **Syncfusion® Essential Studio® {version}** entry (element 1 in the below screenshot) from the Windows control panel, or you can uninstall FileFormats alone by selecting the **Syncfusion® Essential Studio® for FileFormats {version}** entry (element 2 in the below screenshot) from the Windows control panel. + + + +You can uninstall all the installed products by selecting the **Syncfusion® Essential Studio® {version}** entry (element 1 in the below screenshot) from the Windows Control Panel, or you can uninstall FileFormats alone by selecting the **Syncfusion® Essential Studio® for FileFormats {version}** entry (element 2 in the below screenshot) from the Windows Control Panel. ![Control Panel](images/Step-by-Step-Installation_img22.png) - -N> If the **Syncfusion® Essential Studio® for FileFormats {version}** entry is selected from the Windows control panel, the Syncfusion® Essential Studio® FileFormats alone will be removed and the below default MSI uninstallation window will be displayed. -1. The Syncfusion® FileFormats Web Installer's welcome wizard will be displayed. Click the Next button - - ![Welcome wizard uninstall](images/Step-by-Step-Installation_img2.png) +N> If the **Syncfusion® Essential Studio® for FileFormats {version}** entry is selected from the Windows Control Panel, the Syncfusion® Essential Studio® FileFormats alone will be removed, and the below default MSI uninstallation window will be displayed. -2. The Platform Selection Wizard will appear. From the **Installed** tab, select the products to be uninstalled. To select all products, check the **Uninstall All** checkbox. Click the Next button. - - **Installed** - - ![Platform Selection wizard Installed](images/Step-by-Step-Installation_img4.png) - - You can also select the products to be installed from the **Available** tab.Click the Next button. - - **Available** - - ![Platform Selection wizard Available](images/Step-by-Step-Installation_img25.png) - -3. If any other products selected for installation, Uninstall previous version wizard will be displayed with previous version(s) installed for the selected products. Here you can view the list of installed previous versions for the selected products. Select **Uninstall All** checkbox to select all the versions. Click Next. +1. The Syncfusion® FileFormats Web Installer's welcome wizard will be displayed. Click the Next button. - ![Existing Version for install](images/Step-by-Step-Installation_img26.png) - -4. Pop up screen will be displayed to get the confirmation to uninstall selected previous versions. + ![Welcome Wizard Uninstall](images/Step-by-Step-Installation_img2.png) - ![Existing Version for install](images/Step-by-Step-Installation_img21.png) - -5. The Confirmation Wizard will appear with the list of products to be installed/uninstalled. Here you can view and modify the list of products that will be installed/uninstalled. +2. The Platform Selection Wizard will appear. From the **Installed** tab, select the products to be uninstalled. To select all products, check the **Uninstall All** checkbox. Click the Next button. - ![Confirmation for install/uninstall](images/Step-by-Step-Installation_img15.png) - - N> By clicking the **Download Size and Installation** Size links, you can determine the approximate size of the download and installation - -6. The Configuration Wizard will appear. You can change the Download, Install, and Demos locations from here. You can also change the Additional settings on a product-by-product basis. Click Next to install with the default settings. + **Installed** - ![Install and samples location install/uninstall](images/Step-by-Step-Installation_img23.png) - -7. After reading the License Terms and Conditions, check the **I agree to the License Terms and Privacy Policy** check box. Click the Next button. + ![Platform Selection Wizard Installed](images/Step-by-Step-Installation_img4.png) -8. The login wizard will appear. You must enter your Syncfusion® email address and password. If you do not already have a Syncfusion® account, you can create one by clicking on **Create an Account**. If you have forgotten your password, click **Forgot Password** to create a new one. Click the Install button. + You can also select the products to be installed from the **Available** tab. Click the Next button. - ![Login wizard install/uninstall](images/Step-by-Step-Installation_img9.png) - - I> The products you have chosen will be installed based on your Syncfusion® License (Trial or Licensed). + **Available** + + ![Platform Selection Wizard Available](images/Step-by-Step-Installation_img25.png) + +3. If any other products are selected for installation, the Uninstall Previous Version Wizard will be displayed with previous version(s) installed for the selected products. Here you can view the list of installed previous versions for the selected products. Select the **Uninstall All** checkbox to select all the versions. Click Next. -9. The download, installation, and uninstallation progresses will be shown. + ![Existing Version for Install](images/Step-by-Step-Installation_img26.png) - ![Download and Installation progress install/uninstall](images/Step-by-Step-Installation_img17.png) +4. A pop-up screen will be displayed to get confirmation to uninstall selected previous versions. -10. When the installation is finished, the **Summary** wizard will appear. Here you can see the list of products that have been successfully and unsuccessfully installed/uninstalled. To close the Summary wizard, click Finish. + ![Existing Version for Install](images/Step-by-Step-Installation_img21.png) - ![Summary install/uninstall](images/Step-by-Step-Installation_img18.png) +5. The Confirmation Wizard will appear with the list of products to be installed/uninstalled. Here you can view and modify the list of products that will be installed/uninstalled. + + ![Confirmation for Install/Uninstall](images/Step-by-Step-Installation_img15.png) + + N> By clicking the **Download Size** and **Installation Size** links, you can determine the approximate size of the download and installation. + + + +6. The Configuration Wizard will appear. You can change the Download, Install, and Demos locations from here. You can also change additional settings on a product-by-product basis. Click Next to install with the default settings. - * To open the Syncfusion® Control Panel, click **Launch Control Panel**. \ No newline at end of file + + + + + + + + + + + + + ![Install and Samples Location Install/Uninstall](images/Step-by-Step-Installation_img23.png) + + + +7. After reading the License Terms and Conditions, check the **I agree to the License Terms and Privacy Policy** checkbox. Click the Next button. + + + +8. The Login Wizard will appear. You must enter your Syncfusion® email address and password. If you do not already have a Syncfusion® account, you can create one by clicking **Create an Account**. If you have forgotten your password, click **Forgot Password** to create a new one. Click the Install button. + + + + + + ![Login Wizard Install/Uninstall](images/Step-by-Step-Installation_img9.png) + + + + I> The products you have chosen will be installed based on your Syncfusion® License (Trial or Licensed). + +9. The download, installation, and uninstallation progress will be shown. + + + + ![Download and Installation Progress Install/Uninstall](images/Step-by-Step-Installation_img17.png) + +10. When the installation is finished, the **Summary Wizard** will appear. Here you can see the list of products that have been successfully installed/uninstalled and those that have failed. To close the Summary Wizard, click Finish. + + ![Summary Install/Uninstall](images/Step-by-Step-Installation_img18.png) + + + + * To open the Syncfusion® Control Panel, click **Launch Control Panel**. \ No newline at end of file diff --git a/java-file-formats/word-library/accepting-or-rejecting-track-changes.md b/java-file-formats/word-library/accepting-or-rejecting-track-changes.md index 0854f8b..586bd77 100644 --- a/java-file-formats/word-library/accepting-or-rejecting-track-changes.md +++ b/java-file-formats/word-library/accepting-or-rejecting-track-changes.md @@ -1,38 +1,38 @@ --- -title: Accepting or Rejecting Track Changes | Word library | Syncfusion -description: This section illustrates how to Accept or Reject the Track changes in the Word document using Syncfusion Word library (Essential DocIO) +title: Accepting or Rejecting Track Changes | Word Library | Syncfusion +description: This section illustrates how to accept or reject the track changes in the Word document using the Syncfusion Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG --- # Accepting or Rejecting Track Changes -It is used to keep track of the changes made to a Word document. It helps to maintain the record of author, name and time for every insertion, deletion, or modification in a document. This can be enabled by using the TrackChanges property of the Word document. +It is used to keep track of the changes made to a Word document. It helps to maintain the record of the author, name, and time for every insertion, deletion, or modification in a document. This can be enabled by using the `TrackChanges` property of the Word document. N> -With this support, the changes made in the Word document by DocIO library cannot be tracked. +With this support, the changes made in the Word document by the DocIO library cannot be tracked. -The following code example illustrates how to enable track changes of the document. +The following code example illustrates how to enable track changes in the document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds new section to the document. +// Adds a new section to the document. IWSection section = document.addSection(); -//Adds new paragraph to the section. +// Adds a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Appends text to the paragraph. -IWTextRange text = paragraph.appendText("This sample illustrates how to track the changes made to the word document. "); -//Sets font name and size for text. +// Appends text to the paragraph. +IWTextRange text = paragraph.appendText("This sample illustrates how to track the changes made to the Word document. "); +// Sets font name and size for the text. text.getCharacterFormat().setFontName("Times New Roman"); text.getCharacterFormat().setFontSize((float)14); -text=paragraph.appendText("This track changes is useful in shared environment."); +text = paragraph.appendText("This track changes is useful in a shared environment."); text.getCharacterFormat().setFontSize((float)12); -//Turns on the track changes option. +// Turns on the track changes option. document.setTrackChanges(true); -//Saves and closes the document. +// Saves and closes the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} @@ -41,104 +41,104 @@ document.close(); ## Accept all changes -You can **accept all track changes in Word document** using `acceptAll` method. +You can **accept all track changes in a Word document** using the `acceptAll` method. The following code example shows how to accept all the tracked changes. {% tabs %} {% highlight JAVA %} -//Opens an existing Word document. +// Opens an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Accepts all the tracked changes revisions. -if(document.getHasChanges()) +// Accepts all the tracked changes revisions. +if (document.getHasChanges()) document.getRevisions().acceptAll(); -//Saves and closes the document. +// Saves and closes the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. ![Accepting all track changes in Word document](WorkingWithTrackChanges_images/AcceptAll.png) ## Reject all changes -You can **reject all track changes in Word document** using `rejectAll` method. +You can **reject all track changes in a Word document** using the `rejectAll` method. The following code example shows how to reject all the tracked changes. {% tabs %} {% highlight JAVA %} -//Opens an existing Word document. +// Opens an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Rejects all the tracked changes revisions. -if(document.getHasChanges()) - document.getRevisions().rejectAll(); -//Saves and closes the document. +// Rejects all the tracked changes revisions. +if (document.getHasChanges()) + document.getRevisions().rejectAll(); +// Saves and closes the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. ![Rejecting all track changes in Word document](WorkingWithTrackChanges_images/RejectAll.png) ## Accept all changes by a particular reviewer -You can **accept all changes made by the author** in the Word document using `accept` method. +You can **accept all changes made by the author** in the Word document using the `accept` method. The following code example shows how to accept the tracked changes made by the author. {% tabs %} {% highlight JAVA %} -//Opens an existing Word document. +// Opens an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Iterates into all the revisions in Word document. +// Iterates into all the revisions in the Word document. for (int i = document.getRevisions().getCount() - 1; i >= 0; i--) { - //Checks the author of current revision and accepts it. - if(document.getRevisions().get(i).getAuthor().equals("Nancy Davolio")) - document.getRevisions().get(i).accept(); - //Resets to last item when accept the moving related revisions. - if (i > document.getRevisions().getCount() - 1) - i = document.getRevisions().getCount(); + // Checks the author of the current revision and accepts it. + if (document.getRevisions().get(i).getAuthor().equals("Nancy Davolio")) + document.getRevisions().get(i).accept(); + // Resets to the last item when accepting the moving related revisions. + if (i > document.getRevisions().getCount() - 1) + i = document.getRevisions().getCount(); } -//Saves and closes the document. +// Saves and closes the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -## Reject all changes by particular reviewer +## Reject all changes by a particular reviewer -You can **reject all changes made by the author** in the Word document using `reject` method. +You can **reject all changes made by the author** in the Word document using the `reject` method. The following code example shows how to reject the tracked changes made by the author. {% tabs %} {% highlight JAVA %} -//Opens an existing Word document. +// Opens an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Iterates into all the revisions in Word document. +// Iterates into all the revisions in the Word document. for (int i = document.getRevisions().getCount() - 1; i >= 0; i--) { - //Checks the author of current revision and rejects it. - if(document.getRevisions().get(i).getAuthor().equals("Nancy Davolio")) - document.getRevisions().get(i).reject(); - //Resets to last item when reject the moving related revisions. - if (i > document.getRevisions().getCount() - 1) - i = document.getRevisions().getCount(); + // Checks the author of the current revision and rejects it. + if (document.getRevisions().get(i).getAuthor().equals("Nancy Davolio")) + document.getRevisions().get(i).reject(); + // Resets to the last item when rejecting the moving related revisions. + if (i > document.getRevisions().getCount() - 1) + i = document.getRevisions().getCount(); } -//Saves and closes the document. +// Saves and closes the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} @@ -147,24 +147,24 @@ document.close(); ## Revision information -You can get the **revision information of track changes** in the Word document like author name, date, and type of revision. +You can get the **revision information of track changes** in the Word document like the author name, date, and type of revision. The following code example shows how to get the details about the revision information of track changes. {% tabs %} {% highlight JAVA %} -//Opens an existing Word document. +// Opens an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Accesses the first revision in the word document. +// Accesses the first revision in the Word document. Revision revision = document.getRevisions().get(0); -//Gets the name of the user who made the specified tracked change. +// Gets the name of the user who made the specified tracked change. String author = revision.getAuthor(); // Gets the date and time that the tracked change was made. LocalDateTime dateTime = revision.getDate(); // Gets the type of the track changes revision. RevisionType revisionType = revision.getRevisionType(); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} diff --git a/java-file-formats/word-library/applying-watermark.md b/java-file-formats/word-library/applying-watermark.md index 5e0eebe..8f1d808 100644 --- a/java-file-formats/word-library/applying-watermark.md +++ b/java-file-formats/word-library/applying-watermark.md @@ -1,6 +1,6 @@ --- title: Applying Watermark | Syncfusion -description: This section illustrates how to insert text or pictures watermark to the Word document using Syncfusion Word library (Essential DocIO) +description: This section illustrates how to insert text or picture watermarks into a Word document using the Syncfusion Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG @@ -8,13 +8,13 @@ documentation: UG # Working with Watermark -Watermarks are text or pictures that appear behind the document text. You can access the watermark in the document by using the `Watermark` property of `WordDocument` class. +Watermarks are text or pictures that appear behind the document text. You can access the watermark in the document by using the `Watermark` property of the `WordDocument` class. There are two types of watermarks: Text and Picture. -## Text watermark +## Text Watermark -You can add or modify text watermark in the Word document. The `TextWatermark` class represents the text watermark in the Word document. +You can add or modify a text watermark in the Word document. The `TextWatermark` class represents the text watermark in the Word document. The following code example shows how to add a text watermark to the Word document. @@ -40,7 +40,7 @@ textWatermark.setSemitransparent(false); textWatermark.setColor(ColorSupport.getBlack()); //Save the Word document. document.save("Result_watermark1.docx", FormatType.Docx); -//Closes the document. +//Close the document. document.close(); {% endhighlight %} @@ -48,7 +48,7 @@ document.close(); ## Picture Watermark -You can add or modify the picture watermark in the Word document. The `PictureWatermark` class represents the picture watermark in the Word document. +You can add or modify a picture watermark in the Word document. The `PictureWatermark` class represents the picture watermark in the Word document. The following code example shows how to add a picture watermark to the Word document. @@ -63,12 +63,12 @@ IWParagraph paragraph = document.getLastParagraph(); paragraph.appendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."); //Create a new picture watermark. PictureWatermark picWatermark = new PictureWatermark(); -//Set the scaling to picture. +//Set the scaling for the picture. picWatermark.setScaling(120f); picWatermark.setWashout(true); -//Set the picture watermark to document. +//Set the picture watermark to the document. document.setWatermark(picWatermark); -//Set the image to the picture watermark. +//Set the image for the picture watermark. Path path = Paths.get("David.png"); byte[] data = Files.readAllBytes(path); picWatermark.loadPicture(data); diff --git a/java-file-formats/word-library/conversion.md b/java-file-formats/word-library/conversion.md index 2d381ba..363452e 100644 --- a/java-file-formats/word-library/conversion.md +++ b/java-file-formats/word-library/conversion.md @@ -1,6 +1,6 @@ --- -title: Working with Document Conversions | Word library | Syncfusion -description: This section illustrates how to convert a Word document into other supported file formats using Syncfusion Java Word library +title: Working with Document Conversions | Word Library | Syncfusion +description: This section illustrates how to convert a Word document into other supported file formats using the Syncfusion Java Word library platform: java-file-formats control: Word Library documentation: UG @@ -10,31 +10,31 @@ documentation: UG ## Working with Document Conversions -The Essential® DocIO converts documents from one format to another format. Each file format document can be categorized as flow layout document. +The Essential® DocIO converts documents from one format to another format. Each file format document can be categorized as a flow layout document. **Flow layout document** * A flow document is designed to "reflow content" depending on the application. * Does not contain any information about the position of its content. -* Dynamically renders the content by application at run time. -* Example: DOCX, HTML and TEXT file formats. +* Dynamically renders the content by the application at runtime. +* Example: DOCX, HTML, and TEXT file formats. -Essential® DocIO can convert various flow document as fixed document by using our layout engine. Following conversions are supported by Essential DocIO. +Essential® DocIO can convert various flow documents into fixed documents by using our layout engine. The following conversions are supported by Essential DocIO: -* Microsoft Word file format Conversions. -* Text Conversions. -* HTML Conversions. +* Microsoft Word file format conversions. +* Text conversions. +* HTML conversions. -## HTML conversion +## HTML Conversion -Essential® DocIO supports converting the HTML file into Word document and vice versa. It supports only the HTML files that meet the validation either against XHTML 1.0 strict or XHTML 1.0 Transitional schema. +Essential® DocIO supports converting an HTML file into a Word document and vice versa. It supports only the HTML files that meet the validation requirements against either XHTML 1.0 Strict or XHTML 1.0 Transitional schema. -For further information kindly refer this [link](https://help.syncfusion.com/document-processing/word/word-library/java/html#). +For further information, kindly refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/html#). -### Supported Document elements +### Supported Document Elements -Kindly refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/html#supported-and-unsupported-items#) for the document elements and attributes that are supported by DocIO in the Word to HTML and HTML to Word conversions. +Kindly refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/html#supported-and-unsupported-items#) for the document elements and attributes that are supported by DocIO in the Word-to-HTML and HTML-to-Word conversions. -## Text file +## Text File -Essential® DocIO supports to convert the Word document into a Text file and vice versa. For further information, kindly refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/text#). \ No newline at end of file +Essential® DocIO supports converting a Word document into a text file and vice versa. For further information, kindly refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/text#). \ No newline at end of file diff --git a/java-file-formats/word-library/convert-markdown-to-word-document-in-java.md b/java-file-formats/word-library/convert-markdown-to-word-document-in-java.md index e4ea345..d2e0b33 100644 --- a/java-file-formats/word-library/convert-markdown-to-word-document-in-java.md +++ b/java-file-formats/word-library/convert-markdown-to-word-document-in-java.md @@ -1,45 +1,45 @@ --- -title: Convert Markdown to Word document in Java | DocIO | Syncfusion -description: Convert Markdown to Word document in java using Syncfusion Java Word library without Microsoft Word. +title: Convert Markdown to Word Document in Java | DocIO | Syncfusion +description: Convert Markdown to Word document in Java using Syncfusion Java Word library without Microsoft Word. platform: java-file-formats control: Word library documentation: UG --- # Markdown to Word Conversion -Markdown is a lightweight markup language that adds formatting elements to plain text documents. The Java Word library supports the conversion of Markdown to Word document and vice versa, which mostly follows the CommonMark specification and GitHub-flavored syntax. +Markdown is a lightweight markup language that adds formatting elements to plain text documents. The Java Word library supports the conversion of Markdown to Word documents and vice versa, which mostly follows the CommonMark specification and GitHub-flavored syntax. -## Convert Markdown to Word document +## Convert Markdown to Word Document -Convert an existing markdown file to a Word document (DOCX and RTF) using the Java Word library. +Convert an existing Markdown file to a Word document (DOCX and RTF) using the Java Word library. -The following code example shows how to convert Markdown to Word document. +The following code example shows how to convert Markdown to a Word document. {% tabs %} {% highlight JAVA %} -//Open an existing Markdown file. +// Open an existing Markdown file. WordDocument document = new WordDocument("Input.md", FormatType.Markdown); -//Save as a Word document. +// Save as a Word document. document.save("MarkdownToWord.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -T> You can also save the markdown file as [HTML](https://help.syncfusion.com/document-processing/word/word-library/java/html). +T> You can also save the Markdown file as [HTML](https://help.syncfusion.com/document-processing/word/word-library/java/html). -## Customize image data +## Customize Image Data -The Java Word library provides a ImageNodeVisited event, which customizes image data while importing a Markdown file. Implement the logic to customize the image data by using this ImageNodeVisited event. +The Java Word library provides an ImageNodeVisited event, which customizes image data while importing a Markdown file. Implement the logic to customize the image data by using this ImageNodeVisited event. -The following code example shows how to load image data based on the image source path when importing the Markdown files. +The following code example shows how to load image data based on the image source path when importing Markdown files. {% tabs %} {% highlight JAVA %} -//Create a Word document instance. +// Create a Word document instance. WordDocument document = new WordDocument(); -//Customize the image while importing Markdown using event. +// Customize the image while importing Markdown using the event. document.getMdImportSettings().ImageNodeVisited.add("mdImportSettings_ImageNodeVisited", new MdImageNodeVisitedEventHandler() {ListSupport delegateList = new ListSupport(MdImageNodeVisitedEventHandler.class); // Represents event handling for MdImageNodeVisitedEventHandlerCollection. @@ -47,27 +47,27 @@ public void invoke(Object sender, MdImageNodeVisitedEventArgs args) throws Excep { mdImportSettings_ImageNodeVisited(sender, args); } -// Represents the method that handles ImageNodeVisited event. +// Represents the method that handles the ImageNodeVisited event. public void dynamicInvoke(Object... args) throws Exception { mdImportSettings_ImageNodeVisited((Object) args[0], (MdImageNodeVisitedEventArgs) args[1]); } -// Represents the method that handles ImageNodeVisited event to add collection item. +// Represents the method that handles the ImageNodeVisited event to add a collection item. public void add(MdImageNodeVisitedEventHandler delegate) throws Exception { if (delegate != null) delegateList.add(delegate); } -// Represents the method that handles ImageNodeVisited event to remove collection item. +// Represents the method that handles the ImageNodeVisited event to remove a collection item. public void remove(MdImageNodeVisitedEventHandler delegate) throws Exception { if (delegate != null) delegateList.remove(delegate); } }); -//Open the Markdown file. +// Open the Markdown file. document.Open("Input.md"); -//Save as a Word document. +// Save as a Word document. document.Save("Sample.docx"); {% endhighlight %} @@ -77,14 +77,14 @@ The following code examples show the event handler to customize the image based {% tabs %} {% highlight JAVA %} -private static void mdImportSettings_ImageNodeVisited(Object sender,MdImageNodeVisitedEventArgs args)throws Exception +private static void mdImportSettings_ImageNodeVisited(Object sender, MdImageNodeVisitedEventArgs args) throws Exception { - //Set the image stream based on the image name from the input Markdown. - if(args.getUri().equals("Image_1.png")) - args.setImageStream(new FileStreamSupport("Image_1.png",FileMode.Open)); - else - if(args.getUri().equals("Image_2.png")) - args.setImageStream(new FileStreamSupport("Image_2.png",FileMode.Open)); + // Set the image stream based on the image name from the input Markdown. + if (args.getUri().equals("Image_1.png")) + args.setImageStream(new FileStreamSupport("Image_1.png", FileMode.Open)); + + else if (args.getUri().equals("Image_2.png")) + args.setImageStream(new FileStreamSupport("Image_2.png", FileMode.Open)); } {% endhighlight %} @@ -115,7 +115,7 @@ N> Hook the event handler before opening a Word document as per the above code e

Sample content for **bold text**.

@@ -126,7 +126,7 @@ N> Hook the event handler before opening a Word document as per the above code e

Sample content for *Italic text*.

@@ -148,7 +148,7 @@ N> Hook the event handler before opening a Word document as per the above code e

Sample content for ~~strike through text~~.

@@ -156,10 +156,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Subscript

@@ -167,10 +167,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Superscript

@@ -178,10 +178,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Heading 1

@@ -189,10 +189,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Heading 2

@@ -200,10 +200,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Heading 3

@@ -211,10 +211,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Heading 4

@@ -222,10 +222,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Heading 5

@@ -233,51 +233,51 @@ N> Hook the event handler before opening a Word document as per the above code e

Heading 6

@@ -299,10 +299,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Unordered List

@@ -310,10 +310,10 @@ N> Hook the event handler before opening a Word document as per the above code e

Links

@@ -322,9 +322,9 @@ N> Hook the event handler before opening a Word document as per the above code e @@ -336,7 +336,7 @@ N> Hook the event handler before opening a Word document as per the above code e

--- (three hyphen characters)

@@ -347,8 +347,8 @@ N> Hook the event handler before opening a Word document as per the above code e

![Alternate text](URL path)

@@ -359,8 +359,8 @@ N> Hook the event handler before opening a Word document as per the above code e

\(any syntax)

-
-repositories {
-   maven  {
-      //Syncfusion® maven repository to download the artifacts.
-    url "https://jars.syncfusion.com/repository/maven-public/"
+repositories {
+   maven  {
+      //Syncfusion® Maven repository to download the artifacts.
+    url "https://jars.syncfusion.com/repository/maven-public/"
}
}
-

For bold, add ** to front and back of the text.

+

For bold, add ** to the front and back of the text.

-

For Italic, add * to front and back of the text.

+

For Italic, add * to the front and back of the text.

-

For strike through, add ~~ to front and back of the text.

+

For strikethrough, add ~~ to the front and back of the text.

-

<sub>Subscript text</sub>

+

Subscript text

-

For subscript, add <sub> to the front and </sub> to the back of the text.

+

For subscript, add to the front and to the back of the text.

-

<sup>Superscript text</sup>

+

Superscript text

-

For superscript, add <sup> to the front and </sup> to the back of the text.

+

For superscript, add to the front and to the back of the text.

-

#Heading 1 content

+

# Heading 1 content

-

For heading 1, add # to start of the line.

+

For heading 1, add # to the start of the line.

-

##Heading 2 content

+

## Heading 2 content

-

For heading 2, add ## to start of the line.

+

For heading 2, add ## to the start of the line.

-

###Heading 3 content

+

### Heading 3 content

-

For heading 3, add ### to start of the line.

+

For heading 3, add ### to the start of the line.

-

####Heading 4 content

+

#### Heading 4 content

-

For heading 4, add #### to start of the line.

+

For heading 4, add #### to the start of the line.

-

#####Heading 5 content

+

##### Heading 5 content

-

For heading 5, add ##### to start of the line.

+

For heading 5, add ##### to the start of the line.

-

######Heading 6 content

+

###### Heading 6 content

-

For heading 6, add ###### to start of the line.

+

For heading 6, add ###### to the start of the line.

-

Block quotes

+

Block Quotes

-

>Block quotes text

+

> Block quotes text

-

For block quotes, add>to start of the line.

+

For block quotes, add > to the start of the line.

-

Code span

+

Code Span

`Code span text`

-

For code span, add ` to front and back of the text.

+

For code span, add ` to the front and back of the text.

-

Indented code block

+

Indented Code Block

4 spaces

-

For indented code block, add 4 spaces at the beginning of line.

+

For indented code block, add 4 spaces at the beginning of the line.

-

Fenced code block

+

Fenced Code Block

-

```
Multi line code text
Multi line code text
```

+

```
Multi-line code text
Multi-line code text
```

For fenced code block, add ``` in the new line before and after the content.

@@ -291,7 +291,7 @@ N> Hook the event handler before opening a Word document as per the above code e

1. First
2. Second

-

For ordered list, preceding the text with 1. (number with dot and one space)

+

For ordered list, precede the text with 1. (number with dot and one space).

-

- First
- second

+

- First
- Second

-

For unordered list, preceding the text with – (hyphen and space).

+

For unordered list, precede the text with – (hyphen and space).

-

Link text without title text :
[Link text](URL)
Link text with title text :
[Link text](URL , “title text”)

+

Link text without title text:
[Link text](URL)
Link text with title text:
[Link text](URL, "title text")

-

For hyperlink, enclose the link text within the brackets [ ], and then enclose the URL as first parameter and title as second parameter within the parentheses().
Note:The title text is optional.

+

For hyperlinks, enclose the link text within the brackets [ ], and then enclose the URL as the first parameter and the title as the second parameter within the parentheses ().
Note: The title text is optional.

Table Syntax in Markdown -

Create a table using the pipes and underscores as given in the syntax to create 2 x 2 table.

+

Create a table using the pipes and underscores as given in the syntax to create a 2 x 2 table.

-

You can also set column alignments using the syntax below, default it is left aligned.

+

You can also set column alignments using the syntax below; by default, it is left-aligned.

Right alignment:
Right aligned table Syntax in Markdown

Center alignment:
Center aligned table Syntax in Markdown

-

For horizontal line, add --- (three hyphens) in a new line.

+

For a horizontal line, add --- (three hyphens) in a new line.

-

For image, enclose an alternative text within the brackets [], and then link of the image source within parentheses ().

-

If URL path is base64string, then it will be preserved properly in Word document. Otherwise, you can also {{'[set image from stream while opening Markdown file.](https://help.syncfusion.com/document-processing/word/word-library/java/convert-markdown-to-word-document-in-java#customize-image-data)'| markdownify }}

+

For an image, enclose an alternative text within the brackets [], and then link the image source within parentheses ().

+

If the URL path is a base64 string, then it will be preserved properly in the Word document. Otherwise, you can also {{'[set image from stream while opening Markdown file.](https://help.syncfusion.com/document-processing/word/word-library/java/convert-markdown-to-word-document-in-java#customize-image-data)'| markdownify }}

-

Escape any markdown syntax by adding \ as prefix to the syntax.
Example:
\**non-bold text**

+

Escape any Markdown syntax by adding \ as a prefix to the syntax.
Example:
\**non-bold text**

+ \ No newline at end of file diff --git a/java-file-formats/word-library/document-object-model-representation.md b/java-file-formats/word-library/document-object-model-representation.md index de24cea..dd40300 100644 --- a/java-file-formats/word-library/document-object-model-representation.md +++ b/java-file-formats/word-library/document-object-model-representation.md @@ -1,14 +1,12 @@ --- -title: Document Object Model representation -description: This section describes about DOM structure +title: Document Object Model Representation +description: This section describes the DOM structure platform: java-file-formats control: Word Library documentation: UG --- -# Document Object Model representation - -When an existing document is opened or a new document is created, the Java Word library creates a **Document Object Model** (DOM) of the document in main memory. This object model can be used to manipulate the document as needed. - -![Document Object Model representation](DocumentObjectModelrepresentation_images/DocumentObjectModelrepresentation_img1.png) +# Document Object Model Representation +When an existing document is opened or a new document is created, the Java Word Library creates a **Document Object Model** (DOM) of the document in main memory. This object model can be used to manipulate the document as needed. +![Document Object Model Representation](DocumentObjectModelrepresentation_images/DocumentObjectModelrepresentation_img1.png) \ No newline at end of file diff --git a/java-file-formats/word-library/faq.md b/java-file-formats/word-library/faq.md index 333630e..92ad70b 100644 --- a/java-file-formats/word-library/faq.md +++ b/java-file-formats/word-library/faq.md @@ -1,6 +1,6 @@ --- -title: FAQ Section | Word library | Syncfusion -description: This section illustrates about Frequently Asked Questions in Essential Syncfusion Word library (Essential DocIO) +title: FAQ Section | Word Library | Syncfusion +description: This section illustrates Frequently Asked Questions in the Essential Syncfusion Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG @@ -11,29 +11,29 @@ The frequently asked questions in Essential®®
DocIO @@ -383,23 +383,23 @@ The following code example illustrates how to insert the bookmark by using DocIO {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument doc = new WordDocument(); -//Add new section. +// Add a new section. IWSection section = doc.addSection(); -//Add new paragraph. +// Add a new paragraph. IWParagraph paragraph = section.addParagraph(); paragraph.appendText("Simple Bookmark"); -paragraph=section.addParagraph(); +paragraph = section.addParagraph(); paragraph.appendText("Bookmark with one "); -//Insert bookmark. +// Insert bookmark. paragraph.appendBookmarkStart("one_word"); paragraph.appendText("word"); paragraph.appendBookmarkEnd("one_word"); paragraph.appendText(" selected"); -//Save the document. -doc.save("Sample.docx",FormatType.Docx); -//Close the document. +// Save the document. +doc.save("Sample.docx", FormatType.Docx); +// Close the document. doc.close(); {% endhighlight %} @@ -410,28 +410,28 @@ doc.close(); Page numbers can be added to the Word document in headers or footers. -The following code example illustrates how page numbers are inserted to the footer of the Word document by using DocIO. +The following code example illustrates how page numbers are inserted into the footer of the Word document by using DocIO. {% tabs %} {% highlight JAVA %} -//Open the Word document. -WordDocument doc = new WordDocument("Template.docx",FormatType.Docx); -//Iterate through sections. -for(Object sec_tempObj : doc.getSections()) -{ - WSection sec = (WSection)sec_tempObj; +// Open the Word document. +WordDocument doc = new WordDocument("Template.docx", FormatType.Docx); +// Iterate through sections. +for (Object sec_tempObj : doc.getSections()) { + + WSection sec = (WSection) sec_tempObj; IWParagraph para = sec.addParagraph(); - //Append page field to the paragraph. - para.appendField("footer",FieldType.FieldPage); + // Append page field to the paragraph. + para.appendField("footer", FieldType.FieldPage); para.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); sec.getPageSetup().setPageNumberStyle(PageNumberStyle.Arabic); - //Add paragraph to footer. + // Add paragraph to footer. sec.getHeadersFooters().getFooter().getParagraphs().add(para); } -//Save the document. -doc.save("Sample.docx",FormatType.Docx); -//Close the document. +// Save the document. +doc.save("Sample.docx", FormatType.Docx); +// Close the document. doc.close(); {% endhighlight %} @@ -439,9 +439,9 @@ doc.close(); ### Headers and Footers -The headers and footers can be inserted with text, graphics, and any other information that is contained in the document. +Headers and footers can be inserted with text, graphics, and any other information contained in the document. -You can set the header and footer by using the HeadersFooters property in the Word document section. To access a particular header/footer, you can use the following properties of `WHeadersFooters` class: +You can set the header and footer by using the HeadersFooters property in the Word document section. To access a particular header/footer, you can use the following properties of the `WHeadersFooters` class: * FirstPageHeader * FirstPageFooter @@ -453,26 +453,26 @@ You can set the header and footer by using the HeadersFooters property in the Wo {% tabs %} {% highlight JAVA %} -//Open a Word document. +// Open a Word document. WordDocument doc = new WordDocument("Template.docx"); -//Add header and footer to each section in the document. -for(Object sec_tempObj : doc.getSections()) -{ - //Header. - WSection sec = (WSection)sec_tempObj; +// Add header and footer to each section in the document. +for (Object sec_tempObj : doc.getSections()) { + + // Header. + WSection sec = (WSection) sec_tempObj; WParagraph para = new WParagraph(doc); - para.appendField("page",FieldType.FieldPage); + para.appendField("page", FieldType.FieldPage); para.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Right); sec.getHeadersFooters().getHeader().getParagraphs().add(para); - //Footer. + // Footer. WParagraph para1 = new WParagraph(doc); para1.appendText("Internal"); para1.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Left); sec.getHeadersFooters().getFooter().getParagraphs().add(para1); } -//Save the document. -doc.save("Sample.docx",FormatType.Docx); -//Close the document. +// Save the document. +doc.save("Sample.docx", FormatType.Docx); +// Close the document. doc.close(); {% endhighlight %} @@ -480,138 +480,138 @@ doc.close(); ### Tables -Tables are used to organize information and to display the information in rows and columns. You can also add images or even other tables to the table. +Tables are used to organize information and display it in rows and columns. You can also add images or even other tables to a table. -The following code example shows how to insert an empty table to a Word document. The `resetCells()` method is used to specify the number of rows and columns in a table. +The following code example shows how to insert an empty table into a Word document. The `resetCells()` method is used to specify the number of rows and columns in a table. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); IWSection section = document.addSection(); -//Add a table to the document. +// Add a table to the document. IWTable table = section.addTable(); table.resetCells(3, 2); -//Save the document. -document.save("Sample.docx",FormatType.Docx); -//Close the document. +// Save the document. +document.save("Sample.docx", FormatType.Docx); +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -N> For more information on creating tables using DocIO, refer to online documentation link: +N> For more information on creating tables using DocIO, refer to the online documentation link: [Working with Tables](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-tables) ### Comments -Comments are used to include additional information to a paragraph or text in a Word document. Comments can be added or modified whenever needed and deleted when the comment has served its purpose. +Comments are used to include additional information in a paragraph or text in a Word document. Comments can be added or modified whenever needed and deleted when the comment has served its purpose. -You can insert comments to a paragraph or text in a Word document by using DocIO. The following code example shows how to insert comments to a Word document. +You can insert comments into a paragraph or text in a Word document by using DocIO. The following code example shows how to insert comments into a Word document. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument doc = new WordDocument(); IWSection section = doc.addSection(); -//Add a paragraph to the document. +// Add a paragraph to the document. IWParagraph para = section.addParagraph(); para.appendText("New Text"); -//Add comment to the paragraph. +// Add a comment to the paragraph. para.appendComment("Comment goes here"); -//Save the document. +// Save the document. doc.save("Sample.docx", FormatType.Docx); {% endhighlight %} {% endtabs %} -N> For more information on working with the comments using Java Word library, you can refer to the online documentation link: +N> For more information on working with comments using the Java Word library, you can refer to the online documentation link: [Working with Comments](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-comments) ## How to check whether a Word document contains tracked changes or not? -You can check whether a Word document contains tracked changes by using `HasChanges` property in Essential® DocIO. +You can check whether a Word document contains tracked changes by using the `HasChanges` property in Essential® DocIO. The following code example shows how to check whether a Word document contains tracked changes. {% tabs %} {% highlight JAVA %} -//Open an existing Word document. +// Open an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Get a flag which denotes whether the Word document has track changes. +// Get a flag that denotes whether the Word document has tracked changes. boolean hasChanges = document.getHasChanges(); -//When the document has track changes, accepts all changes. +// When the document has tracked changes, accept all changes. if (hasChanges) document.getRevisions().acceptAll(); -//Save and close the document. +// Save and close the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -## How to accept or reject track changes of specific type in the Word document? +## How to accept or reject tracked changes of a specific type in the Word document? -You can **accept or reject track changes by revision type** in the tracked changes Word document. +You can **accept or reject tracked changes by revision type** in the tracked changes Word document. -For example, if you like to accept or reject changes of specific revision type (insertions, deletions, formatting, move to, or move from), you can iterate into the revisions in Word document and then accept or reject the particular revision type using Essential® DocIO. +For example, if you want to accept or reject changes of a specific revision type (insertions, deletions, formatting, move to, or move from), you can iterate into the revisions in the Word document and then accept or reject the particular revision type using Essential® DocIO. -The following code example shows how to accept or reject track changes of specific type in the Word document . +The following code example shows how to accept or reject tracked changes of a specific type in the Word document. {% tabs %} {% highlight JAVA %} -//Open an existing Word document. +// Open an existing Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Iterate into all the revisions in Word document -for (int i = document.getRevisions().getCount() - 1; i >= 0; i--) -{ - // Get the type of the track changes revision. +// Iterate over all the revisions in the Word document. +for (int i = document.getRevisions().getCount() - 1; i >= 0; i--) { + + // Get the type of the tracked changes revision. RevisionType revisionType = document.getRevisions().get(i).getRevisionType(); - //Accept only insertion and Move from revisions changes. + // Accept only insertion and MoveFrom revisions. if (revisionType == RevisionType.Insertions || revisionType == RevisionType.MoveFrom) document.getRevisions().get(i).accept(); - //Reset to last item when accept the moving related revisions. + // Reset to the last item when accepting the moving-related revisions. if (i > document.getRevisions().getCount() - 1) i = document.getRevisions().getCount(); } -//Save and close the document. +// Save and close the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -## How to enable track changes for Word document? +## How to enable track changes for a Word document? -TrackChanges is used to keep track of the changes made to a Word document. This can be enabled by using the TrackChanges property of the Word document. +TrackChanges is used to keep track of the changes made to a Word document. This can be enabled by using the `TrackChanges` property of the Word document. -The following code example shows how to enable track changes of the document. +The following code example shows how to enable track changes in the document. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Append text to the paragraph. -IWTextRange text = paragraph.appendText("This sample illustrates how to track the changes made to the word document. "); -//Set font name and size for text. +// Append text to the paragraph. +IWTextRange text = paragraph.appendText("This sample illustrates how to track the changes made to the Word document. "); +// Set font name and size for the text. text.getCharacterFormat().setFontName("Times New Roman"); text.getCharacterFormat().setFontSize(14); -text = paragraph.appendText("This track changes is useful in shared environment."); +text = paragraph.appendText("This track changes is useful in a shared environment."); text.getCharacterFormat().setFontSize(12); -//Turn on the track changes option. +// Turn on the track changes option. document.setTrackChanges(true); -//Save and close the document. +// Save and close the document. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} diff --git a/java-file-formats/word-library/find-item-in-word-document.md b/java-file-formats/word-library/find-item-in-word-document.md index 9dabab1..52af889 100644 --- a/java-file-formats/word-library/find-item-in-word-document.md +++ b/java-file-formats/word-library/find-item-in-word-document.md @@ -8,35 +8,35 @@ documentation: UG # Find item in Word document -Just like you can search for a text in a Word document, you can also search for an item (like image, content control, textbox, and so on). The Java Word library supports to find an item in Word document based on its properties. With this functionality, you can: +Just like you can search for text in a Word document, you can also search for an item (like an image, content control, textbox, and so on). The Java Word library supports finding an item in a Word document based on its properties. With this functionality, you can: * Find the first item based on one property. -* Find the first item based on multiple properties +* Find the first item based on multiple properties. * Find all the items based on one property. * Find all the items based on multiple properties. ## Find item by property -Using findItemByProperty API, find the first item in the Word document that has the specified property name and value. +Using the `findItemByProperty` API, find the first item in the Word document that has the specified property name and value. The following code example illustrates how to find the first item based on one property. {% tabs %} {% highlight JAVA %} -//Load the input Word document. -WordDocument document = new WordDocument("Input.docx",FormatType.Docx); -//Find picture by alternative text. +// Load the input Word document. +WordDocument document = new WordDocument("Input.docx", FormatType.Docx); +// Find picture by alternative text. WPicture picture = (WPicture) document.findItemByProperty(EntityType.Picture, "AlternativeText", "Logo"); -//Resize the picture. -if(picture != null) -{ - picture.setHeight((float)75); - picture.setWidth((float)100); +// Resize the picture. +if (picture != null) { + + picture.setHeight((float) 75); + picture.setWidth((float) 100); } -//Save the Word document. -document.save("Sample.docx",FormatType.Docx); -//Close the Word document. +// Save the Word document. +document.save("Sample.docx", FormatType.Docx); +// Close the Word document. document.close(); {% endhighlight %} @@ -44,25 +44,25 @@ document.close(); ## Find item by properties -Using findItemByProperties API, find the first item in the Word document based on multiple property names and their corresponding values. +Using the `findItemByProperties` API, find the first item in the Word document based on multiple property names and their corresponding values. -The following code example illustrates how to find the first item in Word document based on multiple property names and their corresponding values. +The following code example illustrates how to find the first item in a Word document based on multiple property names and their corresponding values. {% tabs %} {% highlight JAVA %} -//Load the input Word document. -WordDocument document = new WordDocument("Input.docx",FormatType.Docx); -String[] propertyNames=new String[]{"Title","Rows.Count"}; -String[] propertyValues =new String[]{"SupplierDetails","6"}; -//Find the table by Title and Rows Count. -WTable table = (WTable)document.findItemByProperties(EntityType.Table,propertyNames,propertyValues); -//Remove the table in document. -if(table != null) - table.getOwnerTextBody().getChildEntities().remove(table); -//Save the Word document. -document.save("Sample.docx",FormatType.Docx); -//Close the Word document. +// Load the input Word document. +WordDocument document = new WordDocument("Input.docx", FormatType.Docx); +String[] propertyNames = new String[]{"Title", "Rows.Count"}; +String[] propertyValues = new String[]{"SupplierDetails", "6"}; +// Find the table by Title and Rows Count. +WTable table = (WTable) document.findItemByProperties(EntityType.Table, propertyNames, propertyValues); +// Remove the table in the document. +if (table != null) + table.getOwnerTextBody().getChildEntities().remove(table); +// Save the Word document. +document.save("Sample.docx", FormatType.Docx); +// Close the Word document. document.close(); {% endhighlight %} @@ -70,37 +70,37 @@ document.close(); ## Find all items by property -Using findAllItemsByProperty API, find all the items in the Word document that has the specified property name and value. +Using the `findAllItemsByProperty` API, find all the items in the Word document that have the specified property name and value. -The following code example illustrates how to find all the items in Word document based on one property. +The following code example illustrates how to find all the items in a Word document based on one property. {% tabs %} {% highlight JAVA %} -//Load the input Word document. -WordDocument document = new WordDocument("Input.docx",FormatType.Docx); -//Find all footnote and endnote by EntityType in Word document. -ListSupport footNotes = document.findAllItemsByProperty(EntityType.Footnote,null,null); -//Remove the footnotes and endnotes. -for(int i = 0;i footNotes = document.findAllItemsByProperty(EntityType.Footnote, null, null); +// Remove the footnotes and endnotes. +for (int i = 0; i < footNotes.getCount(); i++) { + + WFootnote footnote = (WFootnote) footNotes.get(i); footnote.getOwnerParagraph().getChildEntities().remove(footnote); } -//Find all fields by FieldType. -ListSupport fields = document.findAllItemsByProperty(EntityType.Field,"FieldType",FieldType.FieldHyperlink.toString()); -//Iterate the hyperlink field and change URL. -for(int i = 0;i fields = document.findAllItemsByProperty(EntityType.Field, "FieldType", FieldType.FieldHyperlink.toString()); +// Iterate through the hyperlink fields and change the URL. +for (int i = 0; i < fields.getCount(); i++) { + + // Create a hyperlink instance from the field to manipulate the hyperlink. + Hyperlink hyperlink = new Hyperlink((WField) fields.get(i)); + // Modify the URI of the hyperlink. + if (hyperlink.getType().getEnumValue() == HyperlinkType.WebLink.getEnumValue() && hyperlink.getTextToDisplay().equals("HTML")) + hyperlink.setUri("http://www.w3schools.com/"); } -//Save the Word document. -document.save("Sample.docx",FormatType.Docx); -//Close the Word document. +// Save the Word document. +document.save("Sample.docx", FormatType.Docx); +// Close the Word document. document.close(); {% endhighlight %} @@ -108,52 +108,52 @@ document.close(); ## Find all items by properties -Using findAllItemsByProperties API, find all the items in the Word document based on multiple property names and their corresponding values. +Using the `findAllItemsByProperties` API, find all the items in the Word document based on multiple property names and their corresponding values. -The following code example illustrates how to find all the items in Word document based on multiple property names and their corresponding values. +The following code example illustrates how to find all the items in a Word document based on multiple property names and their corresponding values. {% tabs %} {% highlight JAVA %} -//Load the input Word document. -WordDocument document = new WordDocument("Input.docx",FormatType.Docx); -String[] propertyNames = {"ContentControlProperties.Title","ContentControlProperties.Tag"}; -String[] propertyValues = {"CompanyName","CompanyName"}; -//Find all block content controls by Title and Tag. -ListSupport blockContentControls = document.findAllItemsByProperties(EntityType.BlockContentControl,propertyNames,propertyValues); -//Iterate the block content controls and remove the block content controls. -for(int i = 0;i blockContentControls = document.findAllItemsByProperties(EntityType.BlockContentControl, propertyNames, propertyValues); +// Iterate through the block content controls and remove them. +for (int i = 0; i < blockContentControls.getCount(); i++) { + + BlockContentControl blockContentControl = (BlockContentControl) blockContentControls.get(i); blockContentControl.getOwnerTextBody().getChildEntities().remove(blockContentControl); } -propertyNames=new String[]{"ContentControlProperties.Title","ContentControlProperties.Tag"}; -propertyValues=new String[]{"Contact","Contact"}; -//Find all the inline content controls by Title and Tag. -ListSupport inlineContentControls = document.findAllItemsByProperties(EntityType.InlineContentControl,propertyNames,propertyValues); -//Iterate the inline content controls and remove the inline content controls. -for(int i = 0;i inlineContentControls = document.findAllItemsByProperties(EntityType.InlineContentControl, propertyNames, propertyValues); +// Iterate through the inline content controls and remove them. +for (int i = 0; i < inlineContentControls.getCount(); i++) { + + InlineContentControl inlineContentControl = (InlineContentControl) inlineContentControls.get(i); inlineContentControl.getOwnerParagraph().getChildEntities().remove(inlineContentControl); } -propertyNames=new String[]{"CharacterFormat.Bold","CharacterFormat.Italic"}; -propertyValues=new String[]{String.valueOf(true),String.valueOf(true)}; -//Find all the bold and italic text. -ListSupport textRanges = document.findAllItemsByProperties(EntityType.TextRange,propertyNames,propertyValues); -//Iterate the textRanges and remove the bold and italic. -for(int i = 0;i textRanges = document.findAllItemsByProperties(EntityType.TextRange, propertyNames, propertyValues); +// Iterate through the text ranges and remove bold and italic formatting. +for (int i = 0; i < textRanges.getCount(); i++) { + + WTextRange textRange = (WTextRange) textRanges.get(i); textRange.getCharacterFormat().setBold(false); textRange.getCharacterFormat().setItalic(false); } -//Save the Word document. -document.save("Sample.docx",FormatType.Docx); -//Close the Word document. +// Save the Word document. +document.save("Sample.docx", FormatType.Docx); +// Close the Word document. document.close(); {% endhighlight %} {% endtabs %} -T> Passing null for both the property names and property values in the above APIs, you can also find an item in a Word document without relying on any property. \ No newline at end of file +T> By passing null for both the property names and property values in the above APIs, you can also find an item in a Word document without relying on any property. \ No newline at end of file diff --git a/java-file-formats/word-library/getting-started.md b/java-file-formats/word-library/getting-started.md index 0187cd0..e9cb60b 100644 --- a/java-file-formats/word-library/getting-started.md +++ b/java-file-formats/word-library/getting-started.md @@ -1,41 +1,41 @@ --- -title: Create a simple Word document in Java | Syncfusion -description: This section illustrate how to create a new Word document from scratch in Java using Syncfusion Java Word library (Essential DocIO) +title: Create a Simple Word Document in Java | Syncfusion +description: This section illustrates how to create a new Word document from scratch in Java using the Syncfusion Java Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG --- -# Getting Started of Word library (DocIO) +# Getting Started with Word Library (DocIO) -In this page, you can see how to create a simple Word document by using Syncfusion® Java Word library APIs. For creating and manipulating a Word document, the following jar files are required to be referenced in your Java application. +On this page, you can learn how to create a simple Word document using the Syncfusion® Java Word library APIs. To create and manipulate a Word document, the following JAR files need to be referenced in your Java application. - - + + +This JAR contains the core features needed for creating, reading, and manipulating a Word document.

+This JAR contains common functionalities required for file format libraries.

Jar files

Short description

JAR Files

Short Description

syncfusion-docio

-This jar contains the core features needed for creating, reading, manipulating a Word document.

syncfusion-javahelper

-This jar contains common functionalities required for file format libraries.

-Get the dependent jar files by installing [file formats controls](https://www.syncfusion.com/sales/teamlicense). You can find the required jars in the build installed drive. +Get the dependent JAR files by installing [file formats controls](https://www.syncfusion.com/sales/teamlicense). You can find the required JARs in the build-installed drive. -**Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\ {Platform}\ {version}\JarFiles +**Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\{Platform}\{version}\JarFiles **Example:** C:\Program Files (x86)\Syncfusion\Essential Studio\FileFormats\18.3.0.35\JarFiles -N> 1. Starting with v19.1.0.x, if you reference Syncfusion® Java packages from trial setup or from the maven repository, you also have to add "syncfusion.licensing" package reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion® license key in your application to use our components. +N> 1. Starting with v19.1.0.x, if you reference Syncfusion® Java packages from the trial setup or the Maven repository, you also need to add the "syncfusion.licensing" package reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to learn about registering the Syncfusion® license key in your application to use our components. -Import the following package in your Java application. +Import the following packages into your Java application. {% tabs %} @@ -43,20 +43,20 @@ Import the following package in your Java application. import com.syncfusion.docio.*; -import com.synfusion.javahelper.system.*; +import com.syncfusion.javahelper.system.*; {% endhighlight %} {% endtabs %} -## Creating a new Word document with few lines of code +## Creating a New Word Document with a Few Lines of Code -The following code example explains how to create a new Word document with a few lines of the code. +The following code example demonstrates how to create a new Word document with a few lines of code. {% tabs %} {% highlight JAVA %} -//Creates an instance of WordDocument Instance (Empty Word Document). +//Creates an instance of WordDocument (Empty Word Document). WordDocument document = new WordDocument(); //Add a section and paragraph in the empty document. document.ensureMinimal(); @@ -69,64 +69,64 @@ document.close(); {% endtabs %} -## Creating a new Word document from scratch with basic elements +## Creating a New Word Document from Scratch with Basic Elements -An entire Word document is represented by an instance of the `WordDocument` and it is the root element of DocIO’s DOM. The Word document contains a collection of sections. A Word document must contain at least one section. +An entire Word document is represented by an instance of the `WordDocument`, and it is the root element of DocIO’s DOM. The Word document contains a collection of sections. A Word document must contain at least one section. -A section represents a group of paragraphs, tables, and more, that have a specific set of properties used to define the pages, a number of columns, headers, and footers, and more, that decides how the text appears. A section should contain at least one paragraph in this body. +A section represents a group of paragraphs, tables, and more, that have a specific set of properties used to define the pages, number of columns, headers, and footers, and more, that decide how the text appears. A section should contain at least one paragraph in its body. -The following code example explains how to add a section into a `WordDocument` instance. +The following code example demonstrates how to add a section to a `WordDocument` instance. {% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument Instance (Empty Word Document). +//Create an instance of WordDocument (Empty Word Document). WordDocument document = new WordDocument(); //Add a new section into the Word document. IWSection section = document.addSection(); -//Specifies the page margins. +//Specify the page margins. section.getPageSetup().getMargins().setAll(50); {% endhighlight %} {% endtabs %} -All the textual contents in a Word document are represented by the paragraphs. Within the paragraph, the textual contents are grouped into one or more child elements such as text range, field, and more. Each text range represents a region of text with a common set of rich text formatting. +All the textual contents in a Word document are represented by paragraphs. Within a paragraph, the textual contents are grouped into one or more child elements such as text ranges, fields, and more. Each text range represents a region of text with a common set of rich text formatting. -The following code example explains how to add a paragraph into a Word document. +The following code example demonstrates how to add a paragraph to a Word document. {% tabs %} {% highlight JAVA %} -//Add a new simple paragraph into the section. +//Add a new simple paragraph to the section. IWParagraph firstParagraph = section.addParagraph(); //Set the paragraph's horizontal alignment as justify. firstParagraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Justify); -//Add a text range into the paragraph. +//Add a text range to the paragraph. IWTextRange firstTextRange = firstParagraph.appendText("AdventureWorks Cycles,"); -//set the font formatting of the text range. +//Set the font formatting of the text range. firstTextRange.getCharacterFormat().setBoldBidi(true); firstTextRange.getCharacterFormat().setFontName("Calibri"); -firstTextRange.getCharacterFormat().setFontSize(14) ; -//Add another text range into the paragraph. +firstTextRange.getCharacterFormat().setFontSize(14); +//Add another text range to the paragraph. IWTextRange secondTextRange = firstParagraph.appendText(" the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."); -//set the font formatting of the text range. +//Set the font formatting of the text range. secondTextRange.getCharacterFormat().setFontName("Calibri"); secondTextRange.getCharacterFormat().setFontSize(11); {% endhighlight %} {% endtabs %} -The following code example shows how to add an image into the Word document. +The following code example demonstrates how to add an image to the Word document. {% tabs %} {% highlight JAVA %} -//Add another paragraph and aligns it as a center. +//Add another paragraph and align it as center. IWParagraph paragraph = section.addParagraph(); paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); -//Set after spacing for paragraph. +//Set after spacing for the paragraph. paragraph.getParagraphFormat().setAfterSpacing(6); -//Add a picture into the paragraph. +//Add a picture to the paragraph. IWPicture picture = paragraph.appendPicture(new FileInputStream("DummyProfilePicture.jpg")); //Specify the size of the picture. picture.setHeight(86); @@ -135,62 +135,62 @@ picture.setWidth(81); {% endtabs %} -A table is another important element in the Word that contains a set of paragraphs arranged in rows and columns. You can create a simple as well as a complex table by using the Essential® DocIO’s API. The following code example creates a simple table and adds content to it. Each table cell must contain at least one paragraph. +A table is another important element in Word that contains a set of paragraphs arranged in rows and columns. You can create a simple or a complex table using the Essential® DocIO’s API. The following code example creates a simple table and adds content to it. Each table cell must contain at least one paragraph. {% tabs %} {% highlight JAVA %} -//Add a table into the Word document. +//Add a table to the Word document. IWTable table = section.addTable(); //Create the specified number of rows and columns. -table.resetCells(2,2); +table.resetCells(2, 2); //Access the instance of the cell (first row, first cell). WTableCell firstCell = table.getRows().get(0).getCells().get(0); -//Specifies the width of the cell. +//Specify the width of the cell. firstCell.setWidth(150); -//Add a paragraph into the cell; a cell must have atleast 1 paragraph. -paragraph=firstCell.addParagraph(); +//Add a paragraph to the cell; a cell must have at least one paragraph. +paragraph = firstCell.addParagraph(); IWTextRange textRange = paragraph.appendText("Profile picture"); textRange.getCharacterFormat().setBold(true); -//Access the instance of cell (first row, second cell). +//Access the instance of the cell (first row, second cell). WTableCell secondCell = table.getRows().get(0).getCells().get(1); secondCell.setWidth(330); -paragraph=secondCell.addParagraph(); +paragraph = secondCell.addParagraph(); //Add text to the paragraph. -textRange=paragraph.appendText("Description"); +textRange = paragraph.appendText("Description"); textRange.getCharacterFormat().setBold(true); -firstCell=table.getRows().get(1).getCells().get(0); +firstCell = table.getRows().get(1).getCells().get(0); firstCell.setWidth(150); -//Add image to the paragraph. -paragraph=firstCell.addParagraph(); -//Set after spacing for paragraph. +//Add an image to the paragraph. +paragraph = firstCell.addParagraph(); +//Set after spacing for the paragraph. paragraph.getParagraphFormat().setAfterSpacing(6); IWPicture profilePicture = paragraph.appendPicture(new FileInputStream("DummyProfilePicture.jpg")); //Set the height and width for the image. profilePicture.setHeight(98); profilePicture.setWidth(95); -//Access the instance of cell (second row, second cell) and adds text. -secondCell=table.getRows().get(1).getCells().get(1); +//Access the instance of the cell (second row, second cell) and add text. +secondCell = table.getRows().get(1).getCells().get(1); secondCell.setWidth(330); -paragraph=secondCell.addParagraph(); -textRange=paragraph.appendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."); +paragraph = secondCell.addParagraph(); +textRange = paragraph.appendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."); {% endhighlight %} {% endtabs %} -Essential® DocIO allows you to create simple and multi-level lists. The following code sample explains how to create a numbered and bulleted list. +Essential® DocIO allows you to create simple and multi-level lists. The following code sample demonstrates how to create a numbered and bulleted list. {% tabs %} {% highlight JAVA %} //Write the default numbered list. paragraph = section.addParagraph(); -//Set before spacing for paragraph. +//Set before spacing for the paragraph. paragraph.getParagraphFormat().setBeforeSpacing(6); paragraph.appendText("Level 0"); //Apply the default numbered list formats. paragraph.getListFormat().applyDefNumberedStyle(); -//Applies list formatting. +//Apply list formatting. paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setLeftIndent(36); paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setFirstLineIndent(-18); paragraph.getListFormat().getCurrentListLevel().setNumberAlignment(ListNumberAlignment.Left); @@ -200,7 +200,7 @@ paragraph.appendText("Level 1"); paragraph.getListFormat().continueListNumbering(); //Increment the list level. paragraph.getListFormat().increaseIndentLevel(); -//Applies list formatting. +//Apply list formatting. paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setLeftIndent(72); paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setFirstLineIndent(-18); paragraph.getListFormat().getCurrentListLevel().setNumberAlignment(ListNumberAlignment.Left); @@ -209,7 +209,7 @@ paragraph.appendText("Level 0"); //Decrement the list level. paragraph.getListFormat().continueListNumbering(); paragraph.getListFormat().decreaseIndentLevel(); -//Applies list formatting. +//Apply list formatting. paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setLeftIndent(36); paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setFirstLineIndent(-18); paragraph.getListFormat().getCurrentListLevel().setNumberAlignment(ListNumberAlignment.Left); @@ -219,7 +219,7 @@ paragraph = section.addParagraph(); paragraph.appendText("Level 0"); //Apply the default bulleted list formats. paragraph.getListFormat().applyDefBulletStyle(); -//Applies list formatting. +//Apply list formatting. paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setLeftIndent(36); paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setFirstLineIndent(-18); paragraph.getListFormat().getCurrentListLevel().setNumberAlignment(ListNumberAlignment.Left); @@ -229,7 +229,7 @@ paragraph.appendText("Level 1"); paragraph.getListFormat().continueListNumbering(); //Increment the list level. paragraph.getListFormat().increaseIndentLevel(); -//Applies list formatting. +//Apply list formatting. paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setLeftIndent(72); paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setFirstLineIndent(-18); paragraph.getListFormat().getCurrentListLevel().setNumberAlignment(ListNumberAlignment.Left); @@ -239,7 +239,7 @@ paragraph.appendText("Level 0"); paragraph.getListFormat().continueListNumbering(); //Decrement the list level. paragraph.getListFormat().decreaseIndentLevel(); -//Applies list formatting. +//Apply list formatting. paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setLeftIndent(36); paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().setFirstLineIndent(-18); paragraph.getListFormat().getCurrentListLevel().setNumberAlignment(ListNumberAlignment.Left); @@ -248,12 +248,12 @@ section.addParagraph(); {% endtabs %} -Finally, save the document in the file system and close its instance. +Finally, save the document to the file system and close its instance. {% tabs %} {% highlight JAVA %} -//Save the document in the given name and format. -document.save(outputFileName,FormatType.Docx); +//Save the document with the given name and format. +document.save(outputFileName, FormatType.Docx); //Release the resources occupied by the WordDocument instance. document.close(); {% endhighlight %} @@ -265,144 +265,144 @@ The resultant Word document looks as follows. ![Creating a new Word document from scratch with basic elements](GettingStarted_images/GettingStarted_img1.png) -## Performing Mail merge +## Performing Mail Merge -Essential® DocIO allows you to generate documents by filling data in the template document from the data source. Mail merge operation automatically maps the column name in the data source and names of the merge fields in the template Word document and fills the data. +Essential® DocIO allows you to generate documents by filling data in the template document from the data source. The Mail merge operation automatically maps the column names in the data source and the names of the merge fields in the template Word document and fills the data. -The following data sources are supported by the Essential® DocIO for performing the Mail merge. +The following data sources are supported by Essential® DocIO for performing the Mail merge: * String Arrays * DataSet * DataTable -Also, you can perform more than one Mail merge operations over the same template to generate documents as per your requirement. +Additionally, you can perform more than one Mail merge operation on the same template to generate documents as per your requirements. Follow the given steps to perform a simple Mail merge in a Word document. -Let’s consider that you have a template Word document with the merge fields as shown. +Let’s consider that you have a template Word document with the merge fields as shown below: ![Performing Mail merge input document](GettingStarted_images/GettingStarted_img2.png) -The `MailMerge` class provides various overloads for the `execute` method to perform a Mail merge from the various data source. The Mail merge operation replaces the matching merge fields with the respective data. +The `MailMerge` class provides various overloads for the `execute` method to perform a Mail merge from various data sources. The Mail merge operation replaces the matching merge fields with the respective data. -The following code example shows how to perform a simple Mail merge by using a string array. +The following code example shows how to perform a simple Mail merge using a string array. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Load the template document with the required merge fields. +// Load the template document with the required merge fields. WordDocument document = new WordDocument("..\\SimpleMailMergeTemplate.docx"); -//Initialize the string array with field names. +// Initialize the string array with field names. String[] fieldNames = new String[] {"FirstName", "LastName", "Email", "Country"}; -//Initialize the string array with field values. +// Initialize the string array with field values. String[] fieldValues = new String[] {"John", "Smith", "john_smith@domain.com", "USA"}; -//Executes the Mail merge operation that replaces the matching field names with field values respectively. +// Execute the Mail merge operation that replaces the matching field names with field values respectively. document.getMailMerge().execute(fieldNames, fieldValues); -//Save and close the WordDocument instance. +// Save and close the WordDocument instance. document.save("Result.docx"); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The resultant Word document looks as follows. +The resultant Word document looks as follows: ![Performing Mail merge output document](GettingStarted_images/GettingStarted_img3.png) -### Simple Mail merge with Group +### Simple Mail Merge with Group -You can perform a Mail merge with the group to append multiple records from the data source into a single document. The group is a part of the document enclosed by two special merge fields named «TableStart:TableName» and «TableEnd:TableName» +You can perform a Mail merge with a group to append multiple records from the data source into a single document. The group is a part of the document enclosed by two special merge fields named «TableStart:TableName» and «TableEnd:TableName». * «TableStart:TableName»: Denotes the start of the group. * «TableEnd:TableName»: Denotes the end of the group. The region between these two merge fields gets repeated for every record from the data source. -For example – let’s consider that you have a template document as shown. +For example, let’s consider that you have a template document as shown below: ![Simple Mail merge with Group input document](GettingStarted_images/GettingStarted_img4.png) -Here in this template, the employees are the group name and the exact same name should be used while performing the Mail merge through code. There are two special merge fields “TableStart:Employees” and “TableEnd:Employees” to denote the start and end of the Mail merge group. +In this template, "Employees" is the group name, and the exact same name should be used while performing the Mail merge through code. There are two special merge fields: "TableStart:Employees" and "TableEnd:Employees" to denote the start and end of the Mail merge group. -To merge an image in the replace of a merge field, you need to add a prefix (“Image:”)the merge field name. +To merge an image in place of a merge field, you need to add a prefix (“Image:”) to the merge field name. -For example, the merge field name should be like “<>”(<>) +For example, the merge field name should be like "<>" (<>). The following code example shows how to perform a Mail merge with objects. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Loads an existing Word document into DocIO instance. +// Load an existing Word document into a DocIO instance. WordDocument document = new WordDocument("EmployeesReportDemo.docx"); -//Gets the employee details as IEnumerable collection. +// Get the employee details as an IEnumerable collection. ListSupport employeeList = getEmployees(); -//Uses the mail merge events handler for image fields. +// Use the mail merge events handler for image fields. document.getMailMerge().MergeImageField.add("mergeField_EmployeeImage", new MergeImageFieldEventHandler() { ListSupport delegateList = new ListSupport( MergeImageFieldEventHandler.class); -//Represents event handling for MergeFieldEventHandlerCollection. +// Represents event handling for MergeFieldEventHandlerCollection. public void invoke(Object sender, MergeImageFieldEventArgs args) throws Exception { mergeField_EmployeeImage(sender, args); } -//Represents the method that handles MergeField event. +// Represents the method that handles the MergeField event. public void dynamicInvoke(Object... args) throws Exception { mergeField_EmployeeImage((Object) args[0], (MergeImageFieldEventArgs) args[1]); } -//Represents the method that handles MergeField event to add collection item. +// Represents the method that handles the MergeField event to add a collection item. public void add(MergeImageFieldEventHandler delegate) throws Exception { if (delegate != null) delegateList.add(delegate); } -//Represents the method that handles MergeField event to remove collection item. +// Represents the method that handles the MergeField event to remove a collection item. public void remove(MergeImageFieldEventHandler delegate) throws Exception { if (delegate != null) delegateList.remove(delegate); } }); -//Creates an instance of MailMergeDataTable by specifying MailMerge group name and IEnumerable collection. -MailMergeDataTable dataSource = new MailMergeDataTable("Employees",employeeList); -//Executes the mail merge for group. +// Create an instance of MailMergeDataTable by specifying the MailMerge group name and IEnumerable collection. +MailMergeDataTable dataSource = new MailMergeDataTable("Employees", employeeList); +// Execute the mail merge for the group. document.getMailMerge().executeGroup(dataSource); -//Saves and closes the WordDocument instance. +// Save and close the WordDocument instance. document.save("Sample.docx"); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The following code example shows getEmployees method which is used to get data for mail merge. +The following code example shows the getEmployees method, which is used to get data for the Mail merge. -{% tabs %} +{% tabs %} {% highlight JAVA %} -public ListSupport getEmployees()throws Exception +public ListSupport getEmployees() throws Exception { ListSupport employees = new ListSupport(Employee.class); - employees.add(new Employee("Nancy","Smith","Sales Representative","505 - 20th Ave. E. Apt. 2A,","Seattle","WA","USA","Nancy.png")); - employees.add(new Employee("Andrew","Fuller","Vice President, Sales","908 W. Capital Way","Tacoma","WA","USA","Andrew.png")); + employees.add(new Employee("Nancy", "Smith", "Sales Representative", "505 - 20th Ave. E. Apt. 2A,", "Seattle", "WA", "USA", "Nancy.png")); + employees.add(new Employee("Andrew", "Fuller", "Vice President, Sales", "908 W. Capital Way", "Tacoma", "WA", "USA", "Andrew.png")); return employees; } {% endhighlight %} {% endtabs %} -The following code example shows how to bind the image from file system during Mail merge process by using MergeImageFieldEventHandler. +The following code example shows how to bind an image from the file system during the Mail merge process by using MergeImageFieldEventHandler. -{% tabs %} +{% tabs %} {% highlight JAVA %} private void mergeField_EmployeeImage(Object sender, MergeImageFieldEventArgs args) throws Exception { - //Binds image from file system during mail merge. + // Bind image from the file system during Mail merge. if ((args.getFieldName()).equals("Photo")) { String ProductFileName = args.getFieldValue().toString(); - //Gets the image from file system. + // Get the image from the file system. FileStreamSupport imageStream = new FileStreamSupport(ProductFileName, FileMode.Open, FileAccess.Read); ByteArrayInputStream stream = new ByteArrayInputStream(imageStream.toArray()); args.setImageStream(stream); @@ -413,8 +413,10 @@ private void mergeField_EmployeeImage(Object sender, MergeImageFieldEventArgs ar {% endtabs %} -The following code example provides supporting class for the above code. -{% tabs %} +The following code example provides the supporting class for the above code. + + +{% tabs %} {% highlight JAVA %} public class Employee @@ -427,78 +429,79 @@ public class Employee private String _country; private String _title; private String _photo; - public String getFirstName()throws Exception + public String getFirstName() throws Exception { return _firstName; } - public String setFirstName(String value)throws Exception + public String setFirstName(String value) throws Exception { - _firstName=value; + _firstName = value; return value; } - public String getLastName()throws Exception + public String getLastName() throws Exception { return _lastName; } - public String setLastName(String value)throws Exception + public String setLastName(String value) throws Exception { - _lastName=value; + _lastName = value; return value; } - public String getAddress()throws Exception + public String getAddress() throws Exception { return _address; } - public String setAddress(String value)throws Exception + public String setAddress(String value) throws Exception { - _address=value; + _address = value; return value; } - public String getCity()throws Exception + public String getCity() throws Exception { return _city; } - public String setCity(String value)throws Exception + public String setCity(String value) throws Exception { - _city=value; + _city = value; return value; } - public String getRegion()throws Exception + public String getRegion() throws Exception { return _region; } - public String setRegion(String value)throws Exception + public String setRegion(String value) throws Exception { - _region=value; + _region = value; return value; } - public String getCountry()throws Exception{ + public String getCountry() throws Exception + { return _country; } - public String setCountry(String value)throws Exception + public String setCountry(String value) throws Exception { - _country=value; + _country = value; return value; } - public String getTitle()throws Exception + public String getTitle() throws Exception { return _title; } - public String setTitle(String value)throws Exception + public String setTitle(String value) throws Exception { - _title=value; + _title = value; return value; } - public String getPhoto()throws Exception + public String getPhoto() throws Exception { return _photo; } - public String setPhoto(String image)throws Exception + public String setPhoto(String image) throws Exception { - _photo=image; - return image; + _photo = image; + return image; } - public Employee(String firstName,String lastName,String title,String address,String city,String region,String country,String photoFilePath)throws Exception + public Employee(String firstName, String lastName, String title, String address, String city, String region, String country, String photoFilePath) throws Exception { setFirstName(firstName); setLastName(lastName); @@ -507,13 +510,13 @@ public class Employee setCity(city); setRegion(region); setCountry(country); - setPhoto((photoFilePath)); + setPhoto(photoFilePath); } } {% endhighlight %} {% endtabs %} -The resultant document looks as follows. +The resultant document looks as follows: -![Simple Mail merge with Group output document](GettingStarted_images/GettingStarted_img5.png) +![Simple Mail merge with Group output document](GettingStarted_images/GettingStarted_img5.png) \ No newline at end of file diff --git a/java-file-formats/word-library/html.md b/java-file-formats/word-library/html.md index 8319333..1e38358 100644 --- a/java-file-formats/word-library/html.md +++ b/java-file-formats/word-library/html.md @@ -1,6 +1,6 @@ --- -title: Word Document to HTML conversion | Word library | Syncfusion -description: This section illustrates how to convert Word document to HTML using Syncfusion Word library (Essential DocIO) +title: Word Document to HTML Conversion | Word Library | Syncfusion +description: This section illustrates how to convert a Word document to HTML using the Syncfusion Word Library (Essential DocIO) platform: java-file-formats control: Word Library documentation: UG @@ -8,28 +8,28 @@ documentation: UG # Word to HTML and HTML to Word Conversions -The Essential® DocIO converts the HTML file into a Word document and vice versa. You can also convert the Word document (DOCX, DOTX, DOCM, and DOTM) into HTML format. +The Essential® DocIO converts an HTML file into a Word document and vice versa. You can also convert a Word document (DOCX, DOTX, DOCM, and DOTM) into HTML format. -In the Word library (DocIO) we use the [XmlReader](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlreader?view=netframework-4.8) for parsing the content from input HTML. So, the input HTML should meet the XML standard (have proper open and close tags), even if you specify the `XHTMLValidationType` parameter as `XHTMLValidationType.None`. +In the Word Library (DocIO), we use the [XmlReader](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlreader?view=netframework-4.8) for parsing the content from the input HTML. So, the input HTML should meet the XML standard (have proper open and close tags), even if you specify the `XHTMLValidationType` parameter as `XHTMLValidationType.None`. ## XHTML Validation -Every HTML content is validated against a Document Type Declaration (DTD) which is a set of mark-up declarations that define a document type for a SGML-family mark-up language (GML, SGML, XML, HTML). +Every HTML content is validated against a Document Type Declaration (DTD), which is a set of markup declarations that define a document type for an SGML-family markup language (GML, SGML, XML, HTML). -### XHTML validation types +### XHTML Validation Types -The following XHTML validation types are supported in Essential® DocIO while importing an HTML content. +The following XHTML validation types are supported in Essential® DocIO while importing HTML content. - + - + @@ -37,38 +37,38 @@ The following XHTML validation types are supported in Essential®-docio 2. syncfusion®-javahelper -Get the dependent jar files by installing [file formats controls](https://www.syncfusion.com/sales/products/fileformats?utm_source=ug&utm_medium=listing&utm_campaign=java-word-library#). You can find the required jars in the build installed drive. +Get the dependent jar files by installing [file formats controls](https://www.syncfusion.com/sales/products/fileformats?utm_source=ug&utm_medium=listing&utm_campaign=java-word-library#). You can find the required jars in the build-installed drive. -**Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\ {Platform}\ {version}\JarFiles -**Example:** C:\Program Files (x86)\Syncfusion\Essential Studio\FileFormats\18.3.0.35\JarFiles +**Location:** {ProgramFilesFolder}\Syncfusion\Essential Studio\{Platform}\{version}\JarFiles +**Example:** C:\Program Files (x86)\Syncfusion\Essential Studio\FileFormats\18.3.0.35\JarFiles +## Supported Java Versions -## Supported Java versions + -Syncfusion® Java Word library supports Java SE 8.0(1.8) or above versions. +The Syncfusion® Java Word Library supports Java SE 8.0 (1.8) or above versions. ## Download Jars -You can download the jars from the Syncfusion® [maven repository](https://jars.syncfusion.com/) to use our artifacts in your projects. It helps you to use the Syncfusion® Java packages without installing Essential Studio® or platform installation to development with Syncfusion® controls. +You can download the jars from the Syncfusion® [Maven repository](https://jars.syncfusion.com/) to use our artifacts in your projects. This allows you to use the Syncfusion® Java packages without installing Essential Studio® or platform installation for development with Syncfusion® controls. -**Frequently Asked questions** +**Frequently Asked Questions** * [How to configure Syncfusion® Java packages in Gradle?](https://help.syncfusion.com/document-processing/word/word-library/java/installation/configure-to-download-syncfusion-java-packages-from-gradle) -* [How to configure Syncfusion® Java packages in Apache Maven?](https://help.syncfusion.com/document-processing/word/word-library/java/installation/configure-to-download-syncfusion-java-packages-from-apache-maven) - +* [How to configure Syncfusion® Java packages in Apache Maven?](https://help.syncfusion.com/document-processing/word/word-library/java/installation/configure-to-download-syncfusion-java-packages-from-apache-maven) \ No newline at end of file diff --git a/java-file-formats/word-library/loading-and-saving-document.md b/java-file-formats/word-library/loading-and-saving-document.md index 76f0942..d3ee839 100644 --- a/java-file-formats/word-library/loading-and-saving-document.md +++ b/java-file-formats/word-library/loading-and-saving-document.md @@ -1,156 +1,156 @@ --- -title: Loading & Saving document | Syncfusion -description: This section illustrates how to load and save the Word document using Syncfusion Word library (Essential DocIO) +title: Loading & Saving Document | Syncfusion +description: This section illustrates how to load and save a Word document using the Syncfusion Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG --- -# Loading & saving document +# Loading & Saving Document -## Opening an existing document +## Opening an Existing Document -You can open an existing Word document by using either the `open` method or the constructor of `WordDocument` class. +You can open an existing Word document by using either the `open` method or the constructor of the `WordDocument` class. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Open an existing document from the file system using the constructor of WordDocument class. +// Open an existing document from the file system using the constructor of the WordDocument class. WordDocument document = new WordDocument(fileName); {% endhighlight %} {% endtabs %} -{% tabs %} - +{% tabs %} + {% highlight JAVA %} -//Create an empty Word document instance. +// Create an empty Word document instance. WordDocument document = new WordDocument(); -//Load or open an existing word document using the open method of WordDocument class. +// Load or open an existing Word document using the open method of the WordDocument class. document.open(fileName); {% endhighlight %} -{% endtabs %} +{% endtabs %} -## Opening an existing document from Stream +## Opening an Existing Document from Stream -You can open an existing document from the stream by using either the overload of `open` methods or the constructor of `WordDocument` class. +You can open an existing document from the stream by using either the overload of `open` methods or the constructor of the `WordDocument` class. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Open an existing document from the stream using the constructor of the WordDocument class. +// Open an existing document from the stream using the constructor of the WordDocument class. FileInputStream fileStreamPath = new FileInputStream("Input.docx"); WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic); {% endhighlight %} -{% endtabs %} +{% endtabs %} -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an empty WordDocument instance. +// Create an empty WordDocument instance. FileInputStream fileStreamPath = new FileInputStream("Input.docx"); -//Loads or opens an existing Word document using the open method of WordDocument class +// Load or open an existing Word document using the open method of the WordDocument class. WordDocument document = new WordDocument(); document.open(fileStreamPath, FormatType.Automatic); {% endhighlight %} -{% endtabs %} +{% endtabs %} + +## Opening a Read-Only Word Document -## Opening the read only Word document +You can open read-only documents or read-only streams using the `openReadOnly` method. If the Word document for reading is opened by any other application, such as Microsoft Word, then the same document can be opened using DocIO in Read-Only mode. The following code sample explains the same. -You can open the ready only documents or read-only streams using the openReadOnly method. If the Word document for reading is opened by any other application such as Microsoft Word, then the same document can be opened using the DocIO in ReadOnly mode. The following code sample explains the same. +{% tabs %} -{% tabs %} - {% highlight JAVA %} -//Create an empty WordDocument instance. +// Create an empty WordDocument instance. WordDocument document = new WordDocument(); -//Load or open an existing word document using the read only stream. +// Load or open an existing Word document using the read-only stream. document.openReadOnly("Template.docx", FormatType.Docx); -{% endhighlight %} +{% endhighlight %} {% endtabs %} -## Saving a Word document to file system +## Saving a Word Document to File System -You can save the created or manipulated Word document to the file system using the `save` method of `WordDocument` class. +You can save the created or manipulated Word document to the file system using the `save` method of the `WordDocument` class. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an empty WordDocument instance. +// Create an empty WordDocument instance. WordDocument document = new WordDocument(); -//open an existing Word document using the Open method of WordDocument class. +// Open an existing Word document using the open method of the WordDocument class. document.open(fileName); -//To-Do some manipulation -//To-Do some manipulation -//Save the document in the file system. +// To-Do some manipulation. +// To-Do some manipulation. +// Save the document in the file system. document.save(outputFileName, FormatType.Docx); {% endhighlight %} -{% endtabs %} +{% endtabs %} -## Saving a Word document to Stream +## Saving a Word Document to Stream -You can also save the created or manipulated word document to the stream by using the overloads of `save` methods. +You can also save the created or manipulated Word document to the stream by using the overloads of `save` methods. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Creates an empty WordDocument instance +// Create an empty WordDocument instance. WordDocument document = new WordDocument(); -//Opens an existing Word document through Open method of WordDocument class. -document.Open(fileName); -//To-Do some manipulation -//To-Do some manipulation -//Create an instance of the output stream. +// Open an existing Word document using the open method of the WordDocument class. +document.open(fileName); +// To-Do some manipulation. +// To-Do some manipulation. +// Create an instance of the output stream. ByteArrayOutputStream stream = new ByteArrayOutputStream(); -//Save the document to stream. +// Save the document to the stream. document.save(stream, FormatType.Docx); {% endhighlight %} -{% endtabs %} +{% endtabs %} -## Sending to a client browser +## Sending to a Client Browser -You can save and send the document to a client browser from a web site or web application by invoking the following shown overload of `save` method. This method explicitly makes use of an instance of [HttpResponse](https://msdn.microsoft.com/en-us/library/system.web.httpresponse(v=vs.110).aspx#) as its parameter to stream the document to the client browser. So, this overload is suitable for a web application that references System.Web assembly. +You can save and send the document to a client browser from a website or web application by invoking the overload of the `save` method shown below. This method explicitly makes use of an instance of [HttpResponse](https://msdn.microsoft.com/en-us/library/system.web.httpresponse(v=vs.110).aspx#) as its parameter to stream the document to the client browser. So, this overload is suitable for a web application that references the System.Web assembly. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an empty WordDocument instance. +// Create an empty WordDocument instance. WordDocument document = new WordDocument(); -//Open an existing Word document using the Open method of WordDocument class. -document.Open(fileName); -//To-Do some manipulation. -//To-Do some manipulation. -//Create an instance of the output stream. +// Open an existing Word document using the open method of the WordDocument class. +document.open(fileName); +// To-Do some manipulation. +// To-Do some manipulation. +// Create an instance of the output stream. ByteArrayOutputStream stream = new ByteArrayOutputStream(); -//Save the document to the stream. +// Save the document to the stream. document.save(outputFileName, FormatType.Docx, Response, HttpContentDisposition.Attachment); {% endhighlight %} -{% endtabs %} +{% endtabs %} -## Closing a document +## Closing a Document -Once the document manipulation and save operation are completed, you should close the instance of `WordDocument`, in order to release all the memory consumed by the DocIO’s DOM. The following code example shows how to close a WordDocument instance. +Once the document manipulation and save operation are completed, you should close the instance of `WordDocument` to release all the memory consumed by DocIO’s DOM. The following code example shows how to close a WordDocument instance. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an empty WordDocument instance. +// Create an empty WordDocument instance. WordDocument document = new WordDocument(); -//Opens an existing Word document using the Open method of WordDocument class -document.Open(fileName); -//To-Do some manipulation. -//To-Do some manipulation. -//Create an instance of the output stream. +// Open an existing Word document using the open method of the WordDocument class. +document.open(fileName); +// To-Do some manipulation. +// To-Do some manipulation. +// Create an instance of the output stream. ByteArrayOutputStream stream = new ByteArrayOutputStream(); -//Save the document to the stream. +// Save the document to the stream. document.save(stream, FormatType.Docx); -//Closes the document. +// Close the document. document.close(); {% endhighlight %} diff --git a/java-file-formats/word-library/mail-merge/mail-merge-for-group.md b/java-file-formats/word-library/mail-merge/mail-merge-for-group.md index ee9b2cd..d787454 100644 --- a/java-file-formats/word-library/mail-merge/mail-merge-for-group.md +++ b/java-file-formats/word-library/mail-merge/mail-merge-for-group.md @@ -1,91 +1,96 @@ --- -title: Mail merge for group | Syncfusion -description: This section illustrates how to Mail merge for a group - replace merge fields in a region of document with data, by repeating the region for each record. +title: Mail Merge for Group | Syncfusion +description: This section illustrates how to perform a Mail Merge for a group - replacing merge fields in a region of a document with data by repeating the region for each record. platform: java-file-formats control: Word Library documentation: UG --- -# Mail merge for a group +# Mail Merge for a Group -You can perform Mail merge and append multiple records from data source within a specified region to a template document. The region between start and end groups merge fields. It gets repeated for every record from the data source. +You can perform a Mail Merge and append multiple records from a data source within a specified region to a template document. The region between the start and end group merge fields gets repeated for every record from the data source. -## Create template for group mail merge +## Create Template for Group Mail Merge -The region where the Mail merge operations are to be performed must be marked by two merge fields with the following names. +The region where the Mail Merge operations are to be performed must be marked by two merge fields with the following names: - * «TableStart:TableName» and «BeginGroup:GroupName» - For the entry point of the region. + * «TableStart:TableName» and «BeginGroup:GroupName» - For the entry point of the region. - * «TableEnd:TableName» and «EndGroup:GroupName» - For the end point of the region. + * «TableEnd:TableName» and «EndGroup:GroupName» - For the endpoint of the region. - 1.*TableStart* and *TableEnd* region is preferred for performing Mail merge inside the table cell. - 2.*BeginGroup* and *EndGroup* region is preferred for performing Mail merge inside the document body contents. + + -For example, consider that you have a template document as shown. + -![Mail merge for a group](../MailMerge_images/Group_mail_merge_template.png) + 1. *TableStart* and *TableEnd* regions are preferred for performing Mail Merge inside the table cell. + 2. *BeginGroup* and *EndGroup* regions are preferred for performing Mail Merge inside the document body contents. -In this template, Employees is the group name and the same name should be used while performing Mail merge through code. There are two special merge fields “TableStart:Employees” and “TableEnd:Employees” to denote the start and end of the Mail merge group. +For example, consider that you have a template document as shown below: -## Mail merge with Java objects +![Mail Merge for a Group](../MailMerge_images/Group_mail_merge_template.png) -You can perform Mail merge with Java objects in a template document. The following code snippet shows how to perform Mail merge with business objects. +In this template, "Employees" is the group name, and the same name should be used while performing Mail Merge through code. There are two special merge fields, "TableStart:Employees" and "TableEnd:Employees," to denote the start and end of the Mail Merge group. + +## Mail Merge with Java Objects + +You can perform a Mail Merge with Java objects in a template document. The following code snippet shows how to perform a Mail Merge with business objects. {% tabs %} {% highlight JAVA %} -//Loads an existing Word document into DocIO instance. +// Loads an existing Word document into the DocIO instance. WordDocument document = new WordDocument("EmployeesReportDemo.docx"); -//Gets the employee details as IEnumerable collection. +// Gets the employee details as an IEnumerable collection. ListSupport employeeList = getEmployees(); -//Uses the mail merge events handler for image fields. +// Uses the Mail Merge events handler for image fields. document.getMailMerge().MergeImageField.add("mergeField_EmployeeImage", new MergeImageFieldEventHandler() { ListSupport delegateList = new ListSupport( MergeImageFieldEventHandler.class); -//Represents event handling for MergeFieldEventHandlerCollection. +// Represents event handling for MergeFieldEventHandlerCollection. public void invoke(Object sender, MergeImageFieldEventArgs args) throws Exception { mergeField_EmployeeImage(sender, args); } -//Represents the method that handles MergeField event. +// Represents the method that handles the MergeField event. public void dynamicInvoke(Object... args) throws Exception { mergeField_EmployeeImage((Object) args[0], (MergeImageFieldEventArgs) args[1]); } -//Represents the method that handles MergeField event to add collection item. +// Represents the method that handles the MergeField event to add a collection item. public void add(MergeImageFieldEventHandler delegate) throws Exception { if (delegate != null) delegateList.add(delegate); } -//Represents the method that handles MergeField event to remove collection item. +// Represents the method that handles the MergeField event to remove a collection item. public void remove(MergeImageFieldEventHandler delegate) throws Exception { if (delegate != null) delegateList.remove(delegate); } }); -//Creates an instance of MailMergeDataTable by specifying MailMerge group name and IEnumerable collection. -MailMergeDataTable dataSource = new MailMergeDataTable("Employees",employeeList); -//Executes the mail merge for group. +// Creates an instance of MailMergeDataTable by specifying the Mail Merge group name and IEnumerable collection. +MailMergeDataTable dataSource = new MailMergeDataTable("Employees", employeeList); +// Executes the Mail Merge for the group. document.getMailMerge().executeGroup(dataSource); -//Saves and closes the WordDocument instance. +// Saves and closes the WordDocument instance. document.save("Sample.docx"); document.close(); {% endhighlight %} {% endtabs %} -The following code example shows getEmployees method which is used to get data for mail merge. +The following code example shows the `getEmployees` method, which is used to get data for Mail Merge. {% tabs %} {% highlight JAVA %} -public ListSupport getEmployees()throws Exception +public ListSupport getEmployees() throws Exception { ListSupport employees = new ListSupport(Employee.class); - employees.add(new Employee("Nancy","Smith","Sales Representative","505 - 20th Ave. E. Apt. 2A,","Seattle","WA","USA","Nancy.png")); - employees.add(new Employee("Andrew","Fuller","Vice President, Sales","908 W. Capital Way","Tacoma","WA","USA","Andrew.png")); + employees.add(new Employee("Nancy", "Smith", "Sales Representative", "505 - 20th Ave. E. Apt. 2A,", "Seattle", "WA", "USA", "Nancy.png")); + employees.add(new Employee("Andrew", "Fuller", "Vice President, Sales", "908 W. Capital Way", "Tacoma", "WA", "USA", "Andrew.png")); return employees; } @@ -93,18 +98,18 @@ public ListSupport getEmployees()throws Exception {% endtabs %} -The following code example shows how to bind the image from file system during Mail merge process by using MergeImageFieldEventHandler. +The following code example shows how to bind the image from the file system during the Mail Merge process by using `MergeImageFieldEventHandler`. {% tabs %} {% highlight JAVA %} private void mergeField_EmployeeImage(Object sender, MergeImageFieldEventArgs args) throws Exception { - //Binds image from file system during mail merge. + // Binds the image from the file system during Mail Merge. if ((args.getFieldName()).equals("Photo")) { String ProductFileName = args.getFieldValue().toString(); - //Gets the image from file system. + // Gets the image from the file system. FileStreamSupport imageStream = new FileStreamSupport(ProductFileName, FileMode.Open, FileAccess.Read); ByteArrayInputStream stream = new ByteArrayInputStream(imageStream.toArray()); args.setImageStream(stream); @@ -115,7 +120,7 @@ private void mergeField_EmployeeImage(Object sender, MergeImageFieldEventArgs ar {% endtabs %} -The following code example shows the Employee class. +The following code example shows the `Employee` class. {% tabs %} {% highlight JAVA %} @@ -129,78 +134,80 @@ public class Employee private String _country; private String _title; private String _photo; - public String getFirstName()throws Exception + + public String getFirstName() throws Exception { return _firstName; } - public String setFirstName(String value)throws Exception + public String setFirstName(String value) throws Exception { - _firstName=value; + _firstName = value; return value; } - public String getLastName()throws Exception + public String getLastName() throws Exception { return _lastName; } - public String setLastName(String value)throws Exception + public String setLastName(String value) throws Exception { - _lastName=value; + _lastName = value; return value; } - public String getAddress()throws Exception + public String getAddress() throws Exception { return _address; } - public String setAddress(String value)throws Exception + public String setAddress(String value) throws Exception { - _address=value; + _address = value; return value; } - public String getCity()throws Exception + public String getCity() throws Exception { return _city; } - public String setCity(String value)throws Exception + public String setCity(String value) throws Exception { - _city=value; + _city = value; return value; } - public String getRegion()throws Exception + public String getRegion() throws Exception { return _region; } - public String setRegion(String value)throws Exception + public String setRegion(String value) throws Exception { - _region=value; + _region = value; return value; } - public String getCountry()throws Exception{ + public String getCountry() throws Exception + { return _country; } - public String setCountry(String value)throws Exception + public String setCountry(String value) throws Exception { - _country=value; + _country = value; return value; } - public String getTitle()throws Exception + public String getTitle() throws Exception { return _title; } - public String setTitle(String value)throws Exception + public String setTitle(String value) throws Exception { - _title=value; + _title = value; return value; } - public String getPhoto()throws Exception + public String getPhoto() throws Exception { return _photo; } - public String setPhoto(String image)throws Exception + public String setPhoto(String image) throws Exception { - _photo=image; + _photo = image; return image; } - public Employee(String firstName,String lastName,String title,String address,String city,String region,String country,String photoFilePath)throws Exception + public Employee(String firstName, String lastName, String title, String address, String city, String region, String country, String photoFilePath) throws Exception { setFirstName(firstName); setLastName(lastName); @@ -209,12 +216,14 @@ public class Employee setCity(city); setRegion(region); setCountry(country); - setPhoto((photoFilePath)); + setPhoto(photoFilePath); } } {% endhighlight %} + + {% endtabs %} -The resultant document looks as follows. +The resultant document looks as follows: -![Group resultant document](../MailMerge_images/Group_mail_merge_output.png) +![Group Resultant Document](../MailMerge_images/Group_mail_merge_output.png) \ No newline at end of file diff --git a/java-file-formats/word-library/mail-merge/mail-merge-for-nested-groups.md b/java-file-formats/word-library/mail-merge/mail-merge-for-nested-groups.md index d3b7901..1e0107a 100644 --- a/java-file-formats/word-library/mail-merge/mail-merge-for-nested-groups.md +++ b/java-file-formats/word-library/mail-merge/mail-merge-for-nested-groups.md @@ -1,238 +1,268 @@ --- -title: Mail merge for nested groups | Syncfusion -description: This section illustrates how to Mail merge for nested groups - replace merge fields in nested regions of document with relational data. +title: Mail Merge for Nested Groups | Syncfusion +description: This section illustrates how to perform a Mail Merge for nested groups - replacing merge fields in nested regions of a document with relational data. platform: java-file-formats control: Word Library documentation: UG --- -# Nested Mail merge for group +# Nested Mail Merge for Groups -You can perform nested Mail merge with relational or hierarchical data source and independent data tables in a template document. +You can perform a nested Mail Merge with relational or hierarchical data sources and independent data tables in a template document. -## Mail merge with implicit relational data +## Mail Merge with Implicit Relational Data -You can perform **nested Mail merge with implicit relational data** objects without any explicit relational commands by using the `executeNestedGroup` overload method. +You can perform **nested Mail Merge with implicit relational data** objects without any explicit relational commands by using the `executeNestedGroup` overload method. -### Map the field of ancestor group +### Map the Field of the Ancestor Group -You can also merge any field in the nested group by **mapping the field or column of its ancestor group or table** in the data source. To achieve this, you need to add a corresponding group name or table name as a prefix to the merge field name along with “:” separator. +You can also merge any field in the nested group by **mapping the field or column of its ancestor group or table** in the data source. To achieve this, you need to add a corresponding group name or table name as a prefix to the merge field name along with a “:” separator. For example: - * The merge field name should be like “TableName:Id” (<>) - * The merge field name should be like “Image:TableName:Photo” (<>) + * The merge field name should be like “TableName:Id” (<>). + * The merge field name should be like “Image:TableName:Photo” (<>). -For example, consider that you have a template document as follow. + -![Word document template to map the fields of ancestor group](../MailMerge_images/Mail_merge_with_implicit_relation_template.png) +For example, consider that you have a template document as follows: -In the above template, Organizations is the owner group and it has two child groups Departments and Employees. The Supervisor merge field of Departments group is used in Employees group. +![Word document template to map the fields of the ancestor group](../MailMerge_images/Mail_merge_with_implicit_relation_template.png) -The following code example shows how to perform nested Mail merge with the implicit relational data objects. +In the above template, Organizations is the owner group, and it has two child groups: Departments and Employees. The Supervisor merge field of the Departments group is used in the Employees group. + +The following code example shows how to perform a nested Mail Merge with the implicit relational data objects. {% tabs %} {% highlight JAVA %} -//Opens the template document. +// Opens the template document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Gets the organization details as “IEnumerable” collection. +// Gets the organization details as an “IEnumerable” collection. ListSupport organizationList = getOrganizations(); -//Creates an instance of “MailMergeDataTable” by specifying mail merge group name and “IEnumerable” collection. +// Creates an instance of “MailMergeDataTable” by specifying the mail merge group name and the “IEnumerable” collection. MailMergeDataTable dataTable = new MailMergeDataTable("Organizations", organizationList); -//Performs Mail merge. +// Performs Mail Merge. document.getMailMerge().executeNestedGroup(dataTable); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} {% endtabs %} -The following code example shows getOrganizations method which is used to get data for mail merge. +The following code example shows the `getOrganizations` method, which is used to get data for the Mail Merge. {% tabs %} {% highlight JAVA %} public static ListSupport getOrganizations() throws Exception { - //Creates Employee details. - ListSupport employees = new ListSupport(); - employees.add(new EmployeeDetails("Thomas Hardy", "1001", "05/27/1996")); - employees.add(new EmployeeDetails("Maria Anders", "1002", "04/10/1998")); - //Creates Departments details. - ListSupport departments = new ListSupport(); - departments.add(new DepartmentDetails("Marketing", "Nancy Davolio", employees)); - employees = new ListSupport(); - employees.add(new EmployeeDetails("Elizabeth Lincoln", "1003", "05/15/1996")); - employees.add(new EmployeeDetails("Antonio Moreno", "1004", "04/22/1996")); - departments.add(new DepartmentDetails("Production", "Andrew Fuller", employees)); - //Creates organization details. - ListSupport organizations = new ListSupport(); - organizations.add(new Organization("UK Office", "120 Hanover Sq.", "London", "WX1 6LT", "UK", departments)); - return organizations; + // Creates Employee details. + ListSupport employees = new ListSupport(); + employees.add(new EmployeeDetails("Thomas Hardy", "1001", "05/27/1996")); + employees.add(new EmployeeDetails("Maria Anders", "1002", "04/10/1998")); + // Creates Departments details. + ListSupport departments = new ListSupport(); + departments.add(new DepartmentDetails("Marketing", "Nancy Davolio", employees)); + employees = new ListSupport(); + employees.add(new EmployeeDetails("Elizabeth Lincoln", "1003", "05/15/1996")); + employees.add(new EmployeeDetails("Antonio Moreno", "1004", "04/22/1996")); + departments.add(new DepartmentDetails("Production", "Andrew Fuller", employees)); + // Creates organization details. + ListSupport organizations = new ListSupport(); + organizations.add(new Organization("UK Office", "120 Hanover Sq.", "London", "WX1 6LT", "UK", departments)); + return organizations; } {% endhighlight %} + {% endtabs %} -The following code example shows Organization, DepartmentDetails, and EmployeeDetails classes. +The following code example shows the `Organization`, `DepartmentDetails`, and `EmployeeDetails` classes. {% tabs %} {% highlight JAVA %} public class Organization { - private String _branchName; - private String _address; - private String _city; - private String _zipCode; - private String _country; - private ListSupport _departments; - public String getBranchName()throws Exception - { - return _branchName; - } - public String setBranchName(String value)throws Exception - { - _branchName=value; - return value; - } - public String getAddress()throws Exception - { - return _address; - } - public String setAddress(String value)throws Exception - { - _address=value; - return value; - } - public String getCity()throws Exception - { - return _city; - } - public String setCity(String value)throws Exception - { - _city=value; - return value; - } - public String getZipCode()throws Exception - { - return _zipCode; - } - public String setZipCode(String value)throws Exception - { - _zipCode=value; - return value; - } - public String getCountry()throws Exception - { - return _country; - } - public String setCountry(String value)throws Exception - { - _country=value; - return value; - } - public ListSupport getDepartments()throws Exception - { - return _departments; - } - public ListSupport setDepartments(ListSupport value)throws Exception - { - _departments=value; - return value; - } - public Organization(String branchName,String address,String city,String zipcode,String country,ListSupport departments)throws Exception - { - setBranchName(branchName); - setAddress(address); - setCity(city); - setZipCode(zipcode); - setCountry(country); - setDepartments(departments); - } -} + private String _branchName; + private String _address; + private String _city; + private String _zipCode; + private String _country; + private ListSupport _departments; + + public String getBranchName() throws Exception + { + return _branchName; + } + + public String setBranchName(String value) throws Exception + { + _branchName = value; + return value; + } + + public String getAddress() throws Exception + { + return _address; + } + + public String setAddress(String value) throws Exception + { + _address = value; + return value; + } + + public String getCity() throws Exception + { + return _city; + } + public String setCity(String value) throws Exception + { + _city = value; + return value; + } + + public String getZipCode() throws Exception + { + return _zipCode; + } + + public String setZipCode(String value) throws Exception + { + _zipCode = value; + return value; + } + + public String getCountry() throws Exception + { + return _country; + } + + public String setCountry(String value) throws Exception + { + _country = value; + return value; + } + + public ListSupport getDepartments() throws Exception + { + return _departments; + } + + public ListSupport setDepartments(ListSupport value) throws Exception + { + _departments = value; + return value; + } + + public Organization(String branchName, String address, String city, String zipcode, String country, ListSupport departments) throws Exception + { + setBranchName(branchName); + setAddress(address); + setCity(city); + setZipCode(zipcode); + setCountry(country); + setDepartments(departments); + } +} public class DepartmentDetails { - private String _departmentName; - private String _supervisor; - private ListSupport _employees; - public String getDepartmentName()throws Exception - { - return _departmentName; - } - public String setDepartmentName(String value)throws Exception - { - _departmentName=value; - return value; - } - public String getSupervisor()throws Exception - { - return _supervisor; - } - public String setSupervisor(String value)throws Exception - { - _supervisor=value; - return value; - } - public ListSupport getEmployees()throws Exception - { - return _employees; - } - public ListSupport setEmployees(ListSupport value)throws Exception - { - _employees=value; - return value; - } - public DepartmentDetails(String departmentName,String supervisor,ListSupport employees)throws Exception - { - setDepartmentName(departmentName); - setSupervisor(supervisor); - setEmployees(employees); - } + private String _departmentName; + private String _supervisor; + private ListSupport _employees; + + public String getDepartmentName() throws Exception + { + return _departmentName; + } + + public String setDepartmentName(String value) throws Exception + { + _departmentName = value; + return value; + } + + public String getSupervisor() throws Exception + { + return _supervisor; + } + + public String setSupervisor(String value) throws Exception + { + _supervisor = value; + return value; + } + + public ListSupport getEmployees() throws Exception + { + return _employees; + } + + public ListSupport setEmployees(ListSupport value) throws Exception + { + _employees = value; + return value; + } + + public DepartmentDetails(String departmentName, String supervisor, ListSupport employees) throws Exception + { + setDepartmentName(departmentName); + setSupervisor(supervisor); + setEmployees(employees); + } } public class EmployeeDetails { - private String _employeeName; - private String _employeeID; - private String _joinedDate; - public String getEmployeeName()throws Exception - { - return _employeeName; - } - public String setEmployeeName(String value)throws Exception - { - _employeeName=value; - return value; - } - public String getEmployeeID()throws Exception - { - return _employeeID; - } - public String setEmployeeID(String value)throws Exception - { - _employeeID=value; - return value; - } - public String getJoinedDate()throws Exception - { - return _joinedDate; - } - public String setJoinedDate(String value)throws Exception - { - _joinedDate=value; - return value; - } - public EmployeeDetails(String employeeName,String employeeID,String joinedDate)throws Exception - { - setEmployeeName(employeeName); - setEmployeeID(employeeID); - setJoinedDate(joinedDate); - } + private String _employeeName; + private String _employeeID; + private String _joinedDate; + + public String getEmployeeName() throws Exception + { + return _employeeName; + } + + public String setEmployeeName(String value) throws Exception + { + _employeeName = value; + return value; + } + + public String getEmployeeID() throws Exception + { + return _employeeID; + } + + public String setEmployeeID(String value) throws Exception + { + _employeeID = value; + return value; + } + + public String getJoinedDate() throws Exception + { + return _joinedDate; + } + + public String setJoinedDate(String value) throws Exception + { + _joinedDate = value; + return value; + } + + public EmployeeDetails(String employeeName, String employeeID, String joinedDate) throws Exception + { + setEmployeeName(employeeName); + setEmployeeID(employeeID); + setJoinedDate(joinedDate); + } } {% endhighlight %} + {% endtabs %} -By executing the above code example, it generates the resultant Word document as follows. - -![Output Word document of mapping field of ancestor group](../MailMerge_images/Mail_merge_with_implicit_relation_output.png) \ No newline at end of file +By executing the above code example, it generates the resultant Word document as follows: + +![Output Word document of mapping fields of the ancestor group](../MailMerge_images/Mail_merge_with_implicit_relation_output.png) \ No newline at end of file diff --git a/java-file-formats/word-library/mail-merge/mail-merge-options.md b/java-file-formats/word-library/mail-merge/mail-merge-options.md index 473dc44..516668e 100644 --- a/java-file-formats/word-library/mail-merge/mail-merge-options.md +++ b/java-file-formats/word-library/mail-merge/mail-merge-options.md @@ -1,6 +1,6 @@ --- title: Mail merge options | Syncfusion -description: This section illustrates the mail merge options used to customize field mapping, remove unmerged fields, unmerged mail merge groups, empty paragraphs and more. +description: This section illustrates the mail merge options used to customize field mapping, remove unmerged fields, unmerged mail merge groups, empty paragraphs, and more. platform: java-file-formats control: Word Library documentation: UG @@ -8,13 +8,13 @@ documentation: UG # Perform Mail merge options -The `MailMerge` class allows you to customize the Mail merge process with the following options. +The `MailMerge` class allows you to customize the mail merge process with the following options. ## Field Mapping -The `MailMerge` class can automatically **maps the merge field names with data source column names** during Mail merge process. You can also customize the field mapping when the merge field names in the template document varies with the column names in the data source by using `MappedFields` collection. +The `MailMerge` class can automatically **map the merge field names with data source column names** during the mail merge process. You can also customize the field mapping when the merge field names in the template document vary from the column names in the data source by using the `MappedFields` collection. -The following code example shows how to add mapping when a merge field name in a document and column name in data source have different names. +The following code example shows how to add mapping when a merge field name in a document and a column name in the data source have different names. {% tabs %} @@ -57,9 +57,9 @@ String[] fieldNames = document.getMailMerge().getMergeFieldNames(); ## Remove empty paragraphs -You can remove the empty paragraphs when the paragraph has only a merge field item, without any data during Mail merge process. +You can remove the empty paragraphs when the paragraph has only a merge field item, without any data during the mail merge process. -The following code example shows how to remove the empty paragraphs during Mail merge process. +The following code example shows how to remove the empty paragraphs during the mail merge process. {% tabs %} @@ -81,23 +81,23 @@ document.close(); {% endtabs %} -N>If any white space or line break exists in the merge field's parent paragraph, then it will not be considered as empty paragraph and not removed during mail merge process. +N> If any white space or line break exists in the merge field's parent paragraph, then it will not be considered an empty paragraph and will not be removed during the mail merge process. ## Remove empty merge fields -Essential® DocIO removes or keeps the unmerged merge fields in the output document based on the `ClearFields` property on each mail merge execution. +Essential® DocIO removes or keeps the unmerged merge fields in the output document based on the `ClearFields` property on each mail merge execution. -When a merge field is considered as unmerged during mail merge process? +When is a merge field considered unmerged during the mail merge process? -1. The merge field doesn't have mapping field in data source. +1. The merge field doesn't have a mapping field in the data source. -2. The merge field has mapping field in data source, but the data is null or string.Empty. +2. The merge field has a mapping field in the data source, but the data is null or string.Empty. -Mail merge operation automatically removes the unmerged merge fields since the default value of `ClearFields` property is true. +Mail merge operation automatically removes the unmerged merge fields since the default value of the `ClearFields` property is true. -T> 1.Set `ClearFields` property to false before the mail merge execution statement if your requirement is to keep the unmerged merge fields in the output document. -T> 2.Modify the `ClearFields` property before each mail merge execution statement while performing multiple mail merge executions if your requirement is to remove the unmerged merge fields in one mail merge execution and keep the unmerged merge fields in another mail merge execution. -T> 3.Order the mail merge executions with the `ClearFields` property false as first to avoid removal merge fields that are required for next mail merge execution in the same document. +T> 1. Set the `ClearFields` property to false before the mail merge execution statement if your requirement is to keep the unmerged merge fields in the output document. +T> 2. Modify the `ClearFields` property before each mail merge execution statement while performing multiple mail merge executions if your requirement is to remove the unmerged merge fields in one mail merge execution and keep the unmerged merge fields in another mail merge execution. +T> 3. Order the mail merge executions with the `ClearFields` property set to false as the first to avoid removing merge fields that are required for the next mail merge execution in the same document. The following code example shows how to keep the unmerged merge fields in the generated Word document. @@ -106,7 +106,7 @@ The following code example shows how to keep the unmerged merge fields in the ge {% highlight JAVA %} //Opens the template document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Sets “ClearFields” to true to remove empty mail merge fields from document. +//Sets "ClearFields" to true to remove empty mail merge fields from the document. document.getMailMerge().setClearFields(false); //Specifies the field names and field values. String[] fieldNames = new String[] { "EmployeeId", "Phone", "City" }; @@ -118,24 +118,25 @@ document.save("Removeemptymergefields.docx", FormatType.Docx); //Closes the Word document. document.close(); {% endhighlight %} + {% endtabs %} ## Remove empty group -You can remove the empty merge field groups which contains unmerged merge fields after executing mail merge for a group in a Word document. +You can remove the empty merge field groups which contain unmerged merge fields after executing the mail merge for a group in a Word document. -The following code example shows how to remove empty merge field group during mail merge process in a Word document. +The following code example shows how to remove empty merge field groups during the mail merge process in a Word document. {% tabs %} {% highlight JAVA %} //Opens the template document. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Gets the employee details as “IEnumerable” collection. +//Gets the employee details as "IEnumerable" collection. ListSupport employeeList = getEmployees(); -//Creates an instance of “MailMergeDataTable” by specifying mail merge group name and “IEnumerable” collection. +//Creates an instance of "MailMergeDataTable" by specifying mail merge group name and "IEnumerable" collection. MailMergeDataTable dataTable = new MailMergeDataTable("Employees", employeeList); -//Enable the flag to remove empty group which contain empty merge fields. +//Enable the flag to remove empty groups which contain empty merge fields. document.getMailMerge().setRemoveEmptyGroup(true); //Performs Mail merge. document.getMailMerge().executeNestedGroup(dataTable); @@ -147,7 +148,7 @@ document.close(); {% endtabs %} -The following code example shows getEmployees method which is used to get data for mail merge. +The following code example shows the getEmployees method, which is used to get data for mail merge. {% tabs %} diff --git a/java-file-formats/word-library/mail-merge/simple-mail-merge.md b/java-file-formats/word-library/mail-merge/simple-mail-merge.md index b6acf85..31c5fc1 100644 --- a/java-file-formats/word-library/mail-merge/simple-mail-merge.md +++ b/java-file-formats/word-library/mail-merge/simple-mail-merge.md @@ -1,34 +1,34 @@ --- -title: Simple Mail merge | Syncfusion -description: This section illustrates how to Mail merge - replace all merge fields in a document with data, by repeating whole document for each record in data source. +title: Simple Mail Merge | Syncfusion +description: This section illustrates how to perform a Mail Merge - replace all merge fields in a document with data, by repeating the whole document for each record in the data source. platform: java-file-formats control: Word Library documentation: UG --- -# Perform simple Mail merge +# Perform Simple Mail Merge -You can create a Word document template using Microsoft Word application or by adding merge fields in the Word document programmatically. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-mail-merge#create-word-document-template). +You can create a Word document template using the Microsoft Word application or by adding merge fields to the Word document programmatically. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-mail-merge#create-word-document-template). -## Mail merge with string arrays +## Mail Merge with String Arrays -The `MailMerge` class provides various overloads for `execute` method to perform Mail merge from various data sources. The Mail merge operation replaces the matching merge fields with the respective data. +The `MailMerge` class provides various overloads for the `execute` method to perform a Mail Merge from various data sources. The Mail Merge operation replaces the matching merge fields with the respective data. -### Create Word document template +### Create Word Document Template The following code example shows how to create a Word template document with merge fields. {% tabs %} {% highlight JAVA %} -//Creates an instance of a WordDocument. +// Creates an instance of a WordDocument. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Sets page margins to the last section of the document. +// Sets page margins to the last section of the document. document.getLastSection().getPageSetup().getMargins().setAll(72); -//Appends text to the last paragraph. +// Appends text to the last paragraph. document.getLastParagraph().appendText("EmployeeId: "); -//Appends merge field to the last paragraph. +// Appends merge field to the last paragraph. document.getLastParagraph().appendField("EmployeeId", FieldType.FieldMergeField); document.getLastParagraph().appendText("\nName: "); document.getLastParagraph().appendField("Name", FieldType.FieldMergeField); @@ -36,9 +36,9 @@ document.getLastParagraph().appendText("\nPhone: "); document.getLastParagraph().appendField("Phone", FieldType.FieldMergeField); document.getLastParagraph().appendText("\nCity: "); document.getLastParagraph().appendField("City", FieldType.FieldMergeField); -//Saves the Word document. +// Saves the Word document. document.save("Template.docx", FormatType.Docx); -//Closes the Word document. +// Closes the Word document. document.close(); {% endhighlight %} {% endtabs %} @@ -47,27 +47,27 @@ The generated template document looks as follows. ![Word document template](../MailMerge_images/Simple_mail_merge_template.png) -### Execute mail merge +### Execute Mail Merge -The following code example shows how to perform a simple Mail merge in the generated template document with string array as data source. +The following code example shows how to perform a simple Mail Merge in the generated template document with a string array as the data source. {% tabs %} {% highlight JAVA %} -//Opens the template document. +// Opens the template document. FileInputStream fileStreamPath = new FileInputStream("Template.docx"); WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx); String[] fieldNames = new String[] { "EmployeeId", "Name", "Phone", "City" }; String[] fieldValues = new String[] { "1001", "Peter", "+122-2222222", "London" }; -//Performs the mail merge. +// Performs the mail merge. document.getMailMerge().execute(fieldNames, fieldValues); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the Word document. +// Closes the Word document. document.close(); {% endhighlight %} {% endtabs %} The resultant document looks as follows. -![Mail merged Word document](../MailMerge_images/Simple_mail_merge_output.png) +![Mail merged Word document](../MailMerge_images/Simple_mail_merge_output.png) \ No newline at end of file diff --git a/java-file-formats/word-library/overview.md b/java-file-formats/word-library/overview.md index 0546d22..3fe082e 100644 --- a/java-file-formats/word-library/overview.md +++ b/java-file-formats/word-library/overview.md @@ -1,26 +1,26 @@ --- -title: Overview of Word library (DocIO) | Syncfusion -description: Java Word library to create, read, edit, and convert the Microsoft Word documents in the Java application without Microsoft Word or interop dependencies. +title: Overview of Word Library (DocIO) | Syncfusion +description: Java Word library to create, read, edit, and convert Microsoft Word documents in Java applications without Microsoft Word or interop dependencies. platform: java-file-formats control: Word Library documentation: UG --- -# Overview of Word library (DocIO) +# Overview of Word Library (DocIO) -Essential® DocIO is a native Java Word library that is used by developers to create, read, write, and convert the Microsoft Word documents in the Java application without Microsoft Word or interop dependencies. +Essential® DocIO is a native Java Word library used by developers to create, read, write, and convert Microsoft Word documents in Java applications without Microsoft Word or interop dependencies. -It is a non-UI component that provides a full-fledged document instance model similar to the Microsoft Office COM libraries to iterate with the document elements explicitly and perform necessary manipulation. It is built from scratch in Java and does not require Microsoft Word to be installed in the machine. It supports Word 2007 and later versions documents. +It is a non-UI component that provides a full-fledged document instance model, similar to the Microsoft Office COM libraries, to interact with document elements explicitly and perform necessary manipulations. It is built from scratch in Java and does not require Microsoft Word to be installed on the machine. It supports Word 2007 and later version documents. **Key Features** -* Support to [create Word document](https://help.syncfusion.com/document-processing/word/word-library/java/getting-started) from scratch. -* Support to open, modify, and save the existing Word documents. -* Advanced [Mail merge](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-mail-merge) support with different data sources. -* Ability to create or edit Word 2007 and later version documents, and convert them to commonly used file formats such as [WordML](https://help.syncfusion.com/document-processing/word/word-library/java/word-file-formats#word-processing-xml-xml), [TXT](https://help.syncfusion.com/document-processing/word/word-library/java/text), [HTML](https://help.syncfusion.com/document-processing/word/word-library/java/html) and vice versa. -* Ability to create and manipulate [shapes](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-shapes), and [group shape](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-shapes#grouping-shapes) in the DOCX and WordML format documents. -* Ability to read and write the [built-in and custom document properties](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-word-document#working-with-word-document-properties). -* Support to insert and edit the [form fields](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-form-fields). -* Ability to insert the [bookmarks](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-bookmarks) and navigate corresponding bookmarks to insert, replace, and delete content. +* Support for [creating Word documents](https://help.syncfusion.com/document-processing/word/word-library/java/getting-started) from scratch. +* Support for opening, modifying, and saving existing Word documents. +* Advanced [Mail Merge](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-mail-merge) support with different data sources. +* Ability to create or edit Word 2007 and later version documents and convert them to commonly used file formats such as [WordML](https://help.syncfusion.com/document-processing/word/word-library/java/word-file-formats#word-processing-xml-xml), [TXT](https://help.syncfusion.com/document-processing/word/word-library/java/text), [HTML](https://help.syncfusion.com/document-processing/word/word-library/java/html) and vice versa. +* Ability to create and manipulate [shapes](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-shapes) and [group shapes](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-shapes#grouping-shapes) in DOCX and WordML format documents. +* Ability to read and write [built-in and custom document properties](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-word-document#working-with-word-document-properties). +* Support for inserting and editing [form fields](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-form-fields). +* Ability to insert [bookmarks](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-bookmarks) and navigate corresponding bookmarks to insert, replace, and delete content. **Compatible Microsoft Word Versions** @@ -30,10 +30,10 @@ It is a non-UI component that provides a full-fledged document instance model si * Microsoft Word 2016 * Microsoft Word 2019 -T> Sometimes a Java application may throw an error like this "Java.Lang.OutOfMemoryError." Usually, this error occurs due to insufficient RAM heap space to allocate an object in the Java heap. To avoid this kind of problem, we suggest [increasing the JVM heap size](https://docs.oracle.com/cd/E29587_01/PlatformServices.60x/ps_rel_discovery/src/crd_advanced_jvm_heap.html). +T> Sometimes a Java application may throw an error like this: "Java.Lang.OutOfMemoryError." Usually, this error occurs due to insufficient RAM heap space to allocate an object in the Java heap. To avoid this kind of problem, we suggest [increasing the JVM heap size](https://docs.oracle.com/cd/E29587_01/PlatformServices.60x/ps_rel_discovery/src/crd_advanced_jvm_heap.html). -N> Currently, Essential® DocIO supports .DOCX, .DOTX, .DOTM, .DOCM, .WordML, .RTF, .Txt, WordML, HTML. Please refer to the [supported and unsupported features](https://help.syncfusion.com/document-processing/word/word-library/java/supported-and-unsupported-features) in the essential® DocIO. +N> Currently, Essential® DocIO supports .DOCX, .DOTX, .DOTM, .DOCM, .WordML, .RTF, .TXT, WordML, and HTML. Please refer to the [supported and unsupported features](https://help.syncfusion.com/document-processing/word/word-library/java/supported-and-unsupported-features) in Essential® DocIO. **See Also** -* [Jars Required for Java Word library (DocIO)](https://help.syncfusion.com/document-processing/word/word-library/java/jars-required#download-jars) +* [Jars Required for Java Word Library (DocIO)](https://help.syncfusion.com/document-processing/word/word-library/java/jars-required#download-jars) \ No newline at end of file diff --git a/java-file-formats/word-library/rtf.md b/java-file-formats/word-library/rtf.md index 24bcf8d..be9b2f4 100644 --- a/java-file-formats/word-library/rtf.md +++ b/java-file-formats/word-library/rtf.md @@ -9,35 +9,35 @@ documentation: UG # Word to RTF and RTF to Word Conversions ## RTF -The [Rich Text Format (RTF)](http://en.wikipedia.org/wiki/Rich_Text_Format#) is one of the document formats supported by Microsoft Word and many other Word processing applications. RTF is human readable file format invented for interchanging formatted text between applications. It is an optional format for Word that retains most formatting and all content of the original document. +The [Rich Text Format (RTF)](http://en.wikipedia.org/wiki/Rich_Text_Format#) is one of the document formats supported by Microsoft Word and many other word processing applications. RTF is a human-readable file format invented for interchanging formatted text between applications. It is an optional format for Word that retains most formatting and all content of the original document. -Most of the Word processors (including Microsoft Word) uses the XML-based file formats, Microsoft has discontinued enhancements to the RTF and still supporting it. The last version was 1.9.1 released in 2008. +Most word processors (including Microsoft Word) use XML-based file formats. Microsoft has discontinued enhancements to RTF but still supports it. The last version was 1.9.1, released in 2008. -The Essential® DocIO converts the RTF document into Word document and vice versa. The following code shows how to convert RTF document into Word document. +The Essential® DocIO converts RTF documents into Word documents and vice versa. The following code shows how to convert an RTF document into a Word document. {% tabs %} {% highlight JAVA %} -//Load an existing document. +// Load an existing document. WordDocument document = new WordDocument("Input.rtf", FormatType.Rtf); -//Save the Word document as RTF file. +// Save the Word document as an RTF file. document.save("RtfToWord.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -The following code example shows how to convert Word document into RTF document. +The following code example shows how to convert a Word document into an RTF document. {% tabs %} {% highlight JAVA %} -//Load an existing document. +// Load an existing document. WordDocument document = new WordDocument("Input.docx", FormatType.Docx); -//Save the Word document as RTF file. +// Save the Word document as an RTF file. document.save("WordToRtf.rtf", FormatType.Rtf); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -## Supported and Unsupported features -The supported and unsupported features of DocIO based on file formats can be referred [here](https://help.syncfusion.com/document-processing/word/word-library/java/supported-and-unsupported-features#) \ No newline at end of file +## Supported and Unsupported Features +The supported and unsupported features of DocIO based on file formats can be referred to [here](https://help.syncfusion.com/document-processing/word/word-library/java/supported-and-unsupported-features#). \ No newline at end of file diff --git a/java-file-formats/word-library/supported-and-unsupported-features.md b/java-file-formats/word-library/supported-and-unsupported-features.md index b8484b1..e9c0e80 100644 --- a/java-file-formats/word-library/supported-and-unsupported-features.md +++ b/java-file-formats/word-library/supported-and-unsupported-features.md @@ -1,15 +1,15 @@ --- title: Supported and Unsupported Features | Syncfusion -description: This section describes the support and unsupported elements used in Syncfusion Java Word library (Essential DocIO) +description: This section describes the supported and unsupported elements used in the Syncfusion Java Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG --- # Supported and Unsupported Features -This section describes the support and unsupported elements in the DocIO. +This section describes the supported and unsupported elements in DocIO. -## Word document features +## Word Document Features
XHTML validation typesXHTML Validation Types Description
XHTMLValidationType.NoneIt does not perform any schema validation but the given HTML content should meet the XHTML 1.0 format.It does not perform any schema validation, but the given HTML content should meet the XHTML 1.0 format.
XHTMLValidationType.Transitional
@@ -51,7 +51,7 @@ Yes

diff --git a/java-file-formats/word-library/supported-latex.md b/java-file-formats/word-library/supported-latex.md index da3cf4c..243f667 100644 --- a/java-file-formats/word-library/supported-latex.md +++ b/java-file-formats/word-library/supported-latex.md @@ -1,17 +1,17 @@ --- title: Supported LaTeX | DocIO | Syncfusion -description: Learn the list of LaTeX supported by Java Word library while creating equation in Word document. +description: Learn about the list of LaTeX supported by the Java Word library while creating equations in Word documents. platform: java-file-formats control: Word Library documentation: UG --- -# Supported symbols using LaTeX in Word Library -The Java Word library allows to insert below supported symbols in equation using **LaTeX**. +# Supported Symbols Using LaTeX in Word Library +The Java Word library allows inserting the following supported symbols in equations using **LaTeX**. ## Arrows -The following image demonstrates the LaTeX supported in Java Word library to create arrow symbols. +The following image demonstrates the LaTeX supported in the Java Word library for creating arrow symbols. ![Create Arrow Symbols in LaTeX](WorkingwithMathematicalEquation_images/ArrowsInLaTex_1.png) ![Create Arrow Symbols in LaTeX](WorkingwithMathematicalEquation_images/ArrowsInLaTex_2.png) @@ -21,7 +21,7 @@ The following image demonstrates the LaTeX supported in Java Word library to cre ## Basic Math -The following image demonstrates the LaTeX supported in Java Word library to create basic math symbols. +The following image demonstrates the LaTeX supported in the Java Word library for creating basic math symbols. ![Create Basic Math Symbols in LaTeX](WorkingwithMathematicalEquation_images/BasicMath_1.png) ![Create Basic Math Symbols in LaTeX](WorkingwithMathematicalEquation_images/BasicMath_2.png) @@ -30,36 +30,36 @@ The following image demonstrates the LaTeX supported in Java Word library to cre ## Geometry -The following image demonstrates the LaTeX equivalent to geometry. +The following image demonstrates the LaTeX equivalent for geometry. ![Create Geometry Symbols in LaTeX](WorkingwithMathematicalEquation_images/Geometry.png) -## Greek Letter +## Greek Letters ### Lower Case -The following image demonstrates the LaTeX supported in Java Word library to create lower case Greek letters. +The following image demonstrates the LaTeX supported in the Java Word library for creating lowercase Greek letters. ![Create Lower Case Symbols in LaTeX](WorkingwithMathematicalEquation_images/GreekLetter_LowerCase_1.png) ![Create Lower Case Symbols in LaTeX](WorkingwithMathematicalEquation_images/GreekLetter_LowerCase_2.png) ### Upper Case -The following image demonstrates the LaTeX supported in Java Word library to create upper case Greek letters. +The following image demonstrates the LaTeX supported in the Java Word library for creating uppercase Greek letters. ![Create Upper Case Symbols in LaTeX](WorkingwithMathematicalEquation_images/GreekLetter_UpperCase_1.png) ![Create Upper Case Symbols in LaTeX](WorkingwithMathematicalEquation_images/GreekLetter_UpperCase_2.png) ## Letter-Like Symbols -The following image demonstrates the LaTeX supported in Java Word library to create letter-like symbols. +The following image demonstrates the LaTeX supported in the Java Word library for creating letter-like symbols. ![Create Letter-Like Symbols in LaTeX](WorkingwithMathematicalEquation_images/LetterLikeSymbols_1.png) ![Create Letter-Like Symbols in LaTeX](WorkingwithMathematicalEquation_images/LetterLikeSymbols_2.png) ## Negated Relations -The following image demonstrates the LaTeX supported in Java Word library to create negated relations. +The following image demonstrates the LaTeX supported in the Java Word library for creating negated relations. ![Create Negated Relations Symbols in LaTeX](WorkingwithMathematicalEquation_images/NegatedRelation_1.png) ![Create Negated Relations Symbols in LaTeX](WorkingwithMathematicalEquation_images/NegatedRelation_2.png) @@ -69,14 +69,14 @@ The following image demonstrates the LaTeX supported in Java Word library to cre ### Common Binary Operators -The following image demonstrates the LaTeX supported in Java Word library to create common binary operators. +The following image demonstrates the LaTeX supported in the Java Word library for creating common binary operators. ![Create Common Binary Operators Symbols in LaTeX](WorkingwithMathematicalEquation_images/CommonBinaryOperator_1.png) ![Create Common Binary Operators Symbols in LaTeX](WorkingwithMathematicalEquation_images/CommonBinaryOperator_2.png) ### Common Relational Operators -The following image demonstrates the LaTeX supported in Java Word library to common relational operators. +The following image demonstrates the LaTeX supported in the Java Word library for creating common relational operators. ![Create Common Relational Operators Symbols in LaTeX](WorkingwithMathematicalEquation_images/CommonRelationalOperator_1.png) ![Create Common Relational Operators Symbols in LaTeX](WorkingwithMathematicalEquation_images/CommonRelationalOperator_2.png) @@ -84,14 +84,14 @@ The following image demonstrates the LaTeX supported in Java Word library to com ### Basic N-ary Operators -The following image demonstrates the LaTeX supported in Java Word library to basic N-ary operators. +The following image demonstrates the LaTeX supported in the Java Word library for creating basic N-ary operators. ![Create Basic N-ary Operators Symbols in LaTeX](WorkingwithMathematicalEquation_images/BinaryN-aryOperator_1.png) ![Create Basic N-ary Operators Symbols in LaTeX](WorkingwithMathematicalEquation_images/BinaryN-aryOperator_2.png) ### Advanced Binary Operators -The following image demonstrates the LaTeX supported in Java Word library to advanced binary operators. +The following image demonstrates the LaTeX supported in the Java Word library for creating advanced binary operators. ![Create Advanced Binary Symbols in LaTeX](WorkingwithMathematicalEquation_images/AdvancedBinaryOperator_1.png) ![Create Advanced Binary Symbols in LaTeX](WorkingwithMathematicalEquation_images/AdvancedBinaryOperator_2.png) @@ -99,9 +99,8 @@ The following image demonstrates the LaTeX supported in Java Word library to adv ### Advanced Relational Operators -The following image demonstrates the LaTeX supported in Java Word library to advanced relational operators. +The following image demonstrates the LaTeX supported in the Java Word library for creating advanced relational operators. ![Create Advanced Relational Symbols in LaTeX](WorkingwithMathematicalEquation_images/AdvancedRelationalOperator_1.png) ![Create Advanced Relational Symbols in LaTeX](WorkingwithMathematicalEquation_images/AdvancedRelationalOperator_2.png) -![Create Advanced Relational Symbols in LaTeX](WorkingwithMathematicalEquation_images/AdvancedRelationalOperator_3.png) - +![Create Advanced Relational Symbols in LaTeX](WorkingwithMathematicalEquation_images/AdvancedRelationalOperator_3.png) \ No newline at end of file diff --git a/java-file-formats/word-library/text.md b/java-file-formats/word-library/text.md index c8fdd03..6c82d48 100644 --- a/java-file-formats/word-library/text.md +++ b/java-file-formats/word-library/text.md @@ -1,6 +1,6 @@ --- -title: Word document to Text Conversion | Word library | Syncfusion -description: This section illustrates how to perform Word document to Text conversion using Syncfusion Word library (Essential DocIO) +title: Word Document to Text Conversion | Word Library | Syncfusion +description: This section illustrates how to perform Word document to text conversion using the Syncfusion Word Library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG @@ -8,15 +8,15 @@ documentation: UG # Word to Text and Text to Word Conversions -The Essential® DocIO converts the Word document into the Text file and vice versa. The following code example shows how to convert the Word document into text file. +The Essential® DocIO converts a Word document into a text file and vice versa. The following code example shows how to convert a Word document into a text file. {% tabs %} {% highlight JAVA %} -//Load a template document. +// Load a template document. WordDocument document = new WordDocument("Template.docx"); -//Save the document as a text file. +// Save the document as a text file. document.save("WordToText.txt", FormatType.Txt); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} @@ -25,34 +25,34 @@ The following code example shows how to convert a text file into a Word document {% tabs %} {% highlight JAVA %} -//Load a text file. +// Load a text file. WordDocument document = new WordDocument("Template.txt"); -//Save the document as a text file. +// Save the document as a Word file. document.save("TextToWord.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -The following code example shows how to retrieve the Word document contents as a plain text. +The following code example shows how to retrieve the Word document contents as plain text. {% tabs %} {% highlight JAVA %} -//Load a template document. +// Load a template document. WordDocument document = new WordDocument("Template.docx"); -//Get the document text. +// Get the document text. String text = document.getText(); -//Create a new Word document. +// Create a new Word document. WordDocument newdocument = new WordDocument(); -//Add a new section. +// Add a new section. IWSection section = newdocument.addSection(); -//Add a new paragraph. +// Add a new paragraph. IWParagraph paragraph = section.addParagraph(); -//Append the text to the paragraph. +// Append the text to the paragraph. paragraph.appendText(text); -//Save and close the document. +// Save and close the document. newdocument.save("Sample.docx"); newdocument.close(); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} \ No newline at end of file diff --git a/java-file-formats/word-library/word-document/compare-word-documents.md b/java-file-formats/word-library/word-document/compare-word-documents.md index ed010dd..cb75594 100644 --- a/java-file-formats/word-library/word-document/compare-word-documents.md +++ b/java-file-formats/word-library/word-document/compare-word-documents.md @@ -1,42 +1,42 @@ --- title: Compare Word Documents | DocIO | Syncfusion -description: Learn how to compare two Word documents using Java Word (DocIO) library without Microsoft Word or interop dependencies. +description: Learn how to compare two Word documents using the Java Word (DocIO) library without Microsoft Word or interop dependencies. platform: java-file-formats control: Word library documentation: UG --- -# Compare Word documents +# Compare Word Documents -Comparing two Word documents allows you to identify the changes between two versions of a document. The Java Word library (DocIO) enables you to compare two Word documents and highlight the following changes as tracked changes. +Comparing two Word documents allows you to identify the changes between two versions of a document. The Java Word library (DocIO) enables you to compare two Word documents and highlight the following changes as tracked changes: * Insertions * Deletions * Formatting -N> 1. DocIO performs word level comparison while comparing two Word documents. In this scenario, if a single character in a word is changed, the entire word will be highlighted as changed. -N> 2. Comparing two Word documents supported in DOCX format only. +N> 1. DocIO performs word-level comparison while comparing two Word documents. In this scenario, if a single character in a word is changed, the entire word will be highlighted as changed. +N> 2. Comparing two Word documents is supported in DOCX format only. -## Compare two Word documents +## Compare Two Word Documents -Compare the existing Word documents or documents created from scratch using the ``Compare`` method in the Java Word library (DocIO). +Compare existing Word documents or documents created from scratch using the `Compare` method in the Java Word library (DocIO). -The following code example illustrates how to compare two Word documents. +The following code example illustrates how to compare two Word documents: {% tabs %} {% highlight JAVA %} -//Load the original document. +// Load the original document. WordDocument originalDocument = new WordDocument("OriginalDocument.docx", FormatType.Docx); -//Load the revised document. +// Load the revised document. WordDocument revisedDocument = new WordDocument("RevisedDocument.docx", FormatType.Docx); -//Compare the original document with the revised document. +// Compare the original document with the revised document. originalDocument.compare(revisedDocument); -//Save the word document. +// Save the Word document. originalDocument.save("Sample.docx"); -//Close the word documents. +// Close the Word documents. originalDocument.close(); revisedDocument.close(); {% endhighlight %} @@ -44,27 +44,27 @@ revisedDocument.close(); ![Compare Word documents in Java](../WorkingwithWordDocument_images/Compare-Word-documents-without-author.png) -## Set Author and Date +## Set Author and Date -Compare the two Word documents by setting the author and date for revisions to identify the changes. In DocIO, the default setting for the “author” field is “Author”, and the default setting for the “dateTime” field is the current time. +Compare the two Word documents by setting the author and date for revisions to identify the changes. In DocIO, the default setting for the “author” field is “Author,” and the default setting for the “dateTime” field is the current time. -The following code example shows how to set the author and date for revision while comparing two Word documents. +The following code example shows how to set the author and date for revision while comparing two Word documents: {% tabs %} {% highlight JAVA %} -//Load the original document. +// Load the original document. WordDocument originalDocument = new WordDocument("OriginalDocument.docx", FormatType.Docx); -//Load the revised document. +// Load the revised document. WordDocument revisedDocument = new WordDocument("RevisedDocument.docx", FormatType.Docx); -//Compare the original document with the revised document. +// Compare the original document with the revised document. originalDocument.compare(revisedDocument, "Nancy Davolio", LocalDateTime.now().minusDays(1)); -//Save the word document. +// Save the Word document. originalDocument.save("Sample.docx"); -//Close the word documents. +// Close the Word documents. originalDocument.close(); revisedDocument.close(); {% endhighlight %} @@ -72,38 +72,38 @@ revisedDocument.close(); ![Compare Word documents in Java](../WorkingwithWordDocument_images/Compare-Word-documents.png) -## Comparison options +## Comparison Options -You can customize the Word comparison using our ``ComparisonOptions`` in the DocIO. +You can customize the Word comparison using our `ComparisonOptions` in DocIO. -### Ignore format changes +### Ignore Format Changes -In the Java Word library (DocIO), document comparison includes formatting changes by default. However, you can configure DocIO to ignore formatting differences using the ``setDetectFormatChanges`` API to concentrate solely on content modifications. +In the Java Word library (DocIO), document comparison includes formatting changes by default. However, you can configure DocIO to ignore formatting differences using the `setDetectFormatChanges` API to concentrate solely on content modifications. -The following code example illustrates how to compare two Word documents by ignoring the format changes. +The following code example illustrates how to compare two Word documents by ignoring the format changes: {% tabs %} {% highlight JAVA %} -//Load the original document. +// Load the original document. WordDocument originalDocument = new WordDocument("OriginalDocument.docx", FormatType.Docx); -//Load the revised document. +// Load the revised document. WordDocument revisedDocument = new WordDocument("RevisedDocument.docx", FormatType.Docx); -//Set the Comparison option detect format changes, whether to detect format changes while comparing two Word documents. +// Set the comparison option to detect format changes, whether to detect format changes while comparing two Word documents. ComparisonOptions compareOptions = new ComparisonOptions(); compareOptions.setDetectFormatChanges(false); -//Compare the original document with the revised document. +// Compare the original document with the revised document. originalDocument.compare(revisedDocument, "Nancy Davolio", LocalDateTime.now(), compareOptions); -//Save the word document. +// Save the Word document. originalDocument.save("Sample.docx"); -//Close the word documents. +// Close the Word documents. originalDocument.close(); revisedDocument.close(); {% endhighlight %} {% endtabs %} -![Compare Word documents by ignoring format changes](../WorkingwithWordDocument_images/Ignore-format-changes.png) +![Compare Word documents by ignoring format changes](../WorkingwithWordDocument_images/Ignore-format-changes.png) \ No newline at end of file diff --git a/java-file-formats/word-library/word-file-formats.md b/java-file-formats/word-library/word-file-formats.md index eba7760..5eddd29 100644 --- a/java-file-formats/word-library/word-file-formats.md +++ b/java-file-formats/word-library/word-file-formats.md @@ -16,7 +16,7 @@ The [Microsoft Word's](https://en.wikipedia.org/wiki/Microsoft_Word#) native fil ## Word Open XML formats (2007 & later) -[Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML#) (OOXML or Microsoft Open XML (MOX)) is a zipped, new XML-based file format introduced by Microsoft in Office 2007 applications.The WordprocessingML is the markup language used by the Microsoft Office Word to store its DOCX documents. +[Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML#) (OOXML or Microsoft Open XML (MOX)) is a zipped, new XML-based file format introduced by Microsoft in Office 2007 applications. The WordprocessingML is the markup language used by Microsoft Office Word to store its DOCX documents. DocIO supports the following WordprocessingML: @@ -30,13 +30,13 @@ The following code example explains how to create a new Word document with a few {% tabs %} {% highlight JAVA %} -//Create an instance of the WordDocument Instance (Empty Word Document). +// Create an instance of the WordDocument class (Empty Word Document). WordDocument document = new WordDocument(); -//Add a section and a paragraph in the empty document. +// Add a section and a paragraph in the empty document. document.ensureMinimal(); -//Append text to the last paragraph of the document. +// Append text to the last paragraph of the document. document.getLastParagraph().appendText("Hello World"); -//Save and close the Word document. +// Save and close the Word document. document.save("Sample.docx"); document.close(); {% endhighlight %} @@ -45,17 +45,17 @@ document.close(); ### Templates -DOTX is a Word document template. The following code sample shows how to create the Word document template with a few lines of code. +DOTX is a Word document template. The following code sample shows how to create a Word document template with a few lines of code. {% tabs %} {% highlight JAVA %} -//Create an instance of the WordDocument Instance (Empty Word Document). +// Create an instance of the WordDocument class (Empty Word Document). WordDocument document = new WordDocument(); -//Add a section and a paragraph in the empty document. +// Add a section and a paragraph in the empty document. document.ensureMinimal(); -//Append text to the last paragraph of the document. +// Append text to the last paragraph of the document. document.getLastParagraph().appendText("Hello World"); -//Save and close the Word document. +// Save and close the Word document. document.save("Sample.dotx"); document.close(); @@ -64,7 +64,7 @@ document.close(); ### Macros -DOCM is a macro-enabled Word document. It is same as the DOCX document contains macros and scripts. The DocIO provides only preservation support for macros. The following code shows how to load and save a macro-enabled document using the DocIO library. +DOCM is a macro-enabled Word document. It is similar to the DOCX document but contains macros and scripts. The DocIO provides only preservation support for macros. The following code shows how to load and save a macro-enabled document using the DocIO library. {% tabs %} {% highlight JAVA %} @@ -72,9 +72,9 @@ DOCM is a macro-enabled Word document. It is same as the DOCX document contains WordDocument document = new WordDocument("Template.dotm"); // Get the table. DataTableSupport table = getDataTable(); -// Execute the Mail Mmrge with groups. +// Execute the Mail Merge with groups. document.getMailMerge().executeGroup(table); -//Save and close the document. +// Save and close the document. document.save("Sample.docm", FormatType.Word2013Docm); document.close(); {% endhighlight %} @@ -83,47 +83,47 @@ document.close(); ## Word Processing XML (.xml) The XML format introduced in Microsoft Word 2003 was a simple, XML-based format called WordprocessingML or WordML. -The Essential® DocIO supports converting the Word document into Word Processing XML document and vice versa. +The Essential® DocIO supports converting Word documents into Word Processing XML documents and vice versa. -N> 1. Importing and exporting the Word Processing 2007 XML documents is supported. -N> 2. Exporting the Word Processing 2003 XML document is not supported. Whereas you can import the Word Processing 2003 XML documents and export it to the other supported file formats. -N> 3. The custom XML elements present in the Word Processing 2003 XML documents will be removed automatically while importing, like latest Microsoft Word. The custom XML element is a depreciated feature in latest Microsoft Word. +N> 1. Importing and exporting Word Processing 2007 XML documents is supported. +N> 2. Exporting Word Processing 2003 XML documents is not supported. However, you can import Word Processing 2003 XML documents and export them to other supported file formats. +N> 3. The custom XML elements present in Word Processing 2003 XML documents will be removed automatically while importing, similar to the latest Microsoft Word. The custom XML element is a deprecated feature in the latest Microsoft Word. -The following code example shows how to convert the Word document into Word Processing XML document. +The following code example shows how to convert a Word document into a Word Processing XML document. {% tabs %} {% highlight JAVA %} -//Load an existing Word document. +// Load an existing Word document. WordDocument document = new WordDocument("Sample.docx"); -//Save the document as a Word Processing ML document. +// Save the document as a Word Processing ML document. document.save("WordToWordML.xml", FormatType.WordML); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -The following code example shows how to convert the Word Processing XML document into Word document. +The following code example shows how to convert a Word Processing XML document into a Word document. {% tabs %} {% highlight JAVA %} -// Load an existing Word document. +// Load an existing Word Processing XML document. WordDocument document = new WordDocument("Template.xml"); -//Save the Word Processing ML document as docx. +// Save the Word Processing ML document as DOCX. document.save("WordMLToWord.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} ### Unsupported elements in Word to Word Processing XML conversion: -The following table contains a list of unsupported elements in the Word to Word Processing XML conversion. +The following table contains a list of unsupported elements in Word to Word Processing XML conversion.
Yes

-Encryption and Decryption

+Encryption and decryption

Yes

Yes

N/A

@@ -74,7 +74,7 @@ Yes

Track changes

Yes

-Yes – limited [can only accept/reject]

+Yes – limited (can only accept/reject)

No

No

- + - + @@ -134,7 +134,7 @@ Not supported

+Embedded Fonts

@@ -161,15 +161,15 @@ Not supported

Form Fields -
ElementLimitations or Unsupported elementsLimitations or Unsupported Elements
-Embedded fonts

Not supported

-Unparsed in Word Processing 2003 XML document +Unparsed in Word Processing 2003 XML documents
-Ole Object +OLE Object Not supported
+ \ No newline at end of file diff --git a/java-file-formats/word-library/working-with-bookmarks.md b/java-file-formats/word-library/working-with-bookmarks.md index fd47a59..33b69a5 100644 --- a/java-file-formats/word-library/working-with-bookmarks.md +++ b/java-file-formats/word-library/working-with-bookmarks.md @@ -9,11 +9,11 @@ documentation: UG A bookmark identifies a location or a selection of text within a document that you can name and identify for future reference. -In Essential® DocIO, bookmark is represented by Bookmark instance that is a pair of BookmarkStart and BookmarkEnd. BookmarkStart represents start point of a bookmark and BookmarkEnd represents end point of a bookmark. Every Word document contains a collection of bookmarks that are accessible through the Bookmarks property of WordDocument class. +In Essential® DocIO, a bookmark is represented by a Bookmark instance that is a pair of BookmarkStart and BookmarkEnd. BookmarkStart represents the starting point of a bookmark, and BookmarkEnd represents the endpoint of a bookmark. Every Word document contains a collection of bookmarks that are accessible through the Bookmarks property of the WordDocument class. -## Adding a bookmark +## Adding a Bookmark -The following code example shows how to add a bookmark in Word document. +The following code example shows how to add a bookmark in a Word document. {% tabs %} @@ -22,40 +22,40 @@ The following code example shows how to add a bookmark in Word document. WordDocument document = new WordDocument(); //Add a new section into the Word Document. IWSection section = document.addSection(); -//Add a new paragraph into Word document and appends text into paragraph. +//Add a new paragraph into the Word document and append text into the paragraph. IWParagraph paragraph = section.addParagraph(); paragraph.appendText("Northwind Database"); paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); -//Add a paragraph into section. +//Add a paragraph into the section. paragraph = section.addParagraph(); -//Add a new bookmark start into paragraph with name "Northwind". +//Add a new bookmark start into the paragraph with the name "Northwind". paragraph.appendBookmarkStart("Northwind"); -//Add a text between the bookmark start and end into paragraph. +//Add text between the bookmark start and end into the paragraph. paragraph.appendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases."); -//Add a new bookmark end into paragraph with name " Northwind ". +//Add a new bookmark end into the paragraph with the name "Northwind". paragraph.appendBookmarkEnd("Northwind"); -//Add a text after the bookmark end. +//Add text after the bookmark end. paragraph.appendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data."); -//Save the document in the given name and format. +//Save the document with the given name and format. document.save("Bookmarks.docx", FormatType.Docx); -//Release the resources occupied by WordDocument instance. +//Release the resources occupied by the WordDocument instance. document.close(); {% endhighlight %} {% endtabs %} -## Obtaining a bookmark instance +## Obtaining a Bookmark Instance -The following code example shows how to retrieve an instance of bookmark from a Word document. +The following code example shows how to retrieve an instance of a bookmark from a Word document. {% tabs %} {% highlight JAVA %} -//Load an existing Word document into DocIO instance. +//Load an existing Word document into the DocIO instance. WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx); -//Get the bookmark instance by using FindByName method of BookmarkCollection with bookmark name. +//Get the bookmark instance by using the FindByName method of BookmarkCollection with the bookmark name. Bookmark bookmark = document.getBookmarks().findByName("Northwind"); -//Access the bookmark start’s owner paragraph by using bookmark and changes its back color. +//Access the bookmark start’s owner paragraph by using the bookmark and change its background color. bookmark.getBookmarkStart().getOwnerParagraph().getParagraphFormat().setBackColor(ColorSupport.getAliceBlue()); //Save and close the Word document. document.save("Result.docx", FormatType.Docx); @@ -64,18 +64,18 @@ document.close(); {% endtabs %} -## Removing a Bookmark from Word document +## Removing a Bookmark from a Word Document -The following code example shows how to remove a bookmark from Word document. +The following code example shows how to remove a bookmark from a Word document. {% tabs %} {% highlight JAVA %} -//Load an existing Word document into DocIO instance. +//Load an existing Word document into the DocIO instance. WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx); -//Get the bookmark instance by using FindByName method of BookmarkCollection with bookmark name. +//Get the bookmark instance by using the FindByName method of BookmarkCollection with the bookmark name. Bookmark bookmark = document.getBookmarks().findByName("Northwind"); -//Remove the bookmark named "Northwind" from Word document. +//Remove the bookmark named "Northwind" from the Word document. document.getBookmarks().remove(bookmark); //Save and close the Word document. document.save("Result.docx", FormatType.Docx); @@ -84,16 +84,16 @@ document.close(); {% endtabs %} -## Retrieving contents within a bookmark +## Retrieving Contents Within a Bookmark -BookmarkNavigator is used for navigating to a bookmark in a Word document. You can retrieve, replace and delete the content of a specified bookmark by using BookmarkNavigator. +BookmarkNavigator is used for navigating to a bookmark in a Word document. You can retrieve, replace, and delete the content of a specified bookmark by using BookmarkNavigator. -You can get the content between bookmark start and bookmark end of the specified bookmark in two ways: +You can get the content between the bookmark start and bookmark end of the specified bookmark in two ways: -1. You can use `getBookmarkContent` method for retrieving content as collection of body items when the bookmark start and bookmark end are preserved in a single section. -2. You can use `getContent` method for retrieving content as collection of sections when the bookmark start and bookmark end are preserved in different sections. +1. You can use the `getBookmarkContent` method for retrieving content as a collection of body items when the bookmark start and bookmark end are preserved in a single section. +2. You can use the `getContent` method for retrieving content as a collection of sections when the bookmark start and bookmark end are preserved in different sections. -The following code example shows how to retrieve the specified bookmark content by using `getBookmarkContent` method in a Word document. +The following code example shows how to retrieve the specified bookmark content by using the `getBookmarkContent` method in a Word document. {% tabs %} @@ -117,12 +117,12 @@ document.close(); {% endtabs %} -The following code example shows how to retrieve the specified bookmark content by using `getContent` method in a Word document. +The following code example shows how to retrieve the specified bookmark content by using the `getContent` method in a Word document. {% tabs %} {% highlight JAVA %} -//Load the template document with bookmark "Northwind" whose start and end are preserved in different section. +//Load the template document with the bookmark "Northwind" whose start and end are preserved in different sections. WordDocument document = new WordDocument("Template.docx", FormatType.Docx); //Create the bookmark navigator instance to access the bookmark. BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document); @@ -130,27 +130,27 @@ BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document); bookmarkNavigator.moveToBookmark("Northwind"); //Get the bookmark content as WordDocumentPart. WordDocumentPart wordDocumentPart = bookmarkNavigator.getContent(); -//Save the WordDocumentPart as separate Word document. +//Save the WordDocumentPart as a separate Word document. WordDocument newDocument = wordDocumentPart.getAsWordDocument(); //Close the WordDocumentPart instance. wordDocumentPart.close(); //Close the template Word document. document.close(); newDocument.save("Result.docx", FormatType.Docx); -//Release the resources hold by WordDocument instance. +//Release the resources held by the WordDocument instance. newDocument.close(); {% endhighlight %} {% endtabs %} -## Retrieving bookmark contents within a table +## Retrieving Bookmark Contents Within a Table You can select the column range for bookmarks inside the tables in Word documents by using `FirstColumn` and `LastColumn` properties. -N> 1. `FirstColumn` and `LastColumn` properties are valid to select table cells, only when the respective bookmark end and start is present within the same row or next rows of the same table. -N> 2. `FirstColumn` property denotes the top left corner cell and `LastColumn` property denotes the bottom right corner cell of rectangular selection region since you can only select the content as a rectangular selection by using bookmarks within the table. -N> 3. `FirstColumn` property selects from the first cell of the respective row when this property value is negative (or) greater than the cells of a row (or) greater than the `LastColumn` value. -N> 4. `LastColumn` property selects till last cell of the respective row when this property value is negative (or) greater than the cells of a row (or) less than the `FirstColumn` value. +N> 1. `FirstColumn` and `LastColumn` properties are valid to select table cells only when the respective bookmark end and start are present within the same row or the next rows of the same table. +N> 2. The `FirstColumn` property denotes the top-left corner cell, and the `LastColumn` property denotes the bottom-right corner cell of the rectangular selection region since you can only select the content as a rectangular selection by using bookmarks within the table. +N> 3. The `FirstColumn` property selects from the first cell of the respective row when this property value is negative (or) greater than the cells of a row (or) greater than the `LastColumn` value. +N> 4. The `LastColumn` property selects till the last cell of the respective row when this property value is negative (or) greater than the cells of a row (or) less than the `FirstColumn` value. The following code example shows how to retrieve the bookmark content of a specified column range from a table in a Word document. @@ -161,7 +161,7 @@ The following code example shows how to retrieve the bookmark content of a speci WordDocument document = new WordDocument(); //Add a section and a paragraph in the document. document.ensureMinimal(); -//Insert a new table with bookmark. +//Insert a new table with a bookmark. IWTable table = CreateTable(document); //Create the bookmark navigator instance to access the bookmark. BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document); @@ -173,7 +173,7 @@ bookmarkNavigator.getCurrentBookmark().setFirstColumn((short) 1); bookmarkNavigator.getCurrentBookmark().setLastColumn((short)4); //Get the bookmark content. TextBodyPart part = bookmarkNavigator.getBookmarkContent(); -//Add new section. +//Add a new section. document.addSection(); //Add the retrieved content into another new section. for (int i = 0; i < part.getBodyItems().getCount(); i++) @@ -185,22 +185,22 @@ document.close(); {% endtabs %} -The following code example shows how to create table with bookmark. +The following code example shows how to create a table with a bookmark. {% tabs %} {% highlight JAVA %} public IWTable CreateTable(WordDocument document) throws Exception { - //Add a new table into Word document. + //Add a new table into the Word document. IWTable table = document.getLastSection().addTable(); //Specify the total number of rows & columns. table.resetCells(5, 5); - //Access the instance of the cells and adds the content into cells. + //Access the instance of the cells and add the content into cells. table.get(0, 0).addParagraph().appendText("Supplier ID"); table.get(0, 1).addParagraph().appendText("Company Name"); IWParagraph paragraph = table.getRows().get(0).getCells().get(2).addParagraph(); - //Append a bookmark start in third cell of first row. + //Append a bookmark start in the third cell of the first row. paragraph.appendBookmarkStart("BkmkInTable"); paragraph.appendText("Contact Name"); table.get(0, 3).addParagraph().appendText("Address"); @@ -223,7 +223,7 @@ public IWTable CreateTable(WordDocument document) throws Exception table.get(4, 0).addParagraph().appendText("4"); table.get(4, 1).addParagraph().appendText("Tokyo Traders"); paragraph = table.getRows().get(4).getCells().get(2).addParagraph(); - //Append a bookmark end in third cell of last row. + //Append a bookmark end in the third cell of the last row. paragraph.appendBookmarkEnd("BkmkInTable"); paragraph.appendText("Yoshi Nagase"); table.get(4, 3).addParagraph().appendText("9-8 Sekimai Musashino - shi"); diff --git a/java-file-formats/word-library/working-with-comments.md b/java-file-formats/word-library/working-with-comments.md index 5a64445..193661e 100644 --- a/java-file-formats/word-library/working-with-comments.md +++ b/java-file-formats/word-library/working-with-comments.md @@ -1,19 +1,19 @@ --- title: Working with Comments | Syncfusion -description: This section illustrates about working with comments in the Word document without MS Word or Office interop +description: This section illustrates working with comments in a Word document without MS Word or Office interop platform: java-file-formats control: Word Library documentation: UG --- # Working with Comments -A comment is a note or annotation that an author or reviewer can add to a document. DocIO represents comment with `WComment` instance. +A comment is a note or annotation that an author or reviewer can add to a document. DocIO represents comments with the `WComment` instance. -N> The comment start and end ranges and dates can be preserved only on processing an existing document that already contains these information for each comment. +N> The comment start and end ranges and dates can be preserved only when processing an existing document that already contains this information for each comment. ## Adding a Comment -You can add a new comment to the Word document by using `appendComment` method of `WParagraph` class. +You can add a new comment to the Word document by using the `appendComment` method of the `WParagraph` class. The following code shows how to add a new comment to the document: @@ -27,13 +27,13 @@ document.ensureMinimal(); IWParagraph paragraph = document.getLastParagraph(); //Appends text to the paragraph. paragraph.appendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."); -//Adds comment to a paragraph. +//Adds a comment to a paragraph. WComment comment = paragraph.appendComment("comment test"); //Specifies the author of the comment. comment.getFormat().setUser("Peter"); -//Specifies the initial of the author. +//Specifies the initials of the author. comment.getFormat().setUserInitials("St"); -//Set the date and time for comment. +//Sets the date and time for the comment. comment.getFormat().setDateTime(LocalDateTime.now()); //Saves the Word document. document.save("Comment.docx", FormatType.Docx); @@ -55,10 +55,10 @@ WordDocument document = new WordDocument("Comment.docx", FormatType.Docx); //Iterates the comments in the Word document. for (Object comments : document.getComments()) { - WComment comment = (WComment)comments; - //Modifies the last paragraph text of an existing comment when it is added by "Peter". - if ((comment.getFormat().getUser()).equals("Peter")) - comment.getTextBody().getLastParagraph().setText("Modified Comment Content"); + WComment comment = (WComment)comments; + //Modifies the last paragraph text of an existing comment when it is added by "Peter". + if ((comment.getFormat().getUser()).equals("Peter")) + comment.getTextBody().getLastParagraph().setText("Modified Comment Content"); } //Saves the Word document. document.save("ModifiedComment.docx", FormatType.Docx); @@ -67,12 +67,12 @@ document.close(); {% endhighlight %} {% endtabs %} - + ## Removing Comments You can either remove all the comments or a particular comment from the Word document. -The following code shows how to remove all the comments in Word document. +The following code shows how to remove all the comments in a Word document: {% tabs %} @@ -83,47 +83,47 @@ WordDocument document = new WordDocument("Comment.docx", FormatType.Docx); document.getComments().clear(); //Saves the Word document. document.save("Result.docx", FormatType.Docx); -//Closes the document +//Closes the document. document.close(); {% endhighlight %} {% endtabs %} -The following code shows how to remove a particular comment from Word document. +The following code shows how to remove a particular comment from a Word document: {% tabs %} {% highlight JAVA %} //Opens the template document. WordDocument document = new WordDocument("Comments.docx", FormatType.Docx); -//Removes second comments from a document. +//Removes the second comment from the document. document.getComments().removeAt(1); //Saves the Word document. document.save("Result.docx", FormatType.Docx); -//Closes the document +//Closes the document. document.close(); {% endhighlight %} {% endtabs %} -##Accessing parent comment +## Accessing Parent Comment -You can access the parent comment of a particular comment (reply) in a Word document using `getAncestor()` API. The ancestor for parent comment returns `null` as default. +You can access the parent comment of a particular comment (reply) in a Word document using the `getAncestor()` API. The ancestor for a parent comment returns `null` by default. -The following code examples show how to access the parent comment of a particular comment in a Word document. +The following code examples show how to access the parent comment of a particular comment in a Word document: {% tabs %} {% highlight JAVA %} -//Create an empty WordDocument instance. +//Creates an empty WordDocument instance. WordDocument document = new WordDocument(); -//open an existing Word document using the Open method of WordDocument class. +//Opens an existing Word document using the Open method of the WordDocument class. document.open("Comments.docx"); -//Get the Ancestor comment. +//Gets the ancestor comment. WComment ancestorComment = document.getComments().get(1).getAncestor(); -//Save and Close the Word document. +//Saves and closes the Word document. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} \ No newline at end of file diff --git a/java-file-formats/word-library/working-with-content-controls.md b/java-file-formats/word-library/working-with-content-controls.md index b1aa231..2a65efc 100644 --- a/java-file-formats/word-library/working-with-content-controls.md +++ b/java-file-formats/word-library/working-with-content-controls.md @@ -1,6 +1,6 @@ --- title: Working with Content Controls | Word library | Syncfusion -description: This section illustrates how to work with Content Controls in Word document using Syncfusion Java Word library (Essential DocIO) +description: This section illustrates how to work with Content Controls in Word documents using the Syncfusion Java Word library (Essential DocIO) platform: java-file-formats control: Word Library documentation: UG @@ -14,14 +14,14 @@ Content controls are individual controls that you can add and customize to use i N> You can use content controls only in documents that are saved in the Open XML Format. -Content controls can be categorized based on its occurrence in a document as follows, +Content controls can be categorized based on their occurrence in a document as follows: * InlineContentControl: Among inline content inside, as a child of a paragraph. * BlockContentControl: Among paragraphs and tables, as a child of a Body, HeaderFooter, Comment, Footnote, or a Shape node. ### Block Content Control -You can add content control to a text body of the Word document using block content control. You can add text, tables, pictures, or other items into the block content control. Refer to the following code. +You can add a content control to the text body of the Word document using block content control. You can add text, tables, pictures, or other items into the block content control. Refer to the following code. {% tabs %} {% highlight JAVA %} @@ -52,7 +52,7 @@ document.close(); ### Inline Content Control -You can add content control as a child to a paragraph using the inline content control. You can add text, pictures, fields or other paragraph items into the inline content control. Refer to the following code. +You can add a content control as a child to a paragraph using inline content control. You can add text, pictures, fields, or other paragraph items into the inline content control. Refer to the following code. {% tabs %} {% highlight JAVA %} @@ -79,7 +79,7 @@ document.close(); N> Currently, DocIO does not support RowContentControl and CellContentControl. -## Common properties of Content Control +## Common Properties of Content Control You can set formatting options for the content control in the Word document. The following are the common properties of a content control. @@ -95,27 +95,27 @@ The tag value to identify the content control. This property allows you to define the appearance of the content controls. The appearance can be any one of the following: -* BoundingBox: Displays the contents of content control within a box. -* Tags: Displays the contents of content control within tags. -* Hidden: Displays the contents of content control without any box or tags. +* BoundingBox: Displays the contents of the content control within a box. +* Tags: Displays the contents of the content control within tags. +* Hidden: Displays the contents of the content control without any box or tags. ### Color Defines the color of the content control. -### Temporary +### Temporary This property defines whether to remove a content control from the Word document when you edit the contents of the content control. ### Lock Contents -Locking the contents of the content control. It restricts to modify the contents of the content control. +Locking the contents of the content control restricts the modification of the contents of the content control. ### Lock Content Control -It restricts to remove or delete the content control. +It restricts the removal or deletion of the content control. -### Example – Content Control Common properties +### Example – Content Control Common Properties The following code sample illustrates the content control properties usage. @@ -147,7 +147,7 @@ contentControl.getContentControlProperties().setColor(ColorSupport.getMagenta()) ContentControlType controlType = contentControl.getContentControlProperties().getType(); //Enables content control lock. contentControl.getContentControlProperties().setLockContentControl(true); -//Protects the contents of content control. +//Protects the contents of the content control. contentControl.getContentControlProperties().setLockContents(true); //Saves and closes the Word document instance. document.save("Sample.docx", FormatType.Docx); @@ -158,7 +158,7 @@ document.close(); ## Why Content Control? -The content controls have the following three major use cases: +Content controls have the following three major use cases: * Protection * Form Filling @@ -166,18 +166,18 @@ The content controls have the following three major use cases: ### Protection -Content controls provides options to prevent users from editing or deleting parts of a Word document contents. This is useful if you have information in a Word document or template that you should be able to read but not edit, or if you want to be able to edit content controls but not delete them. +Content controls provide options to prevent users from editing or deleting parts of a Word document's contents. This is useful if you have information in a Word document or template that should be readable but not editable, or if you want to be able to edit content controls but not delete them. To protect contents inside a content control, you can use properties of the content control to prevent editing or deleting the content control: -* The **LockContents** property prevents from editing the contents of the content control. -* The **LockContentControl** property prevents from deleting the content control. +* The **LockContents** property prevents editing the contents of the content control. +* The **LockContentControl** property prevents deleting the content control. The following code sample shows how to protect the content control and its contents. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +//Creates a new Word document. WordDocument document = new WordDocument(); //Adds one section and one paragraph to the document. document.ensureMinimal(); @@ -199,7 +199,7 @@ contentControl.getContentControlProperties().setTag("Rich Text Protected"); contentControl.getContentControlProperties().setTitle("Text Protected"); //Enables content control lock. contentControl.getContentControlProperties().setLockContentControl(true); -//Protects the contents of content control. +//Protects the contents of the content control. contentControl.getContentControlProperties().setLockContents(true); //Saves and closes the Word document instance. document.save("Sample.docx", FormatType.Docx); diff --git a/java-file-formats/word-library/working-with-fields.md b/java-file-formats/word-library/working-with-fields.md index 113ee48..0d9e337 100644 --- a/java-file-formats/word-library/working-with-fields.md +++ b/java-file-formats/word-library/working-with-fields.md @@ -5,78 +5,78 @@ platform: java-file-formats control: Word Library documentation: UG --- -# Working with document Fields +# Working with Document Fields -Fields in a Word document are placeholders for data that might change on field update. Fields are represented by the `WField` and `WFieldMark` instances in DocIO. A field in a Word document contains field codes, field separator, field result, and field end. +Fields in a Word document are placeholders for data that might change on field update. Fields are represented by the `WField` and `WFieldMark` instances in DocIO. A field in a Word document contains field codes, a field separator, a field result, and a field end. -To learn various types of Microsoft Word supported fields and their syntax,refer to the [MSDN article](https://support.microsoft.com/en-us/office/list-of-field-codes-in-word-1ad6d91a-55a7-4a8d-b535-cf7888659a51?ui=en-us&rs=en-us&ad=us#) +To learn various types of Microsoft Word-supported fields and their syntax, refer to the [MSDN article](https://support.microsoft.com/en-us/office/list-of-field-codes-in-word-1ad6d91a-55a7-4a8d-b535-cf7888659a51?ui=en-us&rs=en-us&ad=us#). -The entire field code is included in Document Object Model(DOM). Hence, adding a field will automatically include the following elements in DOM: +The entire field code is included in the Document Object Model (DOM). Hence, adding a field will automatically include the following elements in DOM: -1. `WField`: Represents the starting of a Field. +1. `WField`: Represents the start of a field. -2. `ParagraphItem`: Represents the Field code. +2. `ParagraphItem`: Represents the field code. -3. `WFieldMark`: Represents the Field separator. +3. `WFieldMark`: Represents the field separator. -4. `ParagraphItem`: Represents the Field result. +4. `ParagraphItem`: Represents the field result. -5. `WFieldMark`: Represents the end of a Field. +5. `WFieldMark`: Represents the end of a field. -## Adding fields +## Adding Fields -You can add a field to a Word document by using the `appendField` method of `WParagraph` class. +You can add a field to a Word document by using the `appendField` method of the `WParagraph` class. The following code example explains how to add a field to the Word document. {% tabs %} {% highlight JAVA %} -//Creates an instance of WordDocument class (Empty Word Document). +// Creates an instance of WordDocument class (Empty Word Document). WordDocument document = new WordDocument(); -//Adds a new section to the Word Document. +// Adds a new section to the Word Document. IWSection section = document.addSection(); -//Adds a new paragraph to Word document and appends text into paragraph. +// Adds a new paragraph to the Word document and appends text into the paragraph. IWParagraph paragraph = section.addParagraph(); paragraph.appendText("Today's Date: "); -//Adds the new Date field to Word document with field name and its type. -WField field = (WField)paragraph.appendField("Date",FieldType.FieldDate); -//Field code used to describe how to display the date. -field.setFieldCode(StringSupport.concat("DATE \\@","\"MMMM d, yyyy\"" )); -//Saves the document in the given name and format. +// Adds the new Date field to the Word document with field name and its type. +WField field = (WField)paragraph.appendField("Date", FieldType.FieldDate); +// Field code used to describe how to display the date. +field.setFieldCode(StringSupport.concat("DATE \@","\"MMMM d, yyyy\"")); +// Saves the document with the given name and format. document.save("Sample.docx", FormatType.Docx); -//Releases the resources occupied by WordDocument instance. +// Releases the resources occupied by the WordDocument instance. document.close(); {% endhighlight %} {% endtabs %} -## Formatting fields +## Formatting Fields -You can format the field instances added to the Word document by iterating the items from field start to end. +You can format the field instances added to the Word document by iterating the items from field start to field end. -The following code example explains how to format the field in Word document. +The following code example explains how to format the field in a Word document. {% tabs %} {% highlight JAVA %} -//Creates an instance of a WordDocument. +// Creates an instance of a WordDocument. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Adds the new Page field to Word document with field name and its type. +// Adds the new Page field to the Word document with field name and its type. IWField field = document.getLastParagraph().appendField("Page", FieldType.FieldPage); IEntity entity = field; -//Iterates to sibling items until Field End. +// Iterates to sibling items until Field End. while (entity.getNextSibling() != null) { if (entity instanceof WTextRange) - //Sets character format for text ranges. + // Sets character format for text ranges. ((WTextRange) entity).getCharacterFormat().setFontSize((float) 6); else if ((entity instanceof WFieldMark) && ((WFieldMark) entity).getType().getEnumValue() == FieldMarkType.FieldEnd.getEnumValue()) break; - //Gets next sibling item. + // Gets the next sibling item. entity = entity.getNextSibling(); } // Saves and closes the Word document instance. @@ -86,9 +86,11 @@ document.close(); {% endtabs %} -## Updating fields + + +## Updating Fields -Field updating engine calculates the resultant value based on the field code information and updates the field result with a new value. You can update the following fields by using DocIO: +The field updating engine calculates the resultant value based on the field code information and updates the field result with a new value. You can update the following fields by using DocIO: * = (formula field) * DATE @@ -106,83 +108,85 @@ Field updating engine calculates the resultant value based on the field code inf * Cross-Reference * SEQ -The following code example explains how to update the fields present in Word document. +The following code example explains how to update the fields present in a Word document. {% tabs %} {% highlight JAVA %} -//Loads an existing Word document into DocIO instance. +// Loads an existing Word document into the DocIO instance. WordDocument document = new WordDocument("Input.docx", FormatType.Docx); -//Updates the fields present in a document. +// Updates the fields present in the document. document.updateDocumentFields(); -//Saves and closes the Word document instance. +// Saves and closes the Word document instance. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -## IF field +## IF Field -IF field compares two values and updates the field result with true text, when comparison succeeds otherwise false text. +The IF field compares two values and updates the field result with true text when the comparison succeeds; otherwise, it displays false text. -To learn more about IF field and its syntax in Microsoft Word, refer to the [MSDN article](https://support.office.com/en-au/article/Field-codes-IF-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e#) +To learn more about the IF field and its syntax in Microsoft Word, refer to the [MSDN article](https://support.office.com/en-au/article/Field-codes-IF-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e#). -The following code example explains how to add an If field to a Word document. +The following code example explains how to add an IF field to a Word document. {% tabs %} {% highlight JAVA %} -//Creates an instance of a WordDocument. +// Creates an instance of a WordDocument. WordDocument document = new WordDocument(); IWSection section = document.addSection(); IWParagraph paragraph = section.addParagraph(); -paragraph.appendText("If field which uses string of characters in expression"); -paragraph=section.addParagraph(); -//Creates the new instance of IF field. +paragraph.appendText("If field which uses a string of characters in expression"); +paragraph = section.addParagraph(); +// Creates the new instance of the IF field. WIfField field = (WIfField)paragraph.appendField("If", FieldType.FieldIf); -//Specifies the expression, true and false statement in field code. +// Specifies the expression, true, and false statements in the field code. field.setFieldCode("IF \"True\" = \"True\" \"The given statement is Correct\" \"The given statement is Wrong\""); paragraph = section.addParagraph(); paragraph.appendText("If field which uses numbers in expression"); paragraph = section.addParagraph(); -//Creates the new instance of IF field +// Creates the new instance of the IF field. field = (WIfField)paragraph.appendField("If", FieldType.FieldIf); -//Specifies the expression, true and false statement in field code. +// Specifies the expression, true, and false statements in the field code. field.setFieldCode("IF 100 >= 1000 \"The given statement is Correct\" \"The given statement is Wrong\""); -//Updates the document fields. +// Updates the document fields. document.updateDocumentFields(); // Saves and closes the Word document instance. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -## Document variables + + +## Document Variables -The DocVariable field displays the value of a specified document variable in the Word document. The document variables can be added or modified using the `Variables` property of `WordDocument` class. +The DocVariable field displays the value of a specified document variable in the Word document. The document variables can be added or modified using the `Variables` property of the `WordDocument` class. The following code example explains how to add a DocVariable field to a Word document. {% tabs %} {% highlight JAVA %} -//Creates an instance of a WordDocument. +// Creates an instance of a WordDocument. WordDocument document = new WordDocument(); IWSection section = document.addSection(); IWParagraph paragraph = section.addParagraph(); paragraph.appendText("First Name of the customer: "); -//Adds the DocVariable field with Variable name and its type. -paragraph.appendField("FirstName",FieldType.FieldDocVariable); +// Adds the DocVariable field with variable name and its type. +paragraph.appendField("FirstName", FieldType.FieldDocVariable); paragraph = section.addParagraph(); paragraph.appendText("Last Name of the customer: "); -//Adds the DocVariable field with Variable name and its type. +// Adds the DocVariable field with variable name and its type. paragraph.appendField("LastName", FieldType.FieldDocVariable); -//Adds the value for variable in WordDocument.Variable collection. +// Adds the value for the variable in the WordDocument.Variable collection. document.getVariables().add("FirstName", "Jeff"); document.getVariables().add("LastName", "Smith"); -//Updates the document fields. +// Updates the document fields. document.updateDocumentFields(); // Saves and closes the Word document instance. document.save("Sample.docx", FormatType.Docx); @@ -191,22 +195,22 @@ document.close(); {% endtabs %} -## Cross reference +## Cross-Reference -A cross-reference refers to an item that appears in another location in a document. You can create cross-reference to bookmarks in a document by using the `appendCrossReference` method of `WParagraph` class. +A cross-reference refers to an item that appears in another location in a document. You can create a cross-reference to bookmarks in a document by using the `appendCrossReference` method of the `WParagraph` class. N> The Essential® DocIO supports creating and updating the cross-reference fields only for bookmarks in a document. -The following code example explains how to append cross reference for bookmark in a Word document. +The following code example explains how to append a cross-reference for a bookmark in a Word document. {% tabs %} {% highlight JAVA %} -//Creates an instance of a WordDocument. +// Creates an instance of a WordDocument. WordDocument document = new WordDocument(); IWSection section = document.addSection(); IWParagraph paragraph = section.addParagraph(); -//Adds text, bookmark start and end in the paragraph. +// Adds text, bookmark start, and end in the paragraph. paragraph.appendBookmarkStart("Title"); paragraph.appendText("Northwind Database"); paragraph.appendBookmarkEnd("Title"); @@ -215,12 +219,12 @@ paragraph.appendText("The Northwind sample database (Northwind.mdb) is included section = document.addSection(); section.addParagraph(); paragraph = (WParagraph)section.addParagraph(); -//Gets the collection of bookmark start in the word document. +// Gets the collection of bookmark start in the Word document. ListSupport items = document.getCrossReferenceItems(ReferenceType.Bookmark); paragraph.appendText("Bookmark Cross Reference starts here "); -//Appends the cross reference for bookmark “Title” with ContentText as reference kind. +// Appends the cross-reference for the bookmark “Title” with ContentText as reference kind. paragraph.appendCrossReference(ReferenceType.Bookmark, ReferenceKind.ContentText, items.get(0), true, false, false, ""); -//Updates the document Fields. +// Updates the document fields. document.updateDocumentFields(); // Saves and closes the Word document instance. document.save("Sample.docx", FormatType.Docx); @@ -229,32 +233,32 @@ document.close(); {% endtabs %} -## Unlink fields +## Unlink Fields You can replace the field with its most recent result in the Word document by unlinking the field using the `unlink` API. When you unlink a field, its current result is converted to text or a graphic and can no longer be updated automatically. -The following code example shows how to unlink the fields in Word document. +The following code example shows how to unlink the fields in a Word document. {% tabs %} {% highlight JAVA %} -//Creates an instance of WordDocument class. +// Creates an instance of the WordDocument class. WordDocument document = new WordDocument(); -//Adds a new section into the Word Document. +// Adds a new section into the Word Document. IWSection section = document.addSection(); -//Adds a new paragraph into Word document and appends text into paragraph. +// Adds a new paragraph into the Word document and appends text into the paragraph. IWParagraph paragraph = section.addParagraph(); paragraph.appendText("Today's Date: "); -//Adds the new Date field in Word document with field name and its type. +// Adds the new Date field in the Word document with field name and its type. WField field = (WField)paragraph.appendField("Date", FieldType.FieldDate); -//Updates the field. +// Updates the field. field.update(); -//Unlink the field. +// Unlinks the field. field.unlink(); -//Saves the document in the given name and format. +// Saves the document with the given name and format. document.save("Sample.docx", FormatType.Docx); -//Releases the resources occupied by WordDocument instance. +// Releases the resources occupied by the WordDocument instance. document.close(); {% endhighlight %} @@ -263,9 +267,11 @@ document.close(); N> XE (Index Entry) fields cannot be unlinked. ## Sequence Field -You can use the Sequence (SEQ) field to automatically numbers the chapters, tables, figures, and other items in a Word document. When you add, delete, or move an item in Word document (along with SEQ fields), you can update the remaining SEQ fields with a new sequence. + + +You can use the Sequence (SEQ) field to automatically number the chapters, tables, figures, and other items in a Word document. When you add, delete, or move an item in a Word document (along with SEQ fields), you can update the remaining SEQ fields with a new sequence. -You can format the SEQ field using below switches. +You can format the SEQ field using the below switches: \c -- Repeats the closest preceding sequence number. \h -- Hides the field result unless a general-formatting-switch is also present. @@ -273,31 +279,33 @@ You can format the SEQ field using below switches. \r -- Resets the sequence number to the number following “r”. \s -- Resets the sequence number at the heading level following the "s". -### Apply Number format -You can apply the number format for the sequence field using `NumberFormat` property. +### Apply Number Format + -The following code example shows how to apply the number format for sequence field. +You can apply the number format for the sequence field using the `NumberFormat` property. + +The following code example shows how to apply the number format for the sequence field. {% tabs %} {% highlight JAVA %} -//Creates a new document. +// Creates a new document. WordDocument document = createDocument(); -//Accesses sequence field in the document. +// Accesses the sequence field in the document. WSeqField field = (WSeqField)((WParagraph)document.getLastSection().getBody().getChildEntities().get(0)).getChildEntities().get(0); -//Applies the number format for sequence field. +// Applies the number format for the sequence field. field.setNumberFormat(CaptionNumberingFormat.Roman); -//Accesses sequence field in the document. +// Accesses the sequence field in the document. field = (WSeqField)((WParagraph)document.getLastSection().getBody().getChildEntities().get(1)).getChildEntities().get(0); -//Applies the number format for sequence field. +// Applies the number format for the sequence field. field.setNumberFormat(CaptionNumberingFormat.Roman); -//Accesses sequence field in the document. +// Accesses the sequence field in the document. field = (WSeqField)((WParagraph)document.getLastSection().getBody().getChildEntities().get(2)).getChildEntities().get(0); -//Applies the number format for sequence field. +// Applies the number format for the sequence field. field.setNumberFormat(CaptionNumberingFormat.Roman); -//Updates the document fields. +// Updates the document fields. document.updateDocumentFields(); -//Saves and closes the Word document. +// Saves and closes the Word document. document.save("Sample.docx"); document.close(); {% endhighlight %} @@ -311,23 +319,23 @@ The following code example provides supporting methods for the above code. {% highlight JAVA %} private WordDocument createDocument() throws Exception { - //Creates a new document. + // Creates a new document. WordDocument document = new WordDocument(); - //Adds a new section to the document. + // Adds a new section to the document. IWSection section = document.addSection(); - //Sets margin of the section. + // Sets the margin of the section. section.getPageSetup().getMargins().setAll((float)72); - //Adds a paragraph to the section. + // Adds a paragraph to the section. IWParagraph paragraph = section.addParagraph(); - paragraph.appendField("List",FieldType.FieldSequence); + paragraph.appendField("List", FieldType.FieldSequence); paragraph.appendText(".Item1"); - //Adds a paragraph to the section. + // Adds a paragraph to the section. paragraph = section.addParagraph(); - paragraph.appendField("List",FieldType.FieldSequence); + paragraph.appendField("List", FieldType.FieldSequence); paragraph.appendText(".Item2"); - //Adds a paragraph to the section. + // Adds a paragraph to the section. paragraph = section.addParagraph(); - paragraph.appendField("List",FieldType.FieldSequence); + paragraph.appendField("List", FieldType.FieldSequence); paragraph.appendText(".Item3"); return document; } @@ -335,21 +343,21 @@ private WordDocument createDocument() throws Exception {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. -![Output document after applied Number format for SEQ field](WorkingWithFields_images/SEQField_NumberFormat.png) +![Output document after applying Number format for SEQ field](WorkingWithFields_images/SEQField_NumberFormat.png) ### Refer Bookmark -You can refer the sequence field elsewhere in the document by including bookmark name through `BookmarkName` property. The referred sequence field may be present anywhere in the Word document, but not beyond the respective bookmark end. +You can refer to the sequence field elsewhere in the document by including the bookmark name through the `BookmarkName` property. The referred sequence field may be present anywhere in the Word document, but not beyond the respective bookmark end. -For example, you can refer the image caption numbers in sentence by including the bookmark name in sequence field. +For example, you can refer to the image caption numbers in a sentence by including the bookmark name in the sequence field. -The following code example shows how to refer the bookmark in sequence field. +The following code example shows how to refer to the bookmark in the sequence field. {% tabs %} {% highlight JAVA %} -//Opens an existing word document. +//Opens an existing Word document. WordDocument document = new WordDocument("Template.docx"); //Accesses sequence field in the document. WParagraph paragraph = (WParagraph)document.getLastSection().getBody().getChildEntities().get(4); @@ -358,7 +366,7 @@ WSeqField seqField = (WSeqField)paragraph.getChildEntities().get(12); seqField.setBookmarkName("BkmkPurchase"); //Accesses sequence field in the document. paragraph = (WParagraph)document.getLastSection().getParagraphs().get(5); -seqField=(WSeqField)paragraph.getChildEntities().get(1); +seqField = (WSeqField)paragraph.getChildEntities().get(1); //Adds bookmark reference to the sequence field. seqField.setBookmarkName("BkkmUnitPrice"); //Updates the document fields. @@ -370,14 +378,14 @@ document.close(); {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. ![Output document of Bookmark referred in SEQ field](WorkingWithFields_images/SEQField_Bookmark.png) ### Reset numbering -You can reset the numbering for sequence field (\r) using `ResetNumber` property and reset the numbering based on heading level (\s) in the Word document using `ResetHeadingLevel` property. +You can reset the numbering for the sequence field (\r) using the `ResetNumber` property and reset the numbering based on the heading level (\s) in the Word document using the `ResetHeadingLevel` property. -The following code example shows how to reset the numbering for sequence field. +The following code example shows how to reset the numbering for the sequence field. {% tabs %} @@ -387,19 +395,19 @@ WordDocument document = createDocument(); //Accesses sequence field in the document. IWTable table = (WTable)document.getLastSection().getBody().getChildEntities().get(1); WSeqField field = ((WSeqField)((WParagraph)table.get(0,1).getChildEntities().get(0)).getChildEntities().get(1)); -//Resets the number for sequence field. +//Resets the number for the sequence field. field.setResetNumber(1001); //Accesses sequence field in the document. field = ((WSeqField)((WParagraph)table.get(1,1).getChildEntities().get(0)).getChildEntities().get(1)); -//Resets the number for sequence field. +//Resets the number for the sequence field. field.setResetNumber(1002); //Accesses sequence field in the document. field = ((WSeqField)((WParagraph)table.get(2,1).getChildEntities().get(0)).getChildEntities().get(1)); -//Resets the number for sequence field. +//Resets the number for the sequence field. field.setResetNumber(1003); table = (WTable)document.getLastSection().getBody().getChildEntities().get(3); field = ((WSeqField)((WParagraph)table.get(0,1).getChildEntities().get(1)).getChildEntities().get(1)); -//Resets the heading level for sequence field. +//Resets the heading level for the sequence field. field.setResetHeadingLevel(1); //Updates the document fields. document.updateDocumentFields(); @@ -417,20 +425,20 @@ The following code example provides supporting methods for the above code. {% highlight JAVA %} private WordDocument createDocument() throws Exception { - //Creates a new word document. + //Creates a new Word document. WordDocument document = new WordDocument(); - //Adds new section to the document. + //Adds a new section to the document. IWSection section = document.addSection(); - //Sets margin of the section. + //Sets the margin of the section. section.getPageSetup().getMargins().setAll((float)72); - //Adds new paragraph to the section. + //Adds a new paragraph to the section. IWParagraph paragraph = (WParagraph)section.addParagraph(); //Adds text range. IWTextRange textRange = paragraph.appendText("Adventure Works Cycles"); textRange.getCharacterFormat().setFontSize((float)16); textRange.getCharacterFormat().setBold(true); paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); - //Adds a new table into Word document. + //Adds a new table into the Word document. IWTable table = section.addTable(); //Specifies the total number of rows & columns. table.resetCells(3,2); @@ -468,11 +476,11 @@ private WordDocument createDocument() throws Exception paragraph.appendText("Product Overview"); paragraph.applyStyle(BuiltinStyle.Heading1); paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Justify); - //Adds a new table into Word document + //Adds a new table into the Word document table = section.addTable(); //Specifies the total number of rows & columns table.resetCells(3,2); - //Accesses the instance of the cell and adds the content into cell. + //Accesses the instance of the cell and adds the content into the cell. //First row. table.get(0,0).addParagraph().appendPicture(new FileInputStream("Mountain-200.png")); table.get(0,1).addParagraph().appendText("Mountain-200"); @@ -506,18 +514,18 @@ private WordDocument createDocument() throws Exception {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. ![Output of reset numbering in SEQ field](WorkingWithFields_images/SEQField_ResetNumbering.png) ### Repeat nearest number -You can insert the closest preceding sequence number (\c) using `RepeatNearestNumber` property. +You can insert the closest preceding sequence number (\c) using the `RepeatNearestNumber` property. -For example, if you need to display total number of products in a page, you can repeat the closest preceding sequence number which referred for products. +For example, if you need to display the total number of products on a page, you can repeat the closest preceding sequence number, which is referred to for products. The following code example shows how to repeat the closest preceding sequence number in the Word document. -{% tabs %} +{% tabs %} {% highlight JAVA %} //Creates a Word document. @@ -540,74 +548,74 @@ The following code example provides supporting methods for the above code. {% tabs %} {% highlight JAVA %} -private WordDocument createDocument()throws Exception +private WordDocument createDocument() throws Exception { - //Creates a new document. - WordDocument document = new WordDocument(); - //Adds a new section to the document - IWSection section = document.addSection(); - //Inserts the default page header. - IWParagraph paragraph = section.getHeadersFooters().getOddHeader().addParagraph(); - paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Right); - paragraph.appendText("Total No. of Products: "); - paragraph.appendField("Product count",FieldType.FieldSequence); - //Adds a paragraph to the section. - paragraph = section.addParagraph(); - IWTextRange textRange = paragraph.appendText("Adventure Works Cycles"); - paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); - textRange.getCharacterFormat().setFontSize((float)16); - textRange.getCharacterFormat().setBold(true); - //Adds a paragraph to the section. - section.addParagraph().appendText("Product Overview"); - document.getLastParagraph().applyStyle(BuiltinStyle.Heading1); - //Adds a new table into Word document - IWTable table = section.addTable(); - //Specifies the total number of rows & columns. - table.resetCells(3,2); - //Accesses the instance of the cell and adds the content into cell - //First row. - table.get(0,0).addParagraph().appendPicture(new FileInputStream("Mountain-200.png")); - table.get(0,1).addParagraph().appendText("Mountain-200"); - paragraph=table.get(0,1).addParagraph(); - paragraph.appendText("Product No: "); - paragraph.appendField("Product count",FieldType.FieldSequence); - table.get(0,1).addParagraph().appendText("Size: 38"); - table.get(0,1).addParagraph().appendText("Weight: 25"); - table.get(0,1).addParagraph().appendText("Price: $2,294.99"); - //Second row. - table.get(1,0).addParagraph().appendText("Mountain-300"); - paragraph=table.get(1,0).addParagraph(); - paragraph.appendText("Product No: "); - paragraph.appendField("Product count",FieldType.FieldSequence); - table.get(1,0).addParagraph().appendText("Size: 35"); - table.get(1,0).addParagraph().appendText("Weight: 22"); - table.get(1,0).addParagraph().appendText("Price: $1,079.99"); - table.get(1,1).addParagraph().appendPicture(new FileInputStream("Mountain-300.png")); - //Third row. - table.get(2,0).addParagraph().appendPicture(new FileInputStream("Road-550.png")); - table.get(2,1).addParagraph().appendText("Road-150"); - paragraph=table.get(2,1).addParagraph(); - paragraph.appendText("Product No: "); - paragraph.appendField("Product count",FieldType.FieldSequence); - table.get(2,1).addParagraph().appendText("Size: 44"); - table.get(2,1).addParagraph().appendText("Weight: 14"); - table.get(2,1).addParagraph().appendText("Price: $3,578.27"); - return document; + //Creates a new document. + WordDocument document = new WordDocument(); + //Adds a new section to the document. + IWSection section = document.addSection(); + //Inserts the default page header. + IWParagraph paragraph = section.getHeadersFooters().getOddHeader().addParagraph(); + paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Right); + paragraph.appendText("Total No. of Products: "); + paragraph.appendField("Product count", FieldType.FieldSequence); + //Adds a paragraph to the section. + paragraph = section.addParagraph(); + IWTextRange textRange = paragraph.appendText("Adventure Works Cycles"); + paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); + textRange.getCharacterFormat().setFontSize((float)16); + textRange.getCharacterFormat().setBold(true); + //Adds a paragraph to the section. + section.addParagraph().appendText("Product Overview"); + document.getLastParagraph().applyStyle(BuiltinStyle.Heading1); + //Adds a new table into the Word document. + IWTable table = section.addTable(); + //Specifies the total number of rows & columns. + table.resetCells(3, 2); + //Accesses the instance of the cell and adds the content into the cell. + //First row. + table.get(0, 0).addParagraph().appendPicture(new FileInputStream("Mountain-200.png")); + table.get(0, 1).addParagraph().appendText("Mountain-200"); + paragraph = table.get(0, 1).addParagraph(); + paragraph.appendText("Product No: "); + paragraph.appendField("Product count", FieldType.FieldSequence); + table.get(0, 1).addParagraph().appendText("Size: 38"); + table.get(0, 1).addParagraph().appendText("Weight: 25"); + table.get(0, 1).addParagraph().appendText("Price: $2,294.99"); + //Second row. + table.get(1, 0).addParagraph().appendText("Mountain-300"); + paragraph = table.get(1, 0).addParagraph(); + paragraph.appendText("Product No: "); + paragraph.appendField("Product count", FieldType.FieldSequence); + table.get(1, 0).addParagraph().appendText("Size: 35"); + table.get(1, 0).addParagraph().appendText("Weight: 22"); + table.get(1, 0).addParagraph().appendText("Price: $1,079.99"); + table.get(1, 1).addParagraph().appendPicture(new FileInputStream("Mountain-300.png")); + //Third row. + table.get(2, 0).addParagraph().appendPicture(new FileInputStream("Road-550.png")); + table.get(2, 1).addParagraph().appendText("Road-150"); + paragraph = table.get(2, 1).addParagraph(); + paragraph.appendText("Product No: "); + paragraph.appendField("Product count", FieldType.FieldSequence); + table.get(2, 1).addParagraph().appendText("Size: 44"); + table.get(2, 1).addParagraph().appendText("Weight: 14"); + table.get(2, 1).addParagraph().appendText("Price: $3,578.27"); + return document; } {% endhighlight %} {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. ![Output of repeating Nearest number of SEQ field](WorkingWithFields_images/SEQField_RepeatNearestNumber.png) ### Hide -You can hide the field result of the sequence field using `HideResult` property. +You can hide the field result of the sequence field using the `HideResult` property. -For example, if you need to consider the sequence numbering for list of products, but not need to print the numbering for retired products, then you can hide those sequence fields alone. +For example, if you need to consider the sequence numbering for a list of products but do not need to print the numbering for retired products, then you can hide those sequence fields alone. -The following code example shows how to hide the field result of sequence field. +The following code example shows how to hide the field result of the sequence field. {% tabs %} @@ -616,11 +624,11 @@ The following code example shows how to hide the field result of sequence field. WordDocument document = createDocument(); //Accesses sequence field in the document. WTable table = (WTable)document.getLastSection().getBody().getChildEntities().get(1); -WSeqField field = ((WSeqField)((WParagraph)table.get(2,1).getChildEntities().get(0)).getChildEntities().get(0)); -//Enables a flag to to hide the sequence field result. +WSeqField field = ((WSeqField)((WParagraph)table.get(2, 1).getChildEntities().get(0)).getChildEntities().get(0)); +//Enables a flag to hide the sequence field result. field.setHideResult(true); //Accesses sequence field in the document. -field=((WSeqField)((WParagraph)table.get(4,1).getChildEntities().get(0)).getChildEntities().get(0)); +field = ((WSeqField)((WParagraph)table.get(4, 1).getChildEntities().get(0)).getChildEntities().get(0)); //Enables a flag to hide the sequence field result. field.setHideResult(true); //Updates the document fields. @@ -639,74 +647,74 @@ The following code example provides supporting methods for the above code. {% highlight JAVA %} private WordDocument createDocument() throws Exception { - //Creates a new Word document. - WordDocument document = new WordDocument(); - //Adds a new section to the document. - IWSection section = document.addSection(); - //Adds a paragraph to the section. - IWParagraph paragraph = section.addParagraph(); - paragraph.appendText("Syncfusion Product Details"); - paragraph.applyStyle(BuiltinStyle.Heading1); - //Adds a new table . - IWTable table = section.addTable(); - //Specifies the total number of rows & columns - table.resetCells(6,4); - //Accesses the instance of the cell and add the content into cell. - //First row. - table.get(0,0).addParagraph().appendText("S.No"); - table.get(0,1).addParagraph().appendText("Platform Id"); - table.get(0,2).addParagraph().appendText("Platform"); - table.get(0,3).addParagraph().appendText("Status "); - table.get(1,0).addParagraph().appendText("1."); - //Second row. - table.get(1,1).addParagraph().appendField("PlatformCount",FieldType.FieldSequence); - table.get(1,2).addParagraph().appendText("ASP.NET Core"); - table.get(1,3).addParagraph().appendText("Live"); - //Third row. - table.get(2,0).addParagraph().appendText("2."); - table.get(2,1).addParagraph().appendField("PlatformCount",FieldType.FieldSequence); - table.get(2,2).addParagraph().appendText("LightSwitch"); - table.get(2,3).addParagraph().appendText("Retired"); - //Fourth row. - table.get(3,0).addParagraph().appendText("3."); - table.get(3,1).addParagraph().appendField("PlatformCount",FieldType.FieldSequence); - table.get(3,2).addParagraph().appendText("ASP.NET MVC"); - table.get(3,3).addParagraph().appendText("Live"); - //Fifth row. - table.get(4,0).addParagraph().appendText("4."); - table.get(4,1).addParagraph().appendField("PlatformCount",FieldType.FieldSequence); - table.get(4,2).addParagraph().appendText("Silverlight "); - table.get(4,3).addParagraph().appendText("Retired"); - //Sixth row. - table.get(5,0).addParagraph().appendText("5."); - table.get(5,1).addParagraph().appendField("PlatformCount",FieldType.FieldSequence); - table.get(5,2).addParagraph().appendText("Blazor"); - table.get(5,3).addParagraph().appendText("Live"); - section.addParagraph().appendText("Total No. of Platforms : 5"); - return document; + //Creates a new Word document. + WordDocument document = new WordDocument(); + //Adds a new section to the document. + IWSection section = document.addSection(); + //Adds a paragraph to the section. + IWParagraph paragraph = section.addParagraph(); + paragraph.appendText("Syncfusion Product Details"); + paragraph.applyStyle(BuiltinStyle.Heading1); + //Adds a new table. + IWTable table = section.addTable(); + //Specifies the total number of rows & columns. + table.resetCells(6, 4); + //Accesses the instance of the cell and adds the content into the cell. + //First row. + table.get(0, 0).addParagraph().appendText("S.No"); + table.get(0, 1).addParagraph().appendText("Platform Id"); + table.get(0, 2).addParagraph().appendText("Platform"); + table.get(0, 3).addParagraph().appendText("Status "); + table.get(1, 0).addParagraph().appendText("1."); + //Second row. + table.get(1, 1).addParagraph().appendField("PlatformCount", FieldType.FieldSequence); + table.get(1, 2).addParagraph().appendText("ASP.NET Core"); + table.get(1, 3).addParagraph().appendText("Live"); + //Third row. + table.get(2, 0).addParagraph().appendText("2."); + table.get(2, 1).addParagraph().appendField("PlatformCount", FieldType.FieldSequence); + table.get(2, 2).addParagraph().appendText("LightSwitch"); + table.get(2, 3).addParagraph().appendText("Retired"); + //Fourth row. + table.get(3, 0).addParagraph().appendText("3."); + table.get(3, 1).addParagraph().appendField("PlatformCount", FieldType.FieldSequence); + table.get(3, 2).addParagraph().appendText("ASP.NET MVC"); + table.get(3, 3).addParagraph().appendText("Live"); + //Fifth row. + table.get(4, 0).addParagraph().appendText("4."); + table.get(4, 1).addParagraph().appendField("PlatformCount", FieldType.FieldSequence); + table.get(4, 2).addParagraph().appendText("Silverlight "); + table.get(4, 3).addParagraph().appendText("Retired"); + //Sixth row. + table.get(5, 0).addParagraph().appendText("5."); + table.get(5, 1).addParagraph().appendField("PlatformCount", FieldType.FieldSequence); + table.get(5, 2).addParagraph().appendText("Blazor"); + table.get(5, 3).addParagraph().appendText("Live"); + section.addParagraph().appendText("Total No. of Platforms : 5"); + return document; } {% endhighlight %} {% endtabs %} -By executing the above code example, it generates output Word document as follows. +By executing the above code example, it generates an output Word document as follows. ![Output after hiding the sequence field](WorkingWithFields_images/SEQField_Hide.png) ### Next Sequence number -You can insert the next sequence number for the specified items using `InsertNextNumber` property. This is the default. +You can insert the next sequence number for the specified items using the `InsertNextNumber` property. This is the default. The following code example shows how to insert the next sequence number for the specified item. {% tabs %} {% highlight JAVA %} -//Opens an existing word document. +//Opens an existing Word document. WordDocument document = new WordDocument("Template.docx"); //Accesses sequence field in the document. WParagraph paragraph = (WParagraph)document.getLastSection().getBody().getChildEntities().get(4); WSeqField field = (WSeqField)paragraph.getChildEntities().get(12); -//Enables a flag to insert next number for sequence field. +//Enables a flag to insert the next number for sequence field. field.setInsertNextNumber(true); //Updates the document fields. document.updateDocumentFields(); diff --git a/java-file-formats/word-library/working-with-find-and-replace.md b/java-file-formats/word-library/working-with-find-and-replace.md index d94dc28..13fbc89 100644 --- a/java-file-formats/word-library/working-with-find-and-replace.md +++ b/java-file-formats/word-library/working-with-find-and-replace.md @@ -7,94 +7,94 @@ documentation: UG --- # Working with Find and Replace -You can search a particular text you like to change and replace it with another text or part of the document. +You can search for a particular text you want to change and replace it with another text or part of the document. ## Finding contents in a Word document -You can find the first occurrence of a particular text within a single paragraph in the document by using `Find` method and its next occurrence by using `FindNext` method. You can also find a particular text pattern in the document. +You can find the first occurrence of a particular text within a single paragraph in the document by using the `Find` method and its next occurrence by using the `FindNext` method. You can also find a particular text pattern in the document. The following code example illustrates how to find a particular text and its next occurrence in the document. {% tabs %} {% highlight JAVA %} -//Loads the template document +// Loads the template document WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Finds the first occurrence of a particular text in the document +// Finds the first occurrence of a particular text in the document TextSelection textSelection = document.find("as graphical contents", false, true); -//Gets the found text as single text range +// Gets the found text as a single text range WTextRange textRange = textSelection.getAsOneRange(); -//Modifies the text +// Modifies the text textRange.setText("Replaced text"); -//Sets highlight color +// Sets highlight color textRange.getCharacterFormat().setHighlightColor(ColorSupport.getYellow()); -//Finds the next occurrence of a particular text from the previous paragraph +// Finds the next occurrence of a particular text from the previous paragraph textSelection = document.findNext(textRange.getOwnerParagraph(), "paragraph", true, false); -//Gets the found text as single text range +// Gets the found text as a single text range WTextRange range = textSelection.getAsOneRange(); -//Sets bold formatting +// Sets bold formatting range.getCharacterFormat().setBold(true); -//Saves and closes the document +// Saves and closes the document document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -You can find all the occurrence of a particular text within a single paragraph in the document by using `FindAll` method. +You can find all the occurrences of a particular text within a single paragraph in the document by using the `FindAll` method. -The following code example illustrates how to find all the occurrences of a particular text in the document. +The following code example illustrates how to find all occurrences of a particular text in the document. {% tabs %} {% highlight JAVA %} -//Loads the template document +// Loads the template document WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Finds all the occurrences of a particular text -TextSelection[] textSelections = document.findAll("paragraph",false,true); -for(Object textSelection_tempObj : textSelections) -{ - TextSelection textSelection = (TextSelection)textSelection_tempObj; +// Finds all the occurrences of a particular text +TextSelection[] textSelections = document.findAll("paragraph", false, true); +for (Object textSelection_tempObj : textSelections) { + + TextSelection textSelection = (TextSelection) textSelection_tempObj; WTextRange textRange = textSelection.getAsOneRange(); textRange.getCharacterFormat().setHighlightColor(ColorSupport.getYellowGreen()); } -//Saves and closes the document +// Saves and closes the document document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -You can find the first occurrence of a particular text extended to several paragraphs in the document by using `FindSingleLine` method and its next occurrence by using `FindNextSingleLine` method. +You can find the first occurrence of a particular text extended to several paragraphs in the document by using the `FindSingleLine` method and its next occurrence by using the `FindNextSingleLine` method. The following code example illustrates how to find a particular text extended to several paragraphs in the Word document. {% tabs %} {% highlight JAVA %} -//Loads the template document +// Loads the template document WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -//Finds the first occurrence of a particular text extended to several paragraphs in the document +// Finds the first occurrence of a particular text extended to several paragraphs in the document TextSelection[] textSelections = document.findSingleLine("First paragraph Second paragraph", true, false); WParagraph paragraph = null; -for(Object textSelection_tempObj : textSelections) -{ - //Gets the found text as single text range and set highlight color - TextSelection textSelection = (TextSelection)textSelection_tempObj; +for (Object textSelection_tempObj : textSelections) { + + // Gets the found text as a single text range and sets highlight color + TextSelection textSelection = (TextSelection) textSelection_tempObj; WTextRange textRange = textSelection.getAsOneRange(); textRange.getCharacterFormat().setHighlightColor(ColorSupport.getYellowGreen()); - paragraph=textRange.getOwnerParagraph(); + paragraph = textRange.getOwnerParagraph(); } -//Finds the next occurrence of a particular text extended to several paragraphs in the document -textSelections=document.findNextSingleLine(paragraph,"First paragraph Second paragraph",true,false); -for(Object textSelection_tempObj : textSelections) -{ - //Gets the found text as single text range and sets italic formatting - TextSelection textSelection = (TextSelection)textSelection_tempObj; +// Finds the next occurrence of a particular text extended to several paragraphs in the document +textSelections = document.findNextSingleLine(paragraph, "First paragraph Second paragraph", true, false); +for (Object textSelection_tempObj : textSelections) { + + // Gets the found text as a single text range and sets italic formatting + TextSelection textSelection = (TextSelection) textSelection_tempObj; WTextRange text = textSelection.getAsOneRange(); text.getCharacterFormat().setItalic(true); } -//Saves and closes the document +// Saves and closes the document document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} @@ -112,9 +112,9 @@ The following code example illustrates how to replace all occurrences of a missp {% highlight JAVA %} // Opens the input Word document WordDocument document = new WordDocument("Template.docx"); -// Finds all occurrences of a misspelled word and replaces with properly spelled word +// Finds all occurrences of a misspelled word and replaces it with the properly spelled word document.replace("Cyles", "Cycles", true, true); -//Saves and closes the document +// Saves and closes the document document.save("Sample.docx"); document.close(); {% endhighlight %} @@ -125,18 +125,18 @@ document.close(); You can find placeholder text in a Word document and replace it with any desired image. -The following code example illustrates how to find and replace text in a word document with an image +The following code example illustrates how to find and replace text in a Word document with an image. {% tabs %} {% highlight JAVA %} -//Opens the input Word document +// Opens the input Word document WordDocument document = new WordDocument("Template.docx"); -//Finds all the image placeholder text in the Word document +// Finds all the image placeholder text in the Word document TextSelection[] textSelections = document.findAll(Pattern.compile(MatchSupport.trimPattern("^//(.*)"))); -for (int i = 0; i < textSelections.length; i++) -{ - // Replaces the image placeholder text with desired image +for (int i = 0; i < textSelections.length; i++) { + + // Replaces the image placeholder text with the desired image WParagraph paragraph = new WParagraph(document); WPicture picture = (WPicture) paragraph.appendPicture(new FileInputStream(textSelections[i].getSelectedText() + ".png")); TextSelection newSelection = new TextSelection(paragraph, 0, 1); @@ -144,14 +144,14 @@ for (int i = 0; i < textSelections.length; i++) bodyPart.getBodyItems().add(paragraph); document.replace(textSelections[i].getSelectedText(), bodyPart, true, true); } -//Saves and closes the document +// Saves and closes the document document.save("Sample.docx"); document.close(); {% endhighlight %} {% endtabs %} -## Find and replace a pattern of text with a merge field +## Find and replace a pattern of text with a merge field You can find and replace a pattern of text in a Word document with merge fields using Regex. @@ -166,21 +166,21 @@ WordDocument document = new WordDocument("Template.docx"); TextSelection[] textSelections = document.findAll( Pattern.compile(MatchSupport.trimPattern("«([(?i)image(?-i)]*:*[a-zA-Z0-9 ]*:*[a-zA-Z0-9 ]+)»"))); String[] searchedPlaceholders = new String[textSelections.length]; -for (int i = 0; i < textSelections.length; i++) -{ - searchedPlaceholders[(int) i] = textSelections[(int) i].getSelectedText(); +for (int i = 0; i < textSelections.length; i++) { + + searchedPlaceholders[i] = textSelections[i].getSelectedText(); } -for (int i = 0; i < searchedPlaceholders.length; i++) -{ +for (int i = 0; i < searchedPlaceholders.length; i++) { + WParagraph paragraph = new WParagraph(document); - // Replaces the placeholder text enclosed within '«' and '»' with desired merge field - paragraph.appendField(StringSupport.trimEnd(StringSupport.trimStart(searchedPlaceholders[i], '«'), '»'),FieldType.FieldMergeField); + // Replaces the placeholder text enclosed within '«' and '»' with the desired merge field + paragraph.appendField(StringSupport.trimEnd(StringSupport.trimStart(searchedPlaceholders[i], '«'), '»'), FieldType.FieldMergeField); TextSelection newSelection = new TextSelection(paragraph, 0, paragraph.getItems().getCount()); TextBodyPart bodyPart = new TextBodyPart(document); bodyPart.getBodyItems().add(paragraph); - document.replace(searchedPlaceholders[(int) i], bodyPart, true, true, true); + document.replace(searchedPlaceholders[i], bodyPart, true, true, true); } -//Saves and closes the document +// Saves and closes the document document.save("Sample.docx"); document.close(); {% endhighlight %} @@ -227,7 +227,7 @@ document.save("Sample.docx"); {% endtabs %} -The following code example provides supporting method for the above code. +The following code example provides a supporting method for the above code. {% tabs %} @@ -271,7 +271,7 @@ private void importDataToTable(WTable table) throws Exception {% endtabs %} -The following code example provides supporting method for the above code. +The following code example provides a supporting method for the above code. {% tabs %} @@ -355,7 +355,7 @@ document.close(); {% endtabs %} ## Find and replace text extending to several paragraphs -Apart from finding text in a paragraph, you can also find and replace text that extends to several paragraphs in a Word document. You can find the first occurrence of the text that extends to several paragraphs by using the `findSingleLine` method. Find the next occurrences of the text by using the `findNextSingleLine` method. Similarly, you can replace text that extends to several paragraphs by using `replaceSingleLine` method. +Apart from finding text in a paragraph, you can also find and replace text that extends to several paragraphs in a Word document. You can find the first occurrence of the text that extends to several paragraphs by using the `findSingleLine` method. Find the next occurrences of the text by using the `findNextSingleLine` method. Similarly, you can replace text that extends to several paragraphs by using the `replaceSingleLine` method. The following code example illustrates how to replace text that extends to several paragraphs. @@ -386,7 +386,7 @@ document.close(); ## Find text in a Word document and format -You can find text in a Word document and format or highlight it .You can find the first occurrence of text using the `find` method. Find the next occurrences of the text using the `findNext` method. +You can find text in a Word document and format or highlight it. You can find the first occurrence of text using the `find` method. Find the next occurrences of the text using the `findNext` method. The following code example illustrates how to find all occurrences of a length of text and highlight it. @@ -395,7 +395,7 @@ The following code example illustrates how to find all occurrences of a length o {% highlight JAVA %} // Opens the input Word document WordDocument document = new WordDocument("Template.docx", FormatType.Docx); -// Finds all occurrence of the text in the Word document +// Finds all occurrences of the text in the Word document TextSelection[] textSelections = document.findAll("Adventure", true, true); for (int i = 0; i < textSelections.length; i++) { diff --git a/java-file-formats/word-library/working-with-form-fields.md b/java-file-formats/word-library/working-with-form-fields.md index d6dc914..7eb05f9 100644 --- a/java-file-formats/word-library/working-with-form-fields.md +++ b/java-file-formats/word-library/working-with-form-fields.md @@ -1,15 +1,15 @@ --- -title: Working with Form Fields | Word library | Syncfusion -description: This section illustrated how to work with FormFields in Word document using Syncfusion Java Word library (Essential DocIO) +title: Working with Form Fields | Word Library | Syncfusion +description: This section illustrates how to work with form fields in a Word document using the Syncfusion Java Word Library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG --- # Working with Form Fields -You can create template document with form fields such as Text, Checkbox and Drop-Down. You can also open an existing template document and fill the form fields with the specified data. +You can create a template document with form fields such as Text, Checkbox, and Drop-Down. You can also open an existing template document and fill the form fields with specified data. -The following are the types of form field in the Word document +The following are the types of form fields in a Word document: * Checkbox – represented by an instance of WCheckBox * Drop-down – represented by an instance of WDropDownFormField @@ -18,21 +18,21 @@ The following are the types of form field in the Word document ## Check Box -You can add new Checkbox form field to a Word document by using `appendCheckBox` method of `WParagraph` class. +You can add a new checkbox form field to a Word document by using the `appendCheckBox` method of the `WParagraph` class. -The following code illustrates how to add new checkbox form field. +The following code illustrates how to add a new checkbox form field. {% tabs %} {% highlight JAVA %} //Creates a new Word document. WordDocument document = new WordDocument(); -//Adds new section to the document. +//Adds a new section to the document. IWSection section = document.addSection(); -//Adds new paragraph to the section. +//Adds a new paragraph to the section. WParagraph paragraph = (WParagraph)section.addParagraph(); paragraph.appendText("Gender\t"); -//Appends new Checkbox. +//Appends a new Checkbox. WCheckBox checkbox = paragraph.appendCheckBox(); checkbox.setChecked(false); //Sets Checkbox size. @@ -48,13 +48,13 @@ checkbox.setCalculateOnExit(true); paragraph.appendText("Female"); //Saves the Word document. document.save("Checkbox.docx", FormatType.Docx); -//Closes the document +//Closes the document. document.close(); {% endhighlight %} {% endtabs %} -You can modify the checkbox properties such as checked state, size, help text in a Word document. The following code illustrates how to modify the checkbox form field properties. +You can modify the checkbox properties such as checked state, size, and help text in a Word document. The following code illustrates how to modify the checkbox form field properties. {% tabs %} @@ -68,7 +68,7 @@ for (Object item_tempObj : document.getLastParagraph().getChildEntities()) if (item instanceof WCheckBox) { WCheckBox checkbox = (WCheckBox) item; - //Modifies check box properties. + //Modifies checkbox properties. if (checkbox.getChecked()) checkbox.setChecked(false); checkbox.setSizeType(CheckBoxSizeType.Exactly); @@ -76,7 +76,7 @@ for (Object item_tempObj : document.getLastParagraph().getChildEntities()) } //Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document +//Closes the document. document.close(); {% endhighlight %} @@ -84,7 +84,7 @@ document.close(); ## Drop-Down -You can add new Dropdown form field to a Word document by using `appendDropDownFormField` method of `WParagraph` class. +You can add a new dropdown form field to a Word document by using the `appendDropDownFormField` method of the `WParagraph` class. The following code illustrates how to add a new dropdown field. @@ -93,19 +93,19 @@ The following code illustrates how to add a new dropdown field. {% highlight JAVA %} //Creates a new Word document. WordDocument document = new WordDocument(); -//Adds new section to the document. +//Adds a new section to the document. IWSection section = document.addSection(); -//Adds new paragraph to the section. +//Adds a new paragraph to the section. WParagraph paragraph = (WParagraph)section.addParagraph(); paragraph.appendText("Educational Qualification\t"); -//Appends Dropdown field. +//Appends a Dropdown field. WDropDownFormField dropDownField = paragraph.appendDropDownFormField(); //Adds items to the Dropdown items collection. dropDownField.getDropDownItems().add("Higher"); dropDownField.getDropDownItems().add("Vocational"); dropDownField.getDropDownItems().add("Universal"); dropDownField.setEnabled(true); -//Sets the item index for default value. +//Sets the item index for the default value. dropDownField.setDropDownSelectedIndex(1); dropDownField.setCalculateOnExit(true); //Saves the Word document. @@ -116,7 +116,7 @@ document.close(); {% endtabs %} -You can add or modify list of items of a Dropdown form field in a Word document. The following code illustrates how to modify the dropdown list of a Dropdown form field. +You can add or modify the list of items in a dropdown form field in a Word document. The following code illustrates how to modify the dropdown list of a dropdown form field. {% tabs %} @@ -144,29 +144,29 @@ document.close(); {% endtabs %} -## Text Form field +## Text Form Field -You can add new text form field to a Word document by using `appendTextFormField` method of `WParagraph` class. +You can add a new text form field to a Word document by using the `appendTextFormField` method of the `WParagraph` class. -The following code illustrates how to add new text form field. +The following code illustrates how to add a new text form field. {% tabs %} {% highlight JAVA %} //Creates a new Word document. WordDocument document = new WordDocument(); -//Adds new section to the document. +//Adds a new section to the document. IWSection section = document.addSection(); -//Adds new paragraph to the section. +//Adds a new paragraph to the section. WParagraph paragraph = (WParagraph)section.addParagraph(); paragraph.appendText("General Information"); section.addParagraph(); paragraph = (WParagraph)section.addParagraph(); IWTextRange text = paragraph.appendText("Name\t"); text.getCharacterFormat().setBold(true); -//Appends Text form field. +//Appends a Text form field. WTextFormField textField = paragraph.appendTextFormField(null); -//Sets type of Text form field. +//Sets the type of Text form field. textField.setType(TextFormFieldType.RegularText); textField.getCharacterFormat().setFontName("Calibri"); textField.setCalculateOnExit(true); @@ -174,27 +174,27 @@ section.addParagraph(); paragraph = (WParagraph)section.addParagraph(); text = paragraph.appendText("Date of Birth\t"); text.getCharacterFormat().setBold(true); -//Appends Text form field. +//Appends a Text form field. textField = paragraph.appendTextFormField("Date field", DateTimeSupport.toString(LocalDateTime.now(), "MM/DD/YY")); textField.setStringFormat("MM/DD/YY"); textField.setType(TextFormFieldType.DateText); textField.setCalculateOnExit(true); //Saves the Word document. document.save("TextForm.docx", FormatType.Docx); -//Closes the document +//Closes the document. document.close(); {% endhighlight %} {% endtabs %} -You can add or modify text form field properties such as default text, type in a Word document. The following code illustrates how to modify the text form field +You can add or modify text form field properties such as default text and type in a Word document. The following code illustrates how to modify the text form field. {% tabs %} {% highlight JAVA %} //Loads the template document. WordDocument document = new WordDocument("TextForm.docx"); -//Iterates through section. +//Iterates through sections. for (Object section_tempObj : document.getSections()) { WSection section = (WSection) section_tempObj; diff --git a/java-file-formats/word-library/working-with-latex.md b/java-file-formats/word-library/working-with-latex.md index db68505..593cb1e 100644 --- a/java-file-formats/word-library/working-with-latex.md +++ b/java-file-formats/word-library/working-with-latex.md @@ -6,14 +6,14 @@ control: Word Library documentation: UG --- -# Create Equation using LaTeX -The Java Word library allows to create mathematical equation in Word document using **LaTeX**. +# Create Equation Using LaTeX +The Java Word library allows you to create mathematical equations in a Word document using **LaTeX**. ## Accent -Add **accent** equation to a Word document using the LaTeX through **appendMath** API. +Add **accent** equations to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create accent equation using LaTeX in Word document. +The following code example illustrates how to create an accent equation using LaTeX in a Word document. {% tabs %} @@ -118,9 +118,9 @@ The following table demonstrates the LaTeX equivalent to professional format acc ## Bar -Add **bar** equation to a Word document using the LaTeX through **appendMath** API. +Add **bar** equations to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create bar equation using LaTeX in Word document. +The following code example illustrates how to create a bar equation using LaTeX in a Word document. {% tabs %} @@ -130,7 +130,7 @@ The following code example illustrates how to create bar equation using LaTeX in WordDocument document = new WordDocument(); //Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an bar equation using LaTeX. +//Append a bar equation using LaTeX. document.getLastParagraph().appendMath("\\overline{a}"); //Saves the Word document. document.save("Sample.docx", FormatType.Docx); @@ -207,9 +207,9 @@ The following table demonstrates the LaTeX equivalent to professional format box ## Border Box -Add **border box** equation to a Word document using the LaTeX through **appendMath** API. +Add **border box** equations to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create border box equation using LaTeX in Word document. +The following code example illustrates how to create a border box equation using LaTeX in a Word document. {% tabs %} @@ -220,7 +220,7 @@ The following code example illustrates how to create border box equation using L WordDocument document = new WordDocument(); //Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an border box equation using LaTeX. +//Append a border box equation using LaTeX. document.getLastParagraph().appendMath("\\boxed{{x}^{2}+{y}^{2}={z}^{2}}"); //Saves the Word document. document.save("Sample.docx", FormatType.Docx); @@ -428,9 +428,9 @@ The following table demonstrates the LaTeX equivalent to professional format del ## Equation Array -Add **equation array** to a Word document using the LaTeX through **appendMath** API. +Add **equation array** to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create an equation array using LaTeX in Word document. +The following code example illustrates how to create an equation array using LaTeX in a Word document. {% tabs %} @@ -440,7 +440,7 @@ The following code example illustrates how to create an equation array using LaT WordDocument document = new WordDocument(); //Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an box equation using LaTeX. +//Appends a box equation using LaTeX. document.getLastParagraph().appendMath("\\eqarray{a@&b}"); //Saves the Word document. document.save("Sample.docx", FormatType.Docx); @@ -451,7 +451,7 @@ document.close(); {% endtabs %} -The following table demonstrates the LaTeX equivalent to professional format equation array. +The following table demonstrates the LaTeX equivalent to professional format equation arrays. @@ -470,9 +470,9 @@ The following table demonstrates the LaTeX equivalent to professional format equ ## Fraction -Add **fraction** equation to a Word document using the LaTeX through **appendMath** API. +Add **fraction** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create fraction equation using LaTeX in Word document. +The following code example illustrates how to create a fraction equation using LaTeX in a Word document. {% tabs %} @@ -482,7 +482,7 @@ The following code example illustrates how to create fraction equation using LaT WordDocument document = new WordDocument(); //Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an fraction equation using LaTeX. +//Appends a fraction equation using LaTeX. document.getLastParagraph().appendMath("{\\frac{dy}{dx}}"); //Saves the Word document. document.save("Sample.docx", FormatType.Docx); @@ -523,23 +523,23 @@ The following table demonstrates the LaTeX equivalent to professional format fra ## Function -Add **function** equation to a Word document using the LaTeX through **appendMath** API. +Add **delimiter** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create function equation using LaTeX in Word document. +The following code example illustrates how to create a delimiter equation using LaTeX in a Word document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an function equation using LaTeX. -document.getLastParagraph().appendMath("\\sin{\\theta}"); -//Saves the Word document. +// Appends a delimiter equation using LaTeX. +document.getLastParagraph().appendMath("\sin{\theta}"); +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -710,23 +710,23 @@ The following table demonstrates the LaTeX equivalent to professional format fun ## Group character -Add **group character** equation to a Word document using the LaTeX through **appendMath** API. +Add **group character** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create group character equation using LaTeX in Word document. +The following code example illustrates how to create a group character equation using LaTeX in a Word document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an group character equation using LaTeX. -document.getLastParagraph().appendMath("\\overbrace{a-b}"); -//Saves the Word document. +// Appends a group character equation using LaTeX. +document.getLastParagraph().appendMath("\overbrace{a-b}"); +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -757,23 +757,23 @@ The following table demonstrates the LaTeX equivalent to professional format gro ## Limit -Add **limit** equation to a Word document using the LaTeX through **appendMath** API. +Add **limit** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create limit equation using LaTeX in Word document. +The following code example illustrates how to create a limit equation using LaTeX in a Word document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an limit equation using LaTeX. -document.getLastParagraph().appendMath("\\lim\\below{b}{a}"); -//Saves the Word document. +// Appends a limit equation using LaTeX. +document.getLastParagraph().appendMath("\lim\below{b}{a}"); +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -809,23 +809,23 @@ The following table demonstrates the LaTeX equivalent to professional format lim ## Matrix -Add **matrix** equation to a Word document using the LaTeX through **appendMath** API. +Add **matrix** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create matrix equation using LaTeX in Word document. +The following code example illustrates how to create a matrix equation using LaTeX in a Word document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an matrix equation using LaTeX. -document.getLastParagraph().appendMath("\\begin{matrix}a&b\\\\\\end{matrix}"); -//Saves the Word document. +// Appends a matrix equation using LaTeX. +document.getLastParagraph().appendMath("\begin{matrix}a&b\\\end{matrix}"); +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -851,9 +851,9 @@ The following table demonstrates the LaTeX equivalent to professional format mat ## N-array -Add **N-array** equation to a Word document using the LaTeX through **appendMath** API. +Add **N-array** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create N-array equation using LaTeX in Word document. +The following code example illustrates how to create an N-array equation using LaTeX in a Word document. {% tabs %} @@ -943,9 +943,9 @@ The following table demonstrates the LaTeX equivalent to professional format N-a ## Radical -Add **radical** equation to a Word document using the LaTeX through **appendMath** API. +Add **radical** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create radical equation using LaTeX in Word document. +The following code example illustrates how to create a radical equation using LaTeX in a Word document. {% tabs %} @@ -955,7 +955,7 @@ The following code example illustrates how to create radical equation using LaTe WordDocument document = new WordDocument(); //Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an radical equation using LaTeX. +//Append a radical equation using LaTeX. document.getLastParagraph().appendMath("\\sqrt{a}"); //Saves the Word document. document.save("Sample.docx", FormatType.Docx); @@ -1037,23 +1037,23 @@ The following table demonstrates the LaTeX equivalent to professional format Sub ## Left SubSuperScript -Add **Left SubSuperScript** equation to a Word document using the LaTeX through **appendMath** API. +Add **Left SubSuperScript** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create Left SubSuperScript equation using LaTeX in Word document. +The following code example illustrates how to create a Left SubSuperScript equation using LaTeX in a Word document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an Left SubSuperScript equation using LaTeX. +// Append a Left SubSuperScript equation using LaTeX. document.getLastParagraph().appendMath("{_{40}^{20}}{100}"); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -1079,23 +1079,23 @@ The following table demonstrates the LaTeX equivalent to professional format Lef ## Right SubSuperScript -Add **Right SubSuperScript** equation to a Word document using the LaTeX through **appendMath** API. +Add **Right SubSuperScript** equation to a Word document using LaTeX through the **appendMath** API. -The following code example illustrates how to create Right SubSuperScript equation using LaTeX in Word document. +The following code example illustrates how to create a Right SubSuperScript equation using LaTeX in a Word document. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an Right SubSuperScript equation using LaTeX. +// Appends a Right SubSuperScript equation using LaTeX. document.getLastParagraph().appendMath("{100}_{40}^{20}"); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -1152,17 +1152,17 @@ The following code example demonstrates how to apply styles to characters within {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an accent equation with bold using LaTeX. +// Appends an accent equation with bold using LaTeX. document.getLastParagraph().appendMath("\\dot{\\mathbf{a}}"); -//Append an accent equation with bold-italic using LaTeX. +// Appends an accent equation with bold-italic using LaTeX. document.getLastSection().addParagraph().appendMath("\\dot{\\mathbit{a}}"); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -1212,23 +1212,23 @@ The following code examples show how to apply the scripts to equations in a Word {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an accent equation with Double-Struck font using LaTeX. +// Appends an accent equation with Double-Struck font using LaTeX. document.getLastParagraph().appendMath("\\dot{\\mathbb{a}}"); -//Append an accent equation with Fraktur font using LaTeX. +// Appends an accent equation with Fraktur font using LaTeX. document.getLastSection().addParagraph().appendMath("\\dot{\\mathfrak{a}}"); -//Append an accent equation with Sans Serif font using LaTeX. +// Appends an accent equation with Sans Serif font using LaTeX. document.getLastSection().addParagraph().appendMath("\\dot{\\mathsf{a}}"); -//Append an accent equation with Script using LaTeX. +// Appends an accent equation with Script using LaTeX. document.getLastSection().addParagraph().appendMath("\\dot{\\mathcal{a}}"); -//Append an accent equation with Script using LaTeX. +// Appends an accent equation with Script using LaTeX. document.getLastSection().addParagraph().appendMath("\\dot{\\mathscr{a}}"); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -1247,15 +1247,15 @@ The following code example shows how to preserve text as normal text, without an {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an accent equation as normal text using LaTeX. +// Appends an accent equation as normal text using LaTeX. document.getLastParagraph().appendMath("\\dot{\\mathrm{a}}"); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} @@ -1273,17 +1273,17 @@ The following code examples show how to apply the justification to equations in {% highlight JAVA %} {% raw %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -//Append an border box equation using LaTeX. +// Appends a border box equation using LaTeX. WMath math = document.getLastParagraph().appendMath("\\boxed{{x}^{2}+{y}^{2}={z}^{2}}"); -//Apply math justification. +// Applies math justification. math.getMathParagraph().setJustification(MathJustification.Left); -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endraw %} @@ -1301,31 +1301,30 @@ The following code snippet shows how to modify the LaTeX equation in a Word docu {% highlight JAVA %} -//Creates a new Word document. +// Creates a new Word document. WordDocument document = new WordDocument("Template.docx", FormatType.Automatic); -//Adds one section and one paragraph to the document. +// Adds one section and one paragraph to the document. document.ensureMinimal(); -// Access the first paragraph from the last section of the document. +// Accesses the first paragraph from the last section of the document. WParagraph paragraph = (WParagraph)document.getLastSection().getBody().getChildEntities().get(0); -// Retrieve the first math equation in the paragraph, if it exists. +// Retrieves the first math equation in the paragraph, if it exists. WMath math = (WMath) paragraph.getChildEntities().get(0); if (math != null) { - // Get the LaTeX representation of the math equation. + // Gets the LaTeX representation of the math equation. String laTeX = math.getMathParagraph().getLaTeX(); - // Replace occurrences of 'x' with 'k' in the LaTeX representation. + // Replaces occurrences of 'x' with 'k' in the LaTeX representation. math.getMathParagraph().setLaTeX(laTeX.replace("x", "k")); } -//Saves the Word document. +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document. +// Closes the document. document.close(); {% endhighlight %} {% endtabs %} -![Edit equation using LaTeX](WorkingwithMathematicalEquation_images/ModifyLaTeXEquation.png) - +![Edit equation using LaTeX](WorkingwithMathematicalEquation_images/ModifyLaTeXEquation.png) \ No newline at end of file diff --git a/java-file-formats/word-library/working-with-lists.md b/java-file-formats/word-library/working-with-lists.md index b6112da..b8c4098 100644 --- a/java-file-formats/word-library/working-with-lists.md +++ b/java-file-formats/word-library/working-with-lists.md @@ -1,181 +1,181 @@ --- title: Working with Lists | Syncfusion -description: This section explains how to work with the lists in Word document using Syncfusion Java Word library (Essential DocIO) +description: This section explains how to work with lists in a Word document using the Syncfusion Java Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG --- -# Working with lists +# Working with Lists -Lists can organize and format the contents of a document in hierarchical way. There are nine levels in the list, starting from level 0 to level 8. DocIO supports both built-in list styles and custom list styles. The following are the types of list supported in DocIO: +Lists can organize and format the contents of a document in a hierarchical way. There are nine levels in a list, starting from level 0 to level 8. DocIO supports both built-in list styles and custom list styles. The following are the types of lists supported in DocIO: * Numbered list -* Bulleted list +* Bulleted list ## Create Bulleted List The following code example explains how to create a simple bulleted list. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Apply the default numbered list style. +// Apply the default bulleted list style. paragraph.getListFormat().applyDefBulletStyle(); -//Add text to the paragraph. +// Add text to the paragraph. paragraph.appendText("List item 1"); -//Continue the list defined. +// Continue the list defined. paragraph.getListFormat().continueListNumbering(); -//Add the second paragraph. +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 2"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Add a new paragraph. +// Add a new paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 3"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Save the Word document. +// Save the Word document. document.save("simple bulleted list.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Create Numbered List The following code example explains how to create a simple numbered list. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Apply the default numbered list style. +// Apply the default numbered list style. paragraph.getListFormat().applyDefNumberedStyle(); -//Add the text to the paragraph. +// Add text to the paragraph. paragraph.appendText("List item 1"); -//Continue the list defined. +// Continue the list defined. paragraph.getListFormat().continueListNumbering(); -//Add the second paragraph. +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 2"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Add a new paragraph. +// Add a new paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 3"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Create Multilevel List The following code example explains how to create a multilevel bulleted list. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Apply the default numbered list style. +// Apply the default bulleted list style. paragraph.getListFormat().applyDefBulletStyle(); -//Add the text to the paragraph. +// Add text to the paragraph. paragraph.appendText("List item 1 - Level 0"); -//Continue the list defined. +// Continue the list defined. paragraph.getListFormat().continueListNumbering(); -//Add the second paragraph. +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 2 - Level 1"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Add a new paragraph. +// Add a new paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 3 - Level 2"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Create Multilevel Numbered List -The following code example explains how to create multilevel numbered list. +The following code example explains how to create a multilevel numbered list. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Apply the default numbered list style. +// Apply the default numbered list style. paragraph.getListFormat().applyDefNumberedStyle(); -//Add the text to the paragraph. +// Add text to the paragraph. paragraph.appendText("List item 1 - Level 0"); -//Continue the list defined. +// Continue the list defined. paragraph.getListFormat().continueListNumbering(); -//Add the second paragraph. +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 2 - Level 1"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Add a new paragraph. +// Add a new paragraph. paragraph = section.addParagraph(); paragraph.appendText("List item 3 - Level 2"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## List number format -The ListPatternType enum in DocIO lets you customize how list numbers appear in Word documents. It supports 61 styles, including Arabic, Hebrew, and more. This is useful for creating region-specific documents or applying culturally appropriate numbering formats. +The `ListPatternType` enum in DocIO lets you customize how list numbers appear in Word documents. It supports 61 styles, including Arabic, Hebrew, and more. This is useful for creating region-specific documents or applying culturally appropriate numbering formats. The following code example demonstrates how to create a list number format. -{% tabs %} +{% tabs %} {% highlight JAVA %} // Creates a new Word document. @@ -191,17 +191,17 @@ levelOne.setStartAt(1); // Adds a heading paragraph for the CardinalText list. IWParagraph paragraph = section.addParagraph(); paragraph.appendText("List pattern Cardinal Text"); -// Adds first list item using CardinalText style. +// Adds the first list item using CardinalText style. paragraph = section.addParagraph(); paragraph.appendText("List item 1"); paragraph.getListFormat().applyStyle("CardinalText"); paragraph.getListFormat().continueListNumbering(); -// Adds second list item using CardinalText style. +// Adds the second list item using CardinalText style. paragraph = section.addParagraph(); paragraph.appendText("List item 2"); paragraph.getListFormat().applyStyle("CardinalText"); paragraph.getListFormat().continueListNumbering(); -// Adds third list item using CardinalText style. +// Adds the third list item using CardinalText style. paragraph = section.addParagraph(); paragraph.appendText("List item 3"); paragraph.getListFormat().applyStyle("CardinalText"); @@ -217,17 +217,17 @@ levelOne.setStartAt(1); // Adds a heading paragraph for the HindiLetter1 list. paragraph = section.addParagraph(); paragraph.appendText("List pattern Hindi Letter"); -// Adds first list item using HindiLetter1 style. +// Adds the first list item using HindiLetter1 style. paragraph = section.addParagraph(); paragraph.appendText("List item 1"); paragraph.getListFormat().applyStyle("HindiLetter1"); paragraph.getListFormat().continueListNumbering(); -// Adds second list item using HindiLetter1 style. +// Adds the second list item using HindiLetter1 style. paragraph = section.addParagraph(); paragraph.appendText("List item 2"); paragraph.getListFormat().applyStyle("HindiLetter1"); paragraph.getListFormat().continueListNumbering(); -// Adds third list item using HindiLetter1 style. +// Adds the third list item using HindiLetter1 style. paragraph = section.addParagraph(); paragraph.appendText("List item 3"); paragraph.getListFormat().applyStyle("HindiLetter1"); @@ -243,29 +243,29 @@ levelOne.setStartAt(1); // Adds a heading paragraph for the Hebrew1 list. paragraph = section.addParagraph(); paragraph.appendText("List pattern Hebrew"); -// Adds first list item using Hebrew1 style. +// Adds the first list item using Hebrew1 style. paragraph = section.addParagraph(); paragraph.appendText("List item 1"); paragraph.getListFormat().applyStyle("Hebrew1"); paragraph.getListFormat().continueListNumbering(); -// Adds second list item using Hebrew1 style. +// Adds the second list item using Hebrew1 style. paragraph = section.addParagraph(); paragraph.appendText("List item 2"); paragraph.getListFormat().applyStyle("Hebrew1"); paragraph.getListFormat().continueListNumbering(); -// Adds third list item using Hebrew1 style. +// Adds the third list item using Hebrew1 style. paragraph = section.addParagraph(); paragraph.appendText("List item 3"); paragraph.getListFormat().applyStyle("Hebrew1"); paragraph.getListFormat().continueListNumbering(); -// Saves the Word document +// Saves the Word document. document.save("Sample.docx", FormatType.Docx); -// Closes the document +// Closes the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} N> Except for the following [ListPatternType](https://help.syncfusion.com/cr/document-processing/Syncfusion.DocIO.DLS.ListPatternType.html) enumeration values: Arabic, Bullet, ChineseCountingThousand, FarEast, KanjiDigit, LeadingZero, LowLetter, LowRoman, None, Number, Ordinal, OrdinalText, Special, UpLetter, and UpRoman, all other [ListPatternType](https://help.syncfusion.com/cr/document-processing/Syncfusion.DocIO.DLS.ListPatternType.html) values are supported only during DOCX to DOCX conversions. @@ -274,180 +274,182 @@ N> Except for the following [ListPatternType](https://help.syncfusion.com/cr/doc The list levels can be incremented or decremented by using the `increaseIndentLevel` and `decreaseIndentLevel` methods respectively. The following code example explains how to increase or decrease the list indent levels. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Apply the default numbered list style. +// Apply the default numbered list style. paragraph.getListFormat().applyDefNumberedStyle(); -//Add the text to the paragraph. +// Add the text to the paragraph. paragraph.appendText("Multilevel numbered list - Level 0"); -//Continue the list defined. +// Continue the list defined. paragraph.getListFormat().continueListNumbering(); -//Add the second paragraph +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("Multilevel numbered list - Level 1"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Add a new paragraph. +// Add a new paragraph. paragraph = section.addParagraph(); paragraph.appendText("Multilevel numbered list - Level 0"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Decrease the level indent. paragraph.getListFormat().decreaseIndentLevel(); -//Add a new paragraph. +// Add a new paragraph. paragraph = section.addParagraph(); paragraph.appendText("Multilevel numbered list - Level 1"); -//Continue he last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Customize List -The following code example explains how to create user defined list styles. +The following code example explains how to create user-defined list styles. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. -IWSection section = document.addSection(); -//Add a new list style to the document. +// Add a new section to the document. +IWSection section = document.addSection(); +// Add a new list style to the document. ListStyle listStyle = document.addListStyle(ListType.Numbered, "UserDefinedList"); WListLevel levelOne = listStyle.getLevels().get(0); -//Define the follow character, prefix, suffix, and start index for level 0. +// Define the follow character, prefix, suffix, and start index for level 0. levelOne.setFollowCharacter(FollowCharacterType.Tab); levelOne.setNumberPrefix("("); -levelOne.setNumberSufix(")"); +levelOne.setNumberSuffix(")"); levelOne.setPatternType(ListPatternType.LowRoman); levelOne.setStartAt(1); levelOne.setTabSpaceAfter(5); levelOne.setNumberAlignment(ListNumberAlignment.Center); WListLevel levelTwo = listStyle.getLevels().get(1); -//Define the follow character, suffix, pattern, and start index for level 1. +// Define the follow character, suffix, pattern, and start index for level 1. levelTwo.setFollowCharacter(FollowCharacterType.Tab); levelTwo.setNumberPrefix("}"); levelTwo.setPatternType(ListPatternType.LowLetter); -levelTwo.setStartAt(2); -//Add a new paragraph to the section. -IWParagraph paragraph = section.addParagraph(); -//Add the text to the paragraph. +levelTwo.setStartAt(2); +// Add a new paragraph to the section. +IWParagraph paragraph = section.addParagraph(); +// Add the text to the paragraph. paragraph.appendText("User defined list - Level 0"); -//Apply the default numbered list style. +// Apply the default numbered list style. paragraph.getListFormat().applyStyle("UserDefinedList"); -//Add the second paragraph. +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("User defined list - Level 1"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Numbered List with Prefix -The following code example explains how to create numbered list with prefix from previous level. +The following code example explains how to create a numbered list with a prefix from the previous level. + +N> The `NumberPrefix` value for the numbered list should meet the syntax "\u000N" to update the previous list level value as a prefix to the current list level. For example, it should be represented as ("\u0000." or "\u0000.\u0001."). + -N> The `NumberPrefix` value for the numbered list should meet the syntax “\u000N” to update the previous list level value as a prefix to the current list level. For example, it should be represented as (“\u0000.” or “\u0000.\u0001.”). -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. -IWSection section = document.addSection(); -//Add a new list style to the document. +// Add a new section to the document. +IWSection section = document.addSection(); +// Add a new list style to the document. ListStyle listStyle = document.addListStyle(ListType.Numbered, "UserDefinedList"); WListLevel levelOne = listStyle.getLevels().get(0); -//Define the follow character, prefix from previous level, and start index for level 0. +// Define the follow character, prefix from previous level, and start index for level 0. levelOne.setFollowCharacter(FollowCharacterType.Nothing); levelOne.setPatternType(ListPatternType.Arabic); levelOne.setStartAt(1); WListLevel levelTwo = listStyle.getLevels().get(1); -//Define the follow character, prefix from previous level, pattern, and start index for level 1. +// Define the follow character, prefix from previous level, pattern, and start index for level 1. levelTwo.setFollowCharacter(FollowCharacterType.Nothing); levelTwo.setNumberPrefix("\u0000."); levelTwo.setPatternType(ListPatternType.Arabic); levelTwo.setStartAt(1); WListLevel levelThree = listStyle.getLevels().get(2); -//Define the follow character, prefix from previous level, pattern, and start index for level 1. +// Define the follow character, prefix from previous level, pattern, and start index for level 2. levelThree.setFollowCharacter(FollowCharacterType.Nothing); levelThree.setNumberPrefix("\u0000.\u0001."); levelThree.setPatternType(ListPatternType.Arabic); -levelThree.setStartAt(1); -//Add a new paragraph to the section. -IWParagraph paragraph = section.addParagraph(); -//Add a text to the paragraph. +levelThree.setStartAt(1); +// Add a new paragraph to the section. +IWParagraph paragraph = section.addParagraph(); +// Add text to the paragraph. paragraph.appendText("User defined list - Level 0"); -//Apply the default numbered list style. +// Apply the default numbered list style. paragraph.getListFormat().applyStyle("UserDefinedList"); -//Add the second paragraph. +// Add the second paragraph. paragraph = section.addParagraph(); paragraph.appendText("User defined list - Level 1"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Add the second paragraph. +// Add the third paragraph. paragraph = section.addParagraph(); paragraph.appendText("User defined list - Level 2"); -//Continue the last defined list. +// Continue the last defined list. paragraph.getListFormat().continueListNumbering(); -//Increase the level indent. +// Increase the level indent. paragraph.getListFormat().increaseIndentLevel(); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Get list value -You can get the string that represents the appearance of **list value of the paragraph** in the Word document using the `ListString` API. +You can get the string that represents the appearance of **list value of the paragraph** in the Word document using the `ListString` API. This API holds the static string of the list value recently calculated while saving the document as Text. It is not updated automatically for each modification done in the Word document. Hence, you should either invoke the `getText()` method of `WordDocument` or save the Word document as Text to get the actual list value from this API. -The following example shows how to **get a string that represents the appearance of list value of the paragraph**. +The following example shows how to **get a string that represents the appearance of the list value of the paragraph**. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Load an existing Word document. +// Load an existing Word document. WordDocument document = new WordDocument("Template.docx"); -//Get the document text. +// Get the document text. document.getText(); -//Get the string that represents the appearance of list value of the paragraph. +// Get the string that represents the appearance of the list value of the paragraph. String listString = document.getLastParagraph().getListString(); -//Save and close the WordDocument instance. +// Save and close the WordDocument instance. document.save("Sample.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -N> For a picture bulleted list, the `ListString` API is not valid and it will return an empty string. +N> For a picture bulleted list, the `ListString` API is not valid, and it will return an empty string. \ No newline at end of file diff --git a/java-file-formats/word-library/working-with-mail-merge.md b/java-file-formats/word-library/working-with-mail-merge.md index 28216fa..1a981b5 100644 --- a/java-file-formats/word-library/working-with-mail-merge.md +++ b/java-file-formats/word-library/working-with-mail-merge.md @@ -1,45 +1,45 @@ --- -title: Working with Mail merge | Syncfusion -description: This section illustrates about Mail merge Word document to create reports (letters, envelopes, labels, invoice, payroll) without MS Word or Office interop. +title: Working with Mail Merge | Syncfusion +description: This section illustrates how to use the Mail Merge feature in Word documents to create reports (letters, envelopes, labels, invoices, payroll) without MS Word or Office interop. platform: java-file-formats control: Word Library documentation: UG --- -# Working with Mail merge +# Working with Mail Merge -Mail merge is a process of merging data from data source to a Word template document. The `WMergeField` class provides support to bind template document and data source. The `WMergeField` instance is replaced with the actual data retrieved from data source for the given merge field name in a template document. +Mail Merge is a process of merging data from a data source into a Word template document. The `WMergeField` class provides support for binding the template document and data source. The `WMergeField` instance is replaced with the actual data retrieved from the data source for the given merge field name in a template document. -The following data sources are supported by Essential® DocIO for performing Mail merge: +The following data sources are supported by Essential® DocIO for performing Mail Merge: * String Arrays -* Java objects +* Java Objects -## Mail merge process +## Mail Merge Process -The mail merge process involves three documents: +The Mail Merge process involves three documents: -1. **Template Word document**: This document contains the static or templated text and graphics along with the merge fields (that are placeholders) for replacing dynamic data. +1. **Template Word Document**: This document contains static or templated text and graphics, along with the merge fields (placeholders) for replacing dynamic data. -2. **Data source**: This represents file containing data to replace the merge fields in template Word document. +2. **Data Source**: This represents a file containing data to replace the merge fields in the template Word document. -3. **Final merged document**: This resultant document is a combination of the template Word document and the data from data source. +3. **Final Merged Document**: This resultant document is a combination of the template Word document and the data from the data source. -T> 1. You can use conditional fields ([IF](https://support.microsoft.com/en-us/office/field-codes-if-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e?ui=en-us&rs=en-us&ad=us), [Formula](https://support.microsoft.com/en-us/office/field-codes-formula-field-32d5c9de-3516-4ec3-80ed-d1fc2b5bc21d?ui=en-us&rs=en-us&ad=us)) combined with merge fields, when you require intelligent decisions in addition to simple mail merge (replace merge fields with result text). To use conditional fields, execute mail merge and then update fields in the Word document using `updateDocumentFields` API. -T> 2. You can replace the fields ([IF](https://support.microsoft.com/en-us/office/field-codes-if-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e?ui=en-us&rs=en-us&ad=us), [Formula](https://support.microsoft.com/en-us/office/field-codes-formula-field-32d5c9de-3516-4ec3-80ed-d1fc2b5bc21d?ui=en-us&rs=en-us&ad=us)) combined with merge fields, with its most recent result and **generates the plain Word document** by unlinking the fields. Refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-fields#unlink-fields) for more information. +T> 1. You can use conditional fields ([IF](https://support.microsoft.com/en-us/office/field-codes-if-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e?ui=en-us&rs=en-us&ad=us), [Formula](https://support.microsoft.com/en-us/office/field-codes-formula-field-32d5c9de-3516-4ec3-80ed-d1fc2b5bc21d?ui=en-us&rs=en-us&ad=us)) combined with merge fields when you require intelligent decisions in addition to simple Mail Merge (replacing merge fields with result text). To use conditional fields, execute Mail Merge and then update fields in the Word document using the `updateDocumentFields` API. +T> 2. You can replace the fields ([IF](https://support.microsoft.com/en-us/office/field-codes-if-field-9f79e82f-e53b-4ff5-9d2c-ae3b22b7eb5e?ui=en-us&rs=en-us&ad=us), [Formula](https://support.microsoft.com/en-us/office/field-codes-formula-field-32d5c9de-3516-4ec3-80ed-d1fc2b5bc21d?ui=en-us&rs=en-us&ad=us)) combined with merge fields with their most recent result and **generate a plain Word document** by unlinking the fields. Refer to this [link](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-fields#unlink-fields) for more information. -### Create Word document template +### Create Word Document Template -You can create a template document with merge fields by using any Word editor application, like Microsoft Word. By using Word editor application, you can take the advantage of the visual interface to design unique layout, formatting, and more for your Word document template interactively. +You can create a template document with merge fields by using any Word editor application, such as Microsoft Word. By using a Word editor application, you can take advantage of the visual interface to design a unique layout, formatting, and more for your Word document template interactively. -The following screenshot shows how to insert a merge field in the Word document by **using the Microsoft Word.** +The following screenshot shows how to insert a merge field in the Word document **using Microsoft Word.** ![Word template document](MailMerge_images/MailMerge_template.png) -You need to add a prefix (“Image:”) to the merge field name for merging an image in the place of a merge field. +You need to add a prefix ("Image:") to the merge field name for merging an image in place of a merge field. -**For example:** The merge field name should be like “Image:Photo” (<>) +**For example:** The merge field name should be like "Image:Photo" (<>). -You can **create Word document template programmatically** by adding merge fields to the Word document using Essential® DocIO. +You can **create a Word document template programmatically** by adding merge fields to the Word document using Essential® DocIO. The following code example shows how to create a merge field in the Word document. @@ -48,7 +48,7 @@ The following code example shows how to create a merge field in the Word documen {% highlight JAVA %} //Creates an instance of a WordDocument. WordDocument document = new WordDocument(); -//Adds a section and a paragraph in the document. +//Adds a section and a paragraph to the document. document.ensureMinimal(); //Appends merge field to the last paragraph. document.getLastParagraph().appendField("FullName", FieldType.FieldMergeField); @@ -59,9 +59,9 @@ document.close(); {% endhighlight %} {% endtabs %} -### Execute mail merge +### Execute Mail Merge -The following code example shows how to perform mail merge in above Word document template using string arrays as data source. +The following code example shows how to perform Mail Merge in the above Word document template using string arrays as the data source. {% tabs %} {% highlight JAVA %} @@ -70,7 +70,7 @@ FileInputStream fileStreamPath = new FileInputStream("Template.docx"); WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx); String[] fieldNames = new String[] { "FullName" }; String[] fieldValues = new String[] { "Nancy Davolio" }; -//Performs the mail merge. +//Performs the Mail Merge. document.getMailMerge().execute(fieldNames, fieldValues); //Saves the Word document. document.save("Output.docx", FormatType.Docx); @@ -83,72 +83,68 @@ By executing the previous code example, it generates the resultant Word document ![Mail merge Word document](MailMerge_images/MailMerge_output.png) -## Simple Mail merge +## Simple Mail Merge -The `MailMerge` class provides various overloads for the `Execute` method to perform Mail merge from various data sources. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/simple-mail-merge). +The `MailMerge` class provides various overloads for the `Execute` method to perform Mail Merge from various data sources. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/simple-mail-merge). -## Performing Mail merge for a group +## Performing Mail Merge for a Group -You can perform Mail merge and append multiple records from data source within a specified region to a template document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-group). +You can perform Mail Merge and append multiple records from the data source within a specified region to a template document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-group). -## Performing Nested Mail merge for group +## Performing Nested Mail Merge for Group -You can perform nested Mail merge with relational or hierarchical data source and independent data tables in a template document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-nested-groups). +You can perform nested Mail Merge with relational or hierarchical data sources and independent data tables in a template document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-nested-groups). -## Performing Mail merge with business objects +## Performing Mail Merge with Business Objects -You can perform Mail merge with business objects in a template document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-group#mail-merge-with-Java-objects). +You can perform Mail Merge with business objects in a template document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-group#mail-merge-with-Java-objects). -## Performing Nested Mail merge with relational data objects +## Performing Nested Mail Merge with Relational Data Objects -Essential® DocIO supports performing nested Mail merge with implicit relational data objects without any explicit relational commands by using the `ExecuteNestedGroup` overload method. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-nested-groups#mail-merge-with-implicit-relational-data). +Essential® DocIO supports performing nested Mail Merge with implicit relational data objects without any explicit relational commands by using the `ExecuteNestedGroup` overload method. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-for-nested-groups#mail-merge-with-implicit-relational-data). -## Event support for mail merge +## Event Support for Mail Merge -The `MailMerge` class provides event support to customize the document contents and merging image data during the Mail merge process. The following events are supported by Essential® DocIO in Mail merge process: +The `MailMerge` class provides event support to customize the document contents and merge image data during the Mail Merge process. The following events are supported by Essential® DocIO in the Mail Merge process: -* `MergeField`: Occurs when a **Mail merge field** except image Mail merge field is encountered. +* `MergeField`: Occurs when a **Mail Merge field** except an image Mail Merge field is encountered. -* `MergeImageField`: Occurs when an **image Mail merge field** is encountered. +* `MergeImageField`: Occurs when an **image Mail Merge field** is encountered. * `BeforeClearGroupField`: Occurs when an **unmerged group field** is encountered. -### MergeField event +### MergeField Event -You can customize the merging text during Mail merge process by using the `MergeField` event. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-events#mergefield-event). +You can customize the merging text during the Mail Merge process by using the `MergeField` event. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-events#mergefield-event). -### MergeImageField event +### MergeImageField Event -You can customize the merging image during Mail merge process by using the `MergeImageField` event. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-events#mergeimagefield-event). +You can customize the merging image during the Mail Merge process by using the `MergeImageField` event. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-events#mergeimagefield-event). -### BeforeClearGroupField event +### BeforeClearGroupField Event -You can get the unmerged groups during Mail merge process by using the `BeforeClearGroupField` event. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-events#beforecleargroupfield-event). +You can get the unmerged groups during the Mail Merge process by using the `BeforeClearGroupField` event. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-events#beforecleargroupfield-event). -## Mail merge options +## Mail Merge Options -The `MailMerge` class allows you to customize the Mail merge process with the following options: +The `MailMerge` class allows you to customize the Mail Merge process with the following options: -### Field mapping +### Field Mapping -You can automatically map the merge field names with data source column names during Mail merge process. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#field-mapping). +You can automatically map the merge field names with data source column names during the Mail Merge process. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#field-mapping). -### Retrieving the merge field names +### Retrieving the Merge Field Names You can retrieve the merge field names and also merge field group names in the Word document. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#retrieve-the-merge-field-names). -### Removing empty paragraphs +### Removing Empty Paragraphs -You can remove the empty paragraphs when the paragraph has a merge field item without any data during Mail merge process. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#remove-empty-paragraphs). +You can remove the empty paragraphs when the paragraph contains a merge field item without any data during the Mail Merge process. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#remove-empty-paragraphs). -### Removing empty merge fields +### Removing Empty Merge Fields -You can remove or keep the unmerged merge fields in the output document based on the `ClearFields` property on each mail merge execution. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#remove-empty-merge-fields). +You can remove or keep the unmerged merge fields in the output document based on the `ClearFields` property during each Mail Merge execution. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#remove-empty-merge-fields). -### Restart numbering in lists +### Restart Numbering in Lists -You can restart the list numbering in a Word document during Mail merge. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#restart-numbering-in-lists). - -## See also - -* [How to Execute Nested Group with JSON in Word Document Using Java?](https://support.syncfusion.com/kb/article/20141/how-to-execute-nested-group-with-json-in-word-document-using-java) \ No newline at end of file +You can restart the list numbering in a Word document during the Mail Merge process. For further information, click [here](https://help.syncfusion.com/document-processing/word/word-library/java/mail-merge/mail-merge-options#restart-numbering-in-lists). \ No newline at end of file diff --git a/java-file-formats/word-library/working-with-mathematical-equation.md b/java-file-formats/word-library/working-with-mathematical-equation.md index bd55151..8283bdc 100644 --- a/java-file-formats/word-library/working-with-mathematical-equation.md +++ b/java-file-formats/word-library/working-with-mathematical-equation.md @@ -1,26 +1,26 @@ --- -title: Working with Mathematical Equation | Syncfusion -description: This section illustrates about create, modify and remove mathematical equation in Word document without MS Word or Office interop +title: Working with Mathematical Equations | Syncfusion +description: This section illustrates how to create, modify, and remove mathematical equations in Word documents without MS Word or Office interop. platform: java-file-formats control: Word Library documentation: UG --- -# Working with Mathematical Equation +# Working with Mathematical Equations -Equations in Word document are combination of mathematical symbols or text. For example, you can create a Fourier series equation in Word document. +Equations in Word documents are combinations of mathematical symbols or text. For example, you can create a Fourier series equation in a Word document. -The Java Word library offers two ways to create and modify equations in Word document. +The Java Word library offers two ways to create and modify equations in Word documents: * [Using WMath DOM](https://help.syncfusion.com/java-file-formats/word-library/working-with-mathematical-equation#types-of-equation). * [Using LaTeX](https://help.syncfusion.com/java-file-formats/word-library/working-with-latex). ![Mathematical equation in Microsoft Word document](WorkingwithMathematicalEquation_images/Mathematical Equation.png) -## Types of equation +## Types of Equations -The following different structures of equation can be created by using the Essential® DocIO. +The following different structures of equations can be created using the Essential® DocIO: -![Different structures of equation in Microsoft Word application](WorkingwithMathematicalEquation_images/EquationStructures.png) +![Different structures of equations in Microsoft Word application](WorkingwithMathematicalEquation_images/EquationStructures.png) * Accent * Bar @@ -46,30 +46,30 @@ You can add an accent mark to the equation. The following code example shows how {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds an accent equation +// Adds an accent equation IOfficeMathAccent mathAccent = (IOfficeMathAccent) officeMath.getFunctions().add(MathFunctionType.Accent); -//Sets the accent character +// Sets the accent character mathAccent.setAccentCharacter("̆"); -//Adds the run element for accent +// Adds the run element for accent IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathAccent.getEquation().getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -WTextRange textRange =(WTextRange) officeMathRunElement.getItem(); -//Sets text for accent equation +WTextRange textRange = (WTextRange) officeMathRunElement.getItem(); +// Sets text for accent equation textRange.setText("a"); -//Applies character formatting for text range +// Applies character formatting for text range textRange.getCharacterFormat().setBold(true); textRange.getCharacterFormat().setItalic(true); -//Saves the Word document +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -77,30 +77,30 @@ document.close(); ### Bar -You can add a bar (which adds horizontal line on top or bottom) to the equation. The following code example shows how to add a bar to the equation. +You can add a bar (which adds a horizontal line on top or bottom) to the equation. The following code example shows how to add a bar to the equation. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Add a section and a paragraph in the empty document +// Adds a section and a paragraph in the empty document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a bar equation +// Adds a bar equation IOfficeMathBar mathBar = (IOfficeMathBar) officeMath.getFunctions().add(0, MathFunctionType.Bar); -//Sets the position of bar +// Sets the position of the bar mathBar.setBarTop(true); -//Adds the run element for bar +// Adds the run element for the bar IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathBar.getEquation().getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for bar equation -((WTextRange)officeMathRunElement.getItem()).setText("a"); -//Saves the Word document +// Sets text for bar equation +((WTextRange) officeMathRunElement.getItem()).setText("a"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -112,84 +112,85 @@ You can add a box to the equation. The following code example shows how to add a {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a box equation +// Adds a box equation IOfficeMathBox mathBox = (IOfficeMathBox) officeMath.getFunctions().add(0, MathFunctionType.Box); -//Adds the run element for box -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) officeMath.getFunctions().add(0, MathFunctionType.RunElement); +// Adds the run element for box +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) officeMath.getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for math -((WTextRange)officeMathRunElement.getItem()).setText("a+b"); -//Enables the flag, to behave the box and its contents as a single operator +// Sets text for math +((WTextRange) officeMathRunElement.getItem()).setText("a+b"); +// Enables the flag to behave the box and its contents as a single operator mathBox.setOperatorEmulator(true); -//Enables the flag, to act box as the mathematical differential +// Enables the flag to act box as the mathematical differential mathBox.setEnableDifferential(true); -//Adds a break in box equation +// Adds a break in the box equation mathBox.setBreak(officeMath.getBreaks().add(0)); -//Adds the run element for box -officeMathRunElement =(IOfficeMathRunElement) mathBox.getEquation().getFunctions().add(0, MathFunctionType.RunElement); -officeMathRunElement.setItem( new WTextRange(document)); -//Sets text for box equation -((WTextRange)officeMathRunElement.getItem()).setText( "=="); -//Adds the run element for box -officeMathRunElement =(IOfficeMathRunElement) mathBox.getEquation().getFunctions().add(1, MathFunctionType.RunElement); -officeMathRunElement.setItem( new WTextRange(document)); -//Sets text for box equation -((WTextRange)officeMathRunElement.getItem()).setText("adx"); -//Saves the Word document +// Adds the run element for box +officeMathRunElement = (IOfficeMathRunElement) mathBox.getEquation().getFunctions().add(0, MathFunctionType.RunElement); +officeMathRunElement.setItem(new WTextRange(document)); +// Sets text for box equation +((WTextRange) officeMathRunElement.getItem()).setText("=="); +// Adds the run element for box +officeMathRunElement = (IOfficeMathRunElement) mathBox.getEquation().getFunctions().add(1, MathFunctionType.RunElement); +officeMathRunElement.setItem(new WTextRange(document)); +// Sets text for box equation +((WTextRange) officeMathRunElement.getItem()).setText("adx"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} {% endtabs %} -### Border box +### Border Box + +You can add a box with borders on four sides and strikethroughs in horizontal, vertical, and diagonal directions to the equation. The following code example shows how to add a border box to the equation. -You can add a box with the borders on four sides and strikethrough on horizontal, vertical, and diagonal directions to the equation. The following code example shows how to add a border box to the equation. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a border box equation -IOfficeMathBorderBox mathBorderBox =(IOfficeMathBorderBox) officeMath.getFunctions().add(0, MathFunctionType.BorderBox); -//Sets the diagonal strikethrough from lower left to upper right +// Adds a border box equation +IOfficeMathBorderBox mathBorderBox = (IOfficeMathBorderBox) officeMath.getFunctions().add(0, MathFunctionType.BorderBox); +// Sets the diagonal strikethrough from lower left to upper right mathBorderBox.setStrikeDiagonalUp(true); -//Sets the diagonal strikethrough from upper left to lower right +// Sets the diagonal strikethrough from upper left to lower right mathBorderBox.setStrikeDiagonalDown(true); -//Sets the horizontal strikethrough +// Sets the horizontal strikethrough mathBorderBox.setStrikeHorizontal(true); -//Sets the vertical strikethrough +// Sets the vertical strikethrough mathBorderBox.setStrikeVertical(true); -//Enables the flag, to hide the bottom border of an equation +// Enables the flag to hide the bottom border of an equation mathBorderBox.setHideBottom(true); -//Enables the flag, to hide the left border of an equation +// Enables the flag to hide the left border of an equation mathBorderBox.setHideLeft(true); -//Sets false to show the right border of an equation +// Sets false to show the right border of an equation mathBorderBox.setHideRight(false); -//Sets false to show the top border of an equation +// Sets false to show the top border of an equation mathBorderBox.setHideTop(false); -//Adds the run element for border box +// Adds the run element for border box IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathBorderBox.getEquation().getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for border box equation -((WTextRange)officeMathRunElement.getItem()).setText("a+b-c"); -//Saves the Word document +// Sets text for border box equation +((WTextRange) officeMathRunElement.getItem()).setText("a+b-c"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -198,76 +199,78 @@ document.close(); ### Delimiter -You can add a delimiter (parenthesis, square brackets and other characters) to the equation. The following code example shows how to a add delimiter to the equation. +You can add a delimiter (parenthesis, square brackets, and other characters) to the equation. The following code example shows how to add a delimiter to the equation. + {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a delimiter equation -IOfficeMathDelimiter mathDelimiter =(IOfficeMathDelimiter) officeMath.getFunctions().add(0, MathFunctionType.Delimiter); -//Sets the begin character +// Adds a delimiter equation +IOfficeMathDelimiter mathDelimiter = (IOfficeMathDelimiter) officeMath.getFunctions().add(0, MathFunctionType.Delimiter); +// Sets the begin character mathDelimiter.setBeginCharacter("["); -//Sets the end character +// Sets the end character mathDelimiter.setEndCharacter("]"); -//Enables the flag, to grow delimiter characters to full height of the arguments +// Enables the flag to grow delimiter characters to full height of the arguments mathDelimiter.setIsGrow(true); -//Sets the appearance of delimiters +// Sets the appearance of delimiters mathDelimiter.setDelimiterShape(MathDelimiterShapeType.Match); -//Adds the run element for delimiter -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) mathDelimiter.getEquation().add(0).getFunctions().add(0, MathFunctionType.RunElement); +// Adds the run element for delimiter +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathDelimiter.getEquation().add(0).getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for delimiter equation -((WTextRange)officeMathRunElement.getItem()).setText("a+b"); -//Saves the Word document +// Sets text for delimiter equation +((WTextRange) officeMathRunElement.getItem()).setText("a+b"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} {% endtabs %} -### Equation array +### Equation Array + +You can create a one-dimensional array of equations in Word documents. The following code example shows how to create an array of equations. -You can create a one dimensional array of equations in Word document. The following code example shows how to create an array of equations. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds an equation array -IOfficeMathEquationArray mathEquationArray =(IOfficeMathEquationArray) officeMath.getFunctions().add(0, MathFunctionType.EquationArray); -//Sets the vertical alignment for equation array +// Adds an equation array +IOfficeMathEquationArray mathEquationArray = (IOfficeMathEquationArray) officeMath.getFunctions().add(0, MathFunctionType.EquationArray); +// Sets the vertical alignment for the equation array mathEquationArray.setVerticalAlignment(MathVerticalAlignment.Center); -//Enables the flag, to distribute the equation array equally within the container +// Enables the flag to distribute the equation array equally within the container mathEquationArray.setExpandEquationContainer(true); -//Enables the flag, to expand the equations in an equation array to the maximum width +// Enables the flag to expand the equations in an equation array to the maximum width mathEquationArray.setExpandEquationContainer(true); -//Sets the row spacing rule +// Sets the row spacing rule mathEquationArray.setRowSpacingRule(SpacingRule.Multiple); -//Adds the run element for equation array -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) mathEquationArray.getEquation().add(0).getFunctions().add(0, MathFunctionType.RunElement); +// Adds the run element for equation array +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathEquationArray.getEquation().add(0).getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for equation) array -((WTextRange)officeMathRunElement.getItem()).setText("x+y+z=0"); -//Adds the run element for equation array -officeMathRunElement =(IOfficeMathRunElement) mathEquationArray.getEquation().add(1).getFunctions().add(0, MathFunctionType.RunElement); +// Sets text for equation array +((WTextRange) officeMathRunElement.getItem()).setText("x+y+z=0"); +// Adds the run element for equation array +officeMathRunElement = (IOfficeMathRunElement) mathEquationArray.getEquation().add(1).getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for equation array -((WTextRange)officeMathRunElement.getItem()).setText("x+y-z=1"); -//Saves the Word document +// Sets text for equation array +((WTextRange) officeMathRunElement.getItem()).setText("x+y-z=1"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -275,32 +278,33 @@ document.close(); ### Fraction -You can create a fraction equation with a numerator and denominator in Word document. The following code example shows how to create a fraction equation. +You can create a fraction equation with a numerator and denominator in Word documents. The following code example shows how to create a fraction equation. + {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a fraction getEquation() -IOfficeMathFraction mathFraction =(IOfficeMathFraction) officeMath.getFunctions().add(0, MathFunctionType.Fraction); -//Sets the denominator for fraction -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) mathFraction.getNumerator().getFunctions().add(0, MathFunctionType.RunElement); +// Adds a fraction equation +IOfficeMathFraction mathFraction = (IOfficeMathFraction) officeMath.getFunctions().add(0, MathFunctionType.Fraction); +// Sets the denominator for the fraction +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathFraction.getNumerator().getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("a"); -//Sets the Numerator for fraction -officeMathRunElement =(IOfficeMathRunElement) mathFraction.getDenominator().getFunctions().add(0, MathFunctionType.RunElement); +((WTextRange) officeMathRunElement.getItem()).setText("a"); +// Sets the numerator for the fraction +officeMathRunElement = (IOfficeMathRunElement) mathFraction.getDenominator().getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("b"); -//Sets the fraction type +((WTextRange) officeMathRunElement.getItem()).setText("b"); +// Sets the fraction type mathFraction.setFractionType(MathFractionType.NormalFractionBar); -//Saves the Word document +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -308,65 +312,66 @@ document.close(); ### Function -You can create trigonometric functions in a Word document. The following code example shows how to create a function. +You can create trigonometric functions in a Word document. The following code example shows how to create a function. + {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a function -IOfficeMathFunction mathFunction =(IOfficeMathFunction) officeMath.getFunctions().add(0, MathFunctionType.Function); -//Sets the function name -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) mathFunction.getFunctionName().getFunctions().add(0, MathFunctionType.RunElement); +// Adds a function +IOfficeMathFunction mathFunction = (IOfficeMathFunction) officeMath.getFunctions().add(0, MathFunctionType.Function); +// Sets the function name +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) mathFunction.getFunctionName().getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("sin"); -//Adds the run element for function -officeMathRunElement =(IOfficeMathRunElement) mathFunction.getEquation().getFunctions().add(0, MathFunctionType.RunElement); +((WTextRange) officeMathRunElement.getItem()).setText("sin"); +// Adds the run element for function +officeMathRunElement = (IOfficeMathRunElement) mathFunction.getEquation().getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for function -((WTextRange)officeMathRunElement.getItem()).setText("90"); -//Saves the Word document +// Sets text for function +((WTextRange) officeMathRunElement.getItem()).setText("90"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} {% endtabs %} -### Group character +### Group Character -You can group mathematical equations by adding a grouping character at above or below to the corresponding equations. The following code example shows how to create an equation with grouping character. +You can group mathematical equations by adding a grouping character above or below the corresponding equations. The following code example shows how to create an equation with a grouping character. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath math = document.getLastParagraph().appendMath(); -//Adds a new math +// Adds a new math IOfficeMath officeMath = math.getMathParagraph().getMaths().add(); -//Adds a group character equation -IOfficeMathGroupCharacter officeMathGroupCharacter =(IOfficeMathGroupCharacter) officeMath.getFunctions().add(0, MathFunctionType.GroupCharacter); -//Sets the group character +// Adds a group character equation +IOfficeMathGroupCharacter officeMathGroupCharacter = (IOfficeMathGroupCharacter) officeMath.getFunctions().add(0, MathFunctionType.GroupCharacter); +// Sets the group character officeMathGroupCharacter.setGroupCharacter("⏞"); -//Enables the flag to align group character at top +// Enables the flag to align group character at the top officeMathGroupCharacter.setHasAlignTop(true); -//Enables the flag to align the text and group character +// Enables the flag to align the text and group character officeMathGroupCharacter.setHasCharacterTop(true); -//Adds the run element for group character -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) officeMathGroupCharacter.getEquation().getFunctions().add(0, MathFunctionType.RunElement); +// Adds the run element for group character +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) officeMathGroupCharacter.getEquation().getFunctions().add(0, MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for group character equation -((WTextRange)officeMathRunElement.getItem()).setText("a-b"); -//Saves the Word document +// Sets text for group character equation +((WTextRange) officeMathRunElement.getItem()).setText("a-b"); +// Saves the Word document document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -374,38 +379,38 @@ document.close(); ### Limit -You can add upper limit or lower limit to the mathematical equation. The following code example shows how to create limit equation. +You can add an upper limit or lower limit to the mathematical equation. The following code example shows how to create a limit equation. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath wMath = document.getLastParagraph().appendMath(); IOfficeMath officeMath = wMath.getMathParagraph().getMaths().add(); -//Adds function to the math -IOfficeMathFunction officeMathFunction =(IOfficeMathFunction) officeMath.getFunctions().add(0, MathFunctionType.Function); -//Adds a mathematical limit equation -IOfficeMathLimit officeMathLimit =(IOfficeMathLimit) officeMathFunction.getFunctionName().getFunctions().add(0, MathFunctionType.Limit); -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) officeMathLimit.getEquation().getFunctions().add(MathFunctionType.RunElement); -officeMathRunElement.setItem( new WTextRange(document)); -//Sets text for limit equation. -((WTextRange)officeMathRunElement.getItem()).setText("lim"); -//Sets the type of the limit. +// Adds function to the math +IOfficeMathFunction officeMathFunction = (IOfficeMathFunction) officeMath.getFunctions().add(0, MathFunctionType.Function); +// Adds a mathematical limit equation +IOfficeMathLimit officeMathLimit = (IOfficeMathLimit) officeMathFunction.getFunctionName().getFunctions().add(0, MathFunctionType.Limit); +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) officeMathLimit.getEquation().getFunctions().add(MathFunctionType.RunElement); +officeMathRunElement.setItem(new WTextRange(document)); +// Sets text for limit equation +((WTextRange) officeMathRunElement.getItem()).setText("lim"); +// Sets the type of the limit officeMathLimit.setLimitType(MathLimitType.LowerLimit); -IOfficeMathRunElement officeMathRunElement_limit =(IOfficeMathRunElement) officeMathLimit.getLimit().getFunctions().add(MathFunctionType.RunElement); +IOfficeMathRunElement officeMathRunElement_limit = (IOfficeMathRunElement) officeMathLimit.getLimit().getFunctions().add(MathFunctionType.RunElement); officeMathRunElement_limit.setItem(new WTextRange(document)); -//Sets the Limit value. -((WTextRange)officeMathRunElement_limit.getItem()).setText("n=0"); -officeMathLimit.setLimitType( MathLimitType.LowerLimit); -officeMathRunElement =(IOfficeMathRunElement) officeMathFunction.getEquation().getFunctions().add(MathFunctionType.RunElement); -officeMathRunElement.setItem( new WTextRange(document)); -//Sets text for base of the specified equation -((WTextRange)officeMathRunElement.getItem()).setText("x"); -//Saves the Word document +// Sets the limit value +((WTextRange) officeMathRunElement_limit.getItem()).setText("n=0"); +officeMathLimit.setLimitType(MathLimitType.LowerLimit); +officeMathRunElement = (IOfficeMathRunElement) officeMathFunction.getEquation().getFunctions().add(MathFunctionType.RunElement); +officeMathRunElement.setItem(new WTextRange(document)); +// Sets text for base of the specified equation +((WTextRange) officeMathRunElement.getItem()).setText("x"); +// Saves the Word document document.save("Sample.docx"); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -413,74 +418,74 @@ document.close(); ### Matrix -You can create a matrix equation in a Word document. The following code example shows how to create a matrix equation. +You can create a matrix equation in a Word document. The following code example shows how to create a matrix equation. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath wmath = document.getLastParagraph().appendMath(); IOfficeMath officeMath = wmath.getMathParagraph().getMaths().add(); -//Adds matrix getEquation() +// Adds matrix equation IOfficeMathMatrix mathMatrix = (IOfficeMathMatrix) officeMath.getFunctions().add(MathFunctionType.Matrix); -//Sets vertical alignment for matrix +// Sets vertical alignment for matrix mathMatrix.setVerticalAlignment(MathVerticalAlignment.Center); -//Sets width for matrix columns +// Sets width for matrix columns mathMatrix.setColumnWidth(1); -//Sets column spacing rule +// Sets column spacing rule mathMatrix.setColumnSpacingRule(SpacingRule.OneAndHalf); -//Sets column spacing value +// Sets column spacing value mathMatrix.setColumnSpacing(3); -//Enables the flag to hide place holders +// Enables the flag to hide placeholders mathMatrix.setHidePlaceHolders(true); -//Sets row spacing rule. +// Sets row spacing rule mathMatrix.setRowSpacingRule(SpacingRule.Double); -//Sets row spacing value. +// Sets row spacing value mathMatrix.setRowSpacing(2); -//Adds a new column +// Adds a new column mathMatrix.getColumns().add(); -//Adds a new row +// Adds a new row mathMatrix.getRows().add(); -//Sets horizontal alignment for column +// Sets horizontal alignment for column mathMatrix.getColumns().get(0).setHorizontalAlignment(MathHorizontalAlignment.Left); -//Gets an argument in first cell in first row +// Gets an argument in the first cell in the first row officeMath = mathMatrix.getRows().get(0).getArguments().get(0); -//Sets text for argument in first cell in first row +// Sets text for argument in the first cell in the first row IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) officeMath.getFunctions().add(MathFunctionType.RunElement); -officeMathRunElement.setItem( new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("1"); +officeMathRunElement.setItem(new WTextRange(document)); +((WTextRange) officeMathRunElement.getItem()).setText("1"); -//Adds a new column +// Adds a new column mathMatrix.getColumns().add(); -//Adds a new row +// Adds a new row mathMatrix.getRows().add(); -//Gets an argument in second cell in first row +// Gets an argument in the second cell in the first row officeMath = mathMatrix.getRows().get(0).getArguments().get(1); -//Sets text for argument in second cell in first row +// Sets text for argument in the second cell in the first row officeMathRunElement = (IOfficeMathRunElement) officeMath.getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("2"); +((WTextRange) officeMathRunElement.getItem()).setText("2"); -//Gets an argument in first cell in second row +// Gets an argument in the first cell in the second row officeMath = mathMatrix.getRows().get(1).getArguments().get(0); -//Sets text for argument in first cell in second row +// Sets text for argument in the first cell in the second row officeMathRunElement = (IOfficeMathRunElement) officeMath.getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("3"); +((WTextRange) officeMathRunElement.getItem()).setText("3"); -//Gets an argument in second cell in second row +// Gets an argument in the second cell in the second row officeMath = mathMatrix.getRows().get(1).getArguments().get(1); -//Sets text for argument in second cell in second row +// Sets text for argument in the second cell in the second row officeMathRunElement = (IOfficeMathRunElement) officeMath.getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("4"); -//Saves the Word document. +((WTextRange) officeMathRunElement.getItem()).setText("4"); +// Saves the Word document document.save("Sample.docx"); -//Closes the document +// Closes the document document.close(); {% endhighlight %} @@ -488,42 +493,42 @@ document.close(); ### N-Array -You can create an equation with common large operators such as summation, integrals, union, intersection, logical OR, logical AND, products and co-products. The following code example shows how to create a summation with limits. +You can create an equation with common large operators such as summation, integrals, union, intersection, logical OR, logical AND, products, and co-products. The following code example shows how to create a summation with limits. {% tabs %} {% highlight JAVA %} -//Creates a new Word document +// Creates a new Word document WordDocument document = new WordDocument(); -//Adds one section and one paragraph to the document +// Adds one section and one paragraph to the document document.ensureMinimal(); -//Appends a new mathematical equation to the paragraph +// Appends a new mathematical equation to the paragraph WMath wMath = document.getLastParagraph().appendMath(); IOfficeMath officeMath = wMath.getMathParagraph().getMaths().add(); -//Adds a N-Array equation +// Adds an N-Array equation IOfficeMathNArray officeMathNArray = (IOfficeMathNArray) officeMath.getFunctions().add(0, MathFunctionType.NArray); -//Sets N-Array character. +// Sets N-Array character officeMathNArray.setNArrayCharacter("∑"); -//Enables the flag, to grow N-array character to full height of the arguments +// Enables the flag to grow N-Array character to the full height of the arguments officeMathNArray.setHasGrow(false); -//Enables the flag to hide lower limit +// Enables the flag to hide lower limit officeMathNArray.setHideLowerLimit(false); -//Enables the flag to hide upper limit +// Enables the flag to hide upper limit officeMathNArray.setHideUpperLimit(false); -//Sets false to set limit position on above the summation +// Sets false to set limit position above the summation officeMathNArray.setSubSuperscriptLimit(false); -IOfficeMathRunElement officeMathRunElement =(IOfficeMathRunElement) officeMathNArray.getSubscript().getFunctions().add(MathFunctionType.RunElement); +IOfficeMathRunElement officeMathRunElement = (IOfficeMathRunElement) officeMathNArray.getSubscript().getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for superscript property of NArray equation -((WTextRange)officeMathRunElement.getItem()).setText("n=1"); -officeMathRunElement =(IOfficeMathRunElement) officeMathNArray.getSuperscript().getFunctions().add(MathFunctionType.RunElement); +// Sets text for superscript property of N-Array equation +((WTextRange) officeMathRunElement.getItem()).setText("n=1"); +officeMathRunElement = (IOfficeMathRunElement) officeMathNArray.getSuperscript().getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -((WTextRange)officeMathRunElement.getItem()).setText("10"); -officeMathRunElement =(IOfficeMathRunElement) officeMathNArray.getEquation().getFunctions().add(MathFunctionType.RunElement); +((WTextRange) officeMathRunElement.getItem()).setText("10"); +officeMathRunElement = (IOfficeMathRunElement) officeMathNArray.getEquation().getFunctions().add(MathFunctionType.RunElement); officeMathRunElement.setItem(new WTextRange(document)); -//Sets text for NArray equation -((WTextRange)officeMathRunElement.getItem()).setText("x"); -//Saves the Word document. +// Sets text for N-Array equation +((WTextRange) officeMathRunElement.getItem()).setText("x"); +// Saves the Word document document.save("Sample.docx"); -//Closes the document +// Closes the document document.close(); {% endhighlight %} diff --git a/java-file-formats/word-library/working-with-paragraph.md b/java-file-formats/word-library/working-with-paragraph.md index e15b1ea..11b778f 100644 --- a/java-file-formats/word-library/working-with-paragraph.md +++ b/java-file-formats/word-library/working-with-paragraph.md @@ -1,25 +1,25 @@ --- title: Working with Paragraph | Syncfusion -description: This section explains how to work with the child elements of Paragraph in Word document using Syncfusion Java Word library (Essential DocIO) +description: This section explains how to work with the child elements of Paragraph in a Word document using Syncfusion Java Word library (Essential DocIO) platform: java-file-formats control: Word Library documentation: UG --- # Working with Paragraph -Paragraph is the basic element in a Word document that contains a textual and graphical contents. Each paragraph has its own formatting such as line spacing, alignment, indentation, and more. Within a paragraph, the contents are represented by one or more child elements such as `WTextRange`, `WPicture`, and `Hyperlink` and more. The `ParagraphItem` is the base class for the child elements of paragraph. The following elements can be the child elements of a paragraph. +A paragraph is the basic element in a Word document that contains textual and graphical content. Each paragraph has its own formatting, such as line spacing, alignment, indentation, and more. Within a paragraph, the contents are represented by one or more child elements, such as `WTextRange`, `WPicture`, `Hyperlink`, and more. The `ParagraphItem` is the base class for the child elements of a paragraph. The following elements can be child elements of a paragraph: * Text: Represented by an instance of `WTextRange`. -* Image: Represented by an instance of `WPicture`. +* Image: Represented by an instance of `WPicture`. * Comments: Represented by an instance of `WComment`. -* Hyperlink: Represented by an instance of `Hyperlink`. -* Symbols: Represented by an instance of `WSymbol`. -* Breaks: Represented by an instance of `Break`. -* Shapes: Represented by an instance of `Shape`. -* TextBox: Represented by an instance of `WTextBox`. +* Hyperlink: Represented by an instance of `Hyperlink`. +* Symbols: Represented by an instance of `WSymbol`. +* Breaks: Represented by an instance of `Break`. +* Shapes: Represented by an instance of `Shape`. +* TextBox: Represented by an instance of `WTextBox`. * Fields: Represented by an instance of `WField`. * Form Fields: Represented by an instance of `WFormField`. -* Bookmarks: Represented by instances of `BookmarkStart` and `BookmarkEnd`. +* Bookmarks: Represented by instances of `BookmarkStart` and `BookmarkEnd`. * Absolute Tab: Represented by an instance of `WAbsoluteTab`. The following code example explains how to add a new paragraph. @@ -27,17 +27,17 @@ The following code example explains how to add a new paragraph. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Add a new text to the paragraph. +// Add new text to the paragraph. paragraph.appendText("Adding new paragraph to the document"); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} @@ -48,27 +48,27 @@ The following code example shows how to modify an existing paragraph. {% tabs %} {% highlight JAVA %} -//Load the template document. +// Load the template document. WordDocument document = new WordDocument("Template.docx"); -//Get the text body of the first section. +// Get the text body of the first section. WTextBody textBody = document.getSections().get(0).getBody(); -//Get the paragraph at index 1. +// Get the paragraph at index 1. WParagraph paragraph = textBody.getParagraphs().get(1); -//Iterate through the child elements of the paragraph. -for(Object item_tempObj : paragraph.getChildEntities()) -{ - ParagraphItem item = (ParagraphItem)item_tempObj; - if(item instanceof WTextRange) - { - WTextRange text = (WTextRange)(item); - //Modify the character format of the text. - text.getCharacterFormat().setBold(true); - break; - } +// Iterate through the child elements of the paragraph. +for (Object item_tempObj : paragraph.getChildEntities()) { + + ParagraphItem item = (ParagraphItem) item_tempObj; + if (item instanceof WTextRange) { + + WTextRange text = (WTextRange) (item); + // Modify the character format of the text. + text.getCharacterFormat().setBold(true); + break; + } } -//Save the Word document. -document.save("Sample.docx",FormatType.Docx); -//Close the document. +// Save the Word document. +document.save("Sample.docx", FormatType.Docx); +// Close the document. document.close(); {% endhighlight %} @@ -76,29 +76,31 @@ document.close(); ## Applying paragraph formatting -As in the Microsoft Word, the DocIO provides support for all the paragraph formatting options such as line spacing, indentation, spacing before and after, keep follow, and more. The following code example explains how to apply the formatting to a paragraph. +As in Microsoft Word, DocIO provides support for all the paragraph formatting options, such as line spacing, indentation, spacing before and after, keep follow, and more. The following code example explains how to apply formatting to a paragraph. -N>The `FirstLineIndent` can be used to update or retrieve both hanging and first line indents. Negative value for this property denotes the hanging indent and positive value denotes the first line indent of the paragraph. +N> The `FirstLineIndent` can be used to update or retrieve both hanging and first-line indents. A negative value for this property denotes the hanging indent, and a positive value denotes the first-line indent of the paragraph. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Add a new text to the paragraph. -IWTextRange firstText = paragraph.appendText("Paragraphs are the basic elements of the Word document. It can contain text and images."); -//Apply the paragraph formatting. +// Add new text to the paragraph. +IWTextRange firstText = paragraph.appendText("Paragraphs are the basic elements of the Word document. They can contain text and images."); +// Apply paragraph formatting. paragraph.getParagraphFormat().setAfterSpacing(18f); -paragraph.getParagraphFormat().setBeforeSpacing(18f);paragraph.getParagraphFormat().setBackColor(ColorSupport.getLightGray()); +paragraph.getParagraphFormat().setBeforeSpacing(18f); +paragraph.getParagraphFormat().setBackColor(ColorSupport.getLightGray()); paragraph.getParagraphFormat().setFirstLineIndent(10f); -paragraph.getParagraphFormat().setLineSpacing(10f);paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Right); -//Save the Word document. +paragraph.getParagraphFormat().setLineSpacing(10f); +paragraph.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Right); +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} @@ -106,28 +108,28 @@ document.close(); ### Paragraph style -The paragraph style contains a definition for both font (text) and paragraph formatting that can be applied to the contents of an entire paragraph. DocIO supports various pre-defined styles and also provides the ability to create custom paragraph styles. +The paragraph style contains a definition for both font (text) and paragraph formatting that can be applied to the contents of an entire paragraph. DocIO supports various predefined styles and also provides the ability to create custom paragraph styles. -T> You can define a custom style or modify any built-in style to the required formatting, and apply this style to the part of Word document to be formatted. You can reduce the file size and code length by using styles instead of formatting each element explicitly. +T> You can define a custom style or modify any built-in style to the required formatting and apply this style to the part of the Word document to be formatted. You can reduce the file size and code length by using styles instead of formatting each element explicitly. The following code example explains how to use the predefined styles. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph firstParagraph = section.addParagraph(); -//Add a new text to the paragraph. +// Add new text to the paragraph. IWTextRange firstText = firstParagraph.appendText("Built-in styles can be applied to the paragraph. Heading1 style is applied to this paragraph."); -//Apply the built-in style for the paragraph. +// Apply the built-in style to the paragraph. firstParagraph.applyStyle(BuiltinStyle.Heading1); -//Save the word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} @@ -140,11 +142,11 @@ The following code example explains how to create a custom paragraph style and a {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Create an user defined style. +// Create a user-defined style. IWParagraphStyle style = document.addParagraphStyle("User_defined_style"); style.getParagraphFormat().setBackColor(ColorSupport.getLightGray()); style.getParagraphFormat().setAfterSpacing(18f); @@ -154,14 +156,14 @@ style.getParagraphFormat().getBorders().setLineWidth(0.5f); style.getParagraphFormat().setLineSpacing(15f); style.getCharacterFormat().setFontName("Calibri"); style.getCharacterFormat().setItalic(true); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); IWTextRange text = paragraph.appendText("A new paragraph style is created and is applied to this paragraph."); -//Apply the new style to the paragraph. +// Apply the new style to the paragraph. paragraph.applyStyle("User_defined_style"); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} @@ -169,31 +171,31 @@ document.close(); ### Tab stop -A tab stop is a horizontal position that is set for aligning text of the paragraph. A tab character causes the carriage to go to the next tab stop. +A tab stop is a horizontal position that is set for aligning text in the paragraph. A tab character causes the carriage to go to the next tab stop. -Each paragraph has its own tab stop collection where the new tab stop can be added and existing tab stop can be removed. +Each paragraph has its own tab stop collection, where a new tab stop can be added and an existing tab stop can be removed. The following code example explains how to add tab stops to the paragraph. {% tabs %} {% highlight JAVA %} -//Creates a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Add a tab stop at position 11. -Tab firstTab = paragraph.getParagraphFormat().getTabs().addTab(11, TabJustification.Left, TabLeader.Dotted); -//Add a tab stop at position 62. +// Add a tab stop at position 11. +Tab firstTab = paragraph.getParagraphFormat().getTabs().addTab(11, TabJustification.Left, TabLeader.Dotted); +// Add a tab stop at position 62. paragraph.getParagraphFormat().getTabs().addTab(62, TabJustification.Left, TabLeader.Single); paragraph.appendText("This sample\t illustrates the use of tabs in the paragraph. Tabs\t can be inserted or removed from the paragraph."); -//Remove the tab stop from the collection. +// Remove the tab stop from the collection. paragraph.getParagraphFormat().getTabs().removeByTabPosition(11); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} @@ -201,31 +203,31 @@ document.close(); ### RTL paragraph -You can set RTL (Right-to-left) direction to the paragraph in a Word document. The following code example shows how to set RTL (Right-to-left) for a paragraph in Word document. +You can set RTL (Right-to-left) direction to the paragraph in a Word document. The following code example shows how to set RTL (Right-to-left) for a paragraph in a Word document. {% tabs %} {% highlight JAVA %} -//Load the template document. +// Load the template document. WordDocument document = new WordDocument("Template.docx"); -//Get the text body of the first section. +// Get the text body of the first section. WTextBody textBody = document.getSections().get(0).getBody(); -//Get the paragraph at index 1. +// Get the paragraph at index 1. WParagraph paragraph = textBody.getParagraphs().get(1); -//Get a value indicating whether the paragraph is right-to-left. True indicates the paragraph direction is RTL. +// Get a value indicating whether the paragraph is right-to-left. True indicates the paragraph direction is RTL. boolean isRTL = paragraph.getParagraphFormat().getBidi(); -//Set the RTL direction for a paragraph. -if(!isRTL) - paragraph.getParagraphFormat().setBidi(true); -//Save the Word document. +// Set the RTL direction for a paragraph. +if (!isRTL) + paragraph.getParagraphFormat().setBidi(true); +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Closes the document +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -## Working with text +## Working with text Text within a paragraph is represented by one or more instances of the `WTextRange`. Each `WTextRange` instance can have its own font (text) formatting. @@ -234,49 +236,49 @@ The following code example explains how to append text to the paragraph. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph to the section. +// Add a new paragraph to the section. IWParagraph firstParagraph = section.addParagraph(); -//Add a new text to the paragraph. +// Add new text to the paragraph. IWTextRange firstText = firstParagraph.appendText("A new text is added to the paragraph."); firstText.getCharacterFormat().setFontSize(14); firstText.getCharacterFormat().setBold(true); firstText.getCharacterFormat().setTextColor(ColorSupport.getGreen()); -//Save the Word document. +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -Text in the paragraph can be modified or replaced with a new text. This can be achieved by iterating through the paragraph items. +Text in the paragraph can be modified or replaced with new text. This can be achieved by iterating through the paragraph items. The following code example explains how to replace the text of a text range. {% tabs %} {% highlight JAVA %} -//Load the template document. +// Load the template document. WordDocument document = new WordDocument("Template.docx"); -//Get the last paragraph. +// Get the last paragraph. WParagraph lastParagraph = document.getLastParagraph(); -//Iterate through the paragraph items to get the text range and modifies its content. -for(int i = 0;i DocIO supports editable ranges in DOCX format documents only. @@ -133,7 +133,7 @@ document.close(); {% endtabs %} -### Retrieve Id of an editable range +### Retrieve the ID of an editable range You can retrieve the ID of an editable range using the **getId()** method of the **EditableRange** class. @@ -148,7 +148,7 @@ WordDocument document = new WordDocument(); document.ensureMinimal(); // Access the last paragraph WParagraph paragraph = document.getLastParagraph(); -// Append text before editable range +// Append text before the editable range paragraph.appendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks "); // Append editable range start EditableRangeStart editableRangeStart = paragraph.appendEditableRangeStart(); @@ -214,7 +214,7 @@ document.close(); An editable range at a specific index can also be removed from the **EditableRangeCollection** using the **removeAt()** method. -The following code example demonstrates how to remove an editable range at particular index from a Word document. +The following code example demonstrates how to remove an editable range at a particular index from a Word document. {% tabs %} @@ -290,7 +290,7 @@ paragraph.appendText("Adventure Works Cycles, the fictitious company on which th // Add an editable range start EditableRangeStart editableRangeStart = paragraph.appendEditableRangeStart(); // Set the single user allowed to edit this range -editableRangeStart.setSingleUser("\"user@domain.com\""); +editableRangeStart.setSingleUser("user@domain.com"); // Append text inside the editable range paragraph.appendText("sample databases are based, is a large, multinational manufacturing company."); // Add the editable range end @@ -305,7 +305,7 @@ document.close(); {% endtabs %} -### Add editable range in a table +### Add an editable range in a table Using the **setFirstColumn()** and **setLastColumn()** methods of the **EditableRangeStart** class, you can specify the starting and ending columns of an editable range within a table. @@ -326,7 +326,7 @@ EditableRangeStart editableRangeStart = new EditableRangeStart(document); paragraph.getChildEntities().insert(0, editableRangeStart); // Set the editor group to allow everyone to edit editableRangeStart.setEditorGroup(EditorType.Everyone); -// Apply editable range to the second column only (index 1) +// Apply the editable range to the second column only (index 1) editableRangeStart.setFirstColumn((short) 0); editableRangeStart.setLastColumn((short) 1); // Access another paragraph in the 6th row, 3rd column (index 5,2) diff --git a/java-file-formats/word-library/working-with-shapes.md b/java-file-formats/word-library/working-with-shapes.md index 038e080..579109a 100644 --- a/java-file-formats/word-library/working-with-shapes.md +++ b/java-file-formats/word-library/working-with-shapes.md @@ -1,337 +1,338 @@ --- title: Working with Shapes | Syncfusion -description: This section describes how to work with the shapes and groupshape in Word document using Syncfusion Java Word library (Essential DocIO) +description: This section describes how to work with the shapes and group shapes in a Word document using the Syncfusion Java Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG keywords: --- -# Working with Shapes in Word document +# Working with Shapes in a Word Document -Shapes are drawing objects that include lines, curves, circles, rectangles, etc. It can be preset or custom geometry. You can create and manipulate the pre-defined shape in DOCX and WordML format documents. +Shapes are drawing objects that include lines, curves, circles, rectangles, etc. They can be preset or custom geometry. You can create and manipulate predefined shapes in DOCX and WordML format documents. -## Adding shapes +## Adding Shapes -The following code example shows how to add pre-defined shape to the document. +The following code example shows how to add a predefined shape to the document. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section. -WParagraph paragraph =(WParagraph) section.addParagraph(); -//Add new shape to the document. +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); +// Add a new shape to the document. Shape rectangle = paragraph.appendShape(AutoShapeType.RoundedRectangle, 150, 100); -//Set position for shape. +// Set position for the shape. rectangle.setVerticalPosition(72); rectangle.setHorizontalPosition(72); paragraph = (WParagraph) section.addParagraph(); -//Add textbody contents to the shape. +// Add text body contents to the shape. paragraph = (WParagraph) rectangle.getTextBody().addParagraph(); -IWTextRange text = paragraph.appendText("This text is in rounded rectangle shape"); +IWTextRange text = paragraph.appendText("This text is in a rounded rectangle shape"); text.getCharacterFormat().setTextColor(ColorSupport.getGreen()); text.getCharacterFormat().setBold(true); -//Add another shape to the document. +// Add another shape to the document. paragraph = (WParagraph) section.addParagraph(); paragraph.appendBreak(BreakType.LineBreak); Shape pentagon = paragraph.appendShape(AutoShapeType.Pentagon, 100, 100); paragraph = (WParagraph) pentagon.getTextBody().addParagraph(); -paragraph.appendText("This text is in pentagon shape"); -//Set position for shape. +paragraph.appendText("This text is in a pentagon shape"); +// Set position for the shape. pentagon.setHorizontalPosition(72); pentagon.setVerticalPosition(200); -//Save and close the Word document instance. +// Save and close the Word document instance. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -### Format shapes +### Format Shapes -Shape can have formatting such as line color, fill color, positioning, wrap formats, etc. The following code example illustrates how to apply formatting options for shape. +Shapes can have formatting such as line color, fill color, positioning, wrap formats, etc. The following code example illustrates how to apply formatting options for a shape. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section. -IWParagraph paragraph = (WParagraph)section.addParagraph(); -//Append shape to the paragraph. +// Add a new paragraph to the section. +IWParagraph paragraph = (WParagraph) section.addParagraph(); +// Append a shape to the paragraph. Shape rectangle = paragraph.appendShape(AutoShapeType.RoundedRectangle, 150, 100); rectangle.setVerticalPosition(72); rectangle.setHorizontalPosition(72); -paragraph = (WParagraph)section.addParagraph(); -paragraph = (WParagraph)rectangle.getTextBody().addParagraph(); -IWTextRange text = paragraph.appendText("This text is in rounded rectangle shape"); -//Apply format to the text. +paragraph = (WParagraph) section.addParagraph(); +paragraph = (WParagraph) rectangle.getTextBody().addParagraph(); +IWTextRange text = paragraph.appendText("This text is in a rounded rectangle shape"); +// Apply format to the text. text.getCharacterFormat().setTextColor(ColorSupport.getGreen()); text.getCharacterFormat().setBold(true); -//Apply fill color for shape. +// Apply fill color for the shape. rectangle.getFillFormat().setFill(true); rectangle.getFillFormat().setColor(ColorSupport.getLightGray()); -//Apply wrap formats. +// Apply wrap formats. rectangle.getWrapFormat().setTextWrappingStyle(TextWrappingStyle.Square); rectangle.getWrapFormat().setTextWrappingType(TextWrappingType.Right); -//Set horizontal and vertical origin. +// Set horizontal and vertical origin. rectangle.setHorizontalOrigin(HorizontalOrigin.Margin); rectangle.setVerticalOrigin(VerticalOrigin.Page); -//Set line format. +// Set line format. rectangle.getLineFormat().setDashStyle(LineDashing.Dot); rectangle.getLineFormat().setColor(ColorSupport.getDarkGray()); -//Save and close the Word document instance. +// Save and close the Word document instance. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -### Rotate shapes +### Rotate Shapes -You can rotate the shape and also apply flipping (horizontal and vertical) to it. The following code example explains how to rotate and flip the shape. +You can rotate a shape and also apply flipping (horizontal and vertical) to it. The following code example explains how to rotate and flip a shape. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section. -WParagraph paragraph = (WParagraph)section.addParagraph(); +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); Shape rectangle = paragraph.appendShape(AutoShapeType.RoundedRectangle, 150, 100); -//Set position for shape. +// Set position for the shape. rectangle.setVerticalPosition(72); rectangle.setHorizontalPosition(72); -//Set 90 degree rotation. +// Set 90-degree rotation. rectangle.setRotation(90); -//Set horizontal flip. +// Set horizontal flip. rectangle.setFlipHorizontal(true); -paragraph = (WParagraph)section.addParagraph(); -paragraph = (WParagraph)rectangle.getTextBody().addParagraph(); -IWTextRange text = paragraph.appendText("This text is in rounded rectangle shape"); -//Save the Word document. +paragraph = (WParagraph) section.addParagraph(); +paragraph = (WParagraph) rectangle.getTextBody().addParagraph(); +IWTextRange text = paragraph.appendText("This text is in a rounded rectangle shape"); +// Save the Word document. document.save("Result.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -## Grouping shapes +## Grouping Shapes -Word library now allows you to create or group multiple shapes, pictures, text boxes as a group shape in Word document (DOCX) and preserve it as in DOCX and WordML format conversions. +The Word library now allows you to create or group multiple shapes, pictures, and text boxes as a group shape in a Word document (DOCX) and preserve it during DOCX and WordML format conversions. -You can create a document with group shapes by using Microsoft Word. It provides an option to group a set of shapes and images as a single shape and a group shape as individual item. -![Create Group shape in Microsoft Word](Working-with-Shapes_images/Working-with-Shapes_img1.jpeg) +You can create a document with group shapes by using Microsoft Word. It provides an option to group a set of shapes and images as a single shape or treat a group shape as an individual item. +![Create Group Shape in Microsoft Word](Working-with-Shapes_images/Working-with-Shapes_img1.jpeg) **Key Features:** -1. You can easily manage group of shapes, pictures, text boxes as a group shape. +1. You can easily manage a group of shapes, pictures, and text boxes as a group shape. 2. You can move several shapes or images simultaneously and apply the same formatting properties for children of group shapes. N> 1. While grouping the shapes or other objects, the shapes should be positioned relative to the “Page”. N> 2. While grouping the shapes or other objects, the wrapping style should not be "In Line with Text". -The following code example shows how to create group shape in Word document. +The following code example shows how to create a group shape in a Word document. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section. -WParagraph paragraph = (WParagraph)section.addParagraph(); -//Create new group shape. +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); +// Create a new group shape. GroupShape groupShape = new GroupShape(document); -//Add group shape to the paragraph. +// Add the group shape to the paragraph. paragraph.getChildEntities().add(groupShape); -//Create new shape. +// Create a new shape. Shape shape = new Shape(document, AutoShapeType.RoundedRectangle); -//Set height and width for shape. +// Set height and width for the shape. shape.setHeight(100); shape.setWidth(150); -//Set horizontal and vertical position. +// Set horizontal and vertical position. shape.setHorizontalPosition(72); shape.setVerticalPosition(72); -//Set wrapping style for shape. +// Set wrapping style for the shape. shape.getWrapFormat().setTextWrappingStyle(TextWrappingStyle.InFrontOfText); -//Set horizontal and vertical origin. +// Set horizontal and vertical origin. shape.setHorizontalOrigin(HorizontalOrigin.Page); shape.setVerticalOrigin(VerticalOrigin.Page); -//Add the specified shape to group shape. +// Add the specified shape to the group shape. groupShape.add(shape); -//Create new picture. +// Create a new picture. WPicture picture = new WPicture(document); FileStreamSupport imageStream = new FileStreamSupport("Image.png", FileMode.Open, FileAccess.ReadWrite); picture.loadImage(imageStream.toArray()); -//Set wrapping style for picture. +// Set wrapping style for the picture. picture.setTextWrappingStyle(TextWrappingStyle.InFrontOfText); -//Set height and width for the image. +// Set height and width for the image. picture.setHeight(100); picture.setWidth(100); -//Set horizontal and vertical position. +// Set horizontal and vertical position. picture.setHorizontalPosition(400); picture.setVerticalPosition(150); -//Set horizontal and vertical origin. +// Set horizontal and vertical origin. picture.setHorizontalOrigin(HorizontalOrigin.Page); picture.setVerticalOrigin(VerticalOrigin.Page); -//Add the specified picture to group shape. +// Add the specified picture to the group shape. groupShape.add(picture); -//Create new textbox. +// Create a new textbox. WTextBox textbox = new WTextBox(document); textbox.getTextBoxFormat().setWidth(150); textbox.getTextBoxFormat().setHeight(75); -//Add new text to the textbox body. +// Add new text to the textbox body. IWParagraph textboxParagraph = textbox.getTextBoxBody().addParagraph(); textboxParagraph.appendText("Text inside text box"); -//Set wrapping style for textbox. +// Set wrapping style for the textbox. textbox.getTextBoxFormat().setTextWrappingStyle(TextWrappingStyle.Behind); -//Set horizontal and vertical position. +// Set horizontal and vertical position. textbox.getTextBoxFormat().setHorizontalPosition(200); textbox.getTextBoxFormat().setVerticalPosition(200); -//Set horizontal and vertical origin. +// Set horizontal and vertical origin. textbox.getTextBoxFormat().setVerticalOrigin(VerticalOrigin.Page); textbox.getTextBoxFormat().setHorizontalOrigin(HorizontalOrigin.Page); -//Add the specified textbox to group shape. +// Add the specified textbox to the group shape. groupShape.add(textbox); -//Save and close the Word document instance. +// Save and close the Word document instance. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} +### Nested Group Shapes -### Nested group shapes + -The following code example illustrates how to group the nested group shapes as a group shape in Word document. +The following code example illustrates how to group nested group shapes as a group shape in a Word document. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section. -WParagraph paragraph = (WParagraph)section.addParagraph(); -//Create new group shape. +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); +// Create a new group shape. GroupShape groupShape = new GroupShape(document); -//Add group shape to the paragraph. +// Add the group shape to the paragraph. paragraph.getChildEntities().add(groupShape); -//Append new shape to the document. +// Append a new shape to the document. Shape shape = new Shape(document, AutoShapeType.RoundedRectangle); -//Set height and width for shape. +// Set height and width for the shape. shape.setHeight(100); shape.setWidth(150); -//Set Wrapping style for shape. +// Set wrapping style for the shape. shape.getWrapFormat().setTextWrappingStyle(TextWrappingStyle.InFrontOfText); -//Set horizontal and vertical position for shape. +// Set horizontal and vertical position for the shape. shape.setHorizontalPosition(72); shape.setVerticalPosition(72); -//Set horizontal and vertical origin for shape. +// Set horizontal and vertical origin for the shape. shape.setHorizontalOrigin(HorizontalOrigin.Page); shape.setVerticalOrigin(VerticalOrigin.Page); -//Add the specified shape to group shape. +// Add the specified shape to the group shape. groupShape.add(shape); -//Append new picture to the document. +// Append a new picture to the document. WPicture picture = new WPicture(document); -//Load image from the file. +// Load image from the file. FileStreamSupport imageStream = new FileStreamSupport("Image.png", FileMode.Open, FileAccess.ReadWrite); picture.loadImage(imageStream.toArray()); -//Set wrapping style for picture. +// Set wrapping style for the picture. picture.setTextWrappingStyle(TextWrappingStyle.InFrontOfText); -//Set height and width for the picture. +// Set height and width for the picture. picture.setHeight(100); picture.setWidth(100); -//Set horizontal and vertical position for the picture. +// Set horizontal and vertical position for the picture. picture.setHorizontalPosition(400); picture.setVerticalPosition(150); -//Set horizontal and vertical origin for the picture. +// Set horizontal and vertical origin for the picture. picture.setHorizontalOrigin(HorizontalOrigin.Page); picture.setVerticalOrigin(VerticalOrigin.Page); -//Add specified picture to the group shape. +// Add the specified picture to the group shape. groupShape.add(picture); -//Create new nested group shape. +// Create a new nested group shape. GroupShape nestedGroupShape = new GroupShape(document); -//Append new textbox to the document. +// Append a new textbox to the document. WTextBox textbox = new WTextBox(document); -//Set width and height for the textbox. +// Set width and height for the textbox. textbox.getTextBoxFormat().setWidth(150); textbox.getTextBoxFormat().setHeight(75); -//Add new text to the textbox body. +// Add new text to the textbox body. IWParagraph textboxParagraph = textbox.getTextBoxBody().addParagraph(); -//Add new text to the textbox paragraph. +// Add new text to the textbox paragraph. textboxParagraph.appendText("Text inside text box"); -//Set wrapping style for the textbox. +// Set wrapping style for the textbox. textbox.getTextBoxFormat().setTextWrappingStyle(TextWrappingStyle.Behind); -//Set horizontal and vertical position for the textbox. +// Set horizontal and vertical position for the textbox. textbox.getTextBoxFormat().setHorizontalPosition(200); textbox.getTextBoxFormat().setVerticalPosition(200); -//Set horizontal and vertical origin for the textbox. +// Set horizontal and vertical origin for the textbox. textbox.getTextBoxFormat().setVerticalOrigin(VerticalOrigin.Page); textbox.getTextBoxFormat().setHorizontalOrigin(HorizontalOrigin.Page); -//Add specified textbox to the nested group shape. +// Add the specified textbox to the nested group shape. nestedGroupShape.add(textbox); -//Append new shape to the document. +// Append a new shape to the document. shape = new Shape(document, AutoShapeType.Oval); -//Set height and width for the new shape. +// Set height and width for the new shape. shape.setHeight(100); shape.setWidth(150); -//Set horizontal and vertical position for the shape. +// Set horizontal and vertical position for the shape. shape.setHorizontalPosition(200); shape.setVerticalPosition(72); -//Set horizontal and vertical origin for the shape. +// Set horizontal and vertical origin for the shape. shape.setHorizontalOrigin(HorizontalOrigin.Page); shape.setVerticalOrigin(VerticalOrigin.Page); -//Set horizontal and vertical position for the nested group shape. +// Set horizontal and vertical position for the nested group shape. nestedGroupShape.setHorizontalPosition(72); nestedGroupShape.setVerticalPosition(72); -//Add specified shape to the nested group shape. +// Add the specified shape to the nested group shape. nestedGroupShape.add(shape); -//Add nested group shape to the group shape of the paragraph. +// Add the nested group shape to the group shape of the paragraph. groupShape.add(nestedGroupShape); -//Save and close the Word document instance. +// Save and close the Word document instance. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -## Ungrouping shapes +## Ungrouping Shapes -You can ungroup the group shapes in the Word document to preserve each shape as individual item. +You can ungroup group shapes in the Word document to preserve each shape as an individual item. -The following code example shows how to ungroup the group shape in Word document. +The following code example shows how to ungroup a group shape in a Word document. {% tabs %} {% highlight JAVA %} -//Load the template document. +// Load the template document. WordDocument document = new WordDocument("Template.docx", FormatType.Automatic); -//Get the last paragraph. +// Get the last paragraph. WParagraph lastParagraph = document.getLastParagraph(); -//Iterate through the paragraph items to get the group shape. +// Iterate through the paragraph items to get the group shape. for (int i = 0; i < lastParagraph.getChildEntities().getCount(); i++) { if (lastParagraph.getChildEntities().get(i) instanceof GroupShape) { - GroupShape groupShape = (GroupShape)lastParagraph.getChildEntities().get(i); - //Ungroup the child shapes in the group shape. + GroupShape groupShape = (GroupShape) lastParagraph.getChildEntities().get(i); + // Ungroup the child shapes in the group shape. groupShape.ungroup(); break; } } -//Save and closes the Word document instance. +// Save and close the Word document instance. document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} diff --git a/java-file-formats/word-library/working-with-tables.md b/java-file-formats/word-library/working-with-tables.md index 9a3f11c..baa84bc 100644 --- a/java-file-formats/word-library/working-with-tables.md +++ b/java-file-formats/word-library/working-with-tables.md @@ -1,664 +1,630 @@ --- -title: Working With Tables | DocIO | Syncfusion -description: This section illustrates how to work with Tables in Word document using Syncfusion Java Word library (Essential DocIO) +title: Working with Shapes | Syncfusion +description: This section describes how to work with the shapes and group shapes in a Word document using the Syncfusion Java Word library (Essential DocIO). platform: java-file-formats control: Word Library documentation: UG +keywords: --- -# Working with Tables in Word document +# Working with Shapes in a Word Document -A table in Word document is used to arrange document content in rows and columns. `WTable` instance represents a table in Word document. A table must contain at least one row. +Shapes are drawing objects that include lines, curves, circles, rectangles, etc. They can be preset or custom geometry. You can create and manipulate predefined shapes in DOCX and WordML format documents. -1. A row is a collection of cells and it is represented by an instance of `WTableRow`. Each row must contain at least one cell. -2. A cell can contain one or more paragraphs and tables. An instance of `WTableCell` represents a table cell. Each table cell must contain at least one paragraph. +## Adding Shapes -N> Adding more than 63 columns not supported in Word document using Microsoft Word application. It shows alert when you attempt to insert table with more than 64 columns, which is a one of the behaviors of Microsoft Word and Essential® DocIO does the same. +The following code example shows how to add a predefined shape to the document. -The following image illustrates how a table in Word document is organized in EssentialDocIO’s DOM: - -![DocIO Table DOM Structure](WorkingwithTables_images/WTable_DOM.jpg) - -The following code example illustrates how to create a simple table with predefined number of rows and cells. - -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add a section into Word document. +// Add a new section to the document. IWSection section = document.addSection(); -//Add a new paragraph into Word document and appends text into paragraph. -IWTextRange textRange = section.addParagraph().appendText("Price Details"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(12); -textRange.getCharacterFormat().setBold(true); -section.addParagraph(); -//Add a new table into Word document. -IWTable table = section.addTable(); -//Specify the total number of rows & columns. -table.resetCells(3, 2); -//Access the instance of the cell (first row, first cell) and add the content into cell. -textRange = table.get(0, 0).addParagraph().appendText("Item"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(12); -textRange.getCharacterFormat().setBold(true); -//Access the instance of the cell (first row, second cell) and add the content into cell. -textRange = table.get(0, 1).addParagraph().appendText("Price($)"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(12); -textRange.getCharacterFormat().setBold(true); -//Access the instance of the cell (second row, first cell) and add the content into cell. -textRange = table.get(1, 0).addParagraph().appendText("Apple"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(10); -//Access the instance of the cell (second row, second cell) and add the content into cell. -textRange = table.get(1, 1).addParagraph().appendText("50"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(10); -//Accessthe instance of the cell (third row, first cell) and add the content into cell. -textRange = table.get(2, 0).addParagraph().appendText("Orange"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(10); -//Access the instance of the cell (third row, second cell) and add the content into cell. -textRange = table.get(2, 1).addParagraph().appendText("30"); -textRange.getCharacterFormat().setFontName("Arial"); -textRange.getCharacterFormat().setFontSize(10); -//Save the document in the given name and format. -document.save("Table.docx", FormatType.Docx); -//Release the resources occupied by WordDocument instance. +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); +// Add a new shape to the document. +Shape rectangle = paragraph.appendShape(AutoShapeType.RoundedRectangle, 150, 100); +// Set position for the shape. +rectangle.setVerticalPosition(72); +rectangle.setHorizontalPosition(72); +paragraph = (WParagraph) section.addParagraph(); +// Add text body contents to the shape. +paragraph = (WParagraph) rectangle.getTextBody().addParagraph(); +IWTextRange text = paragraph.appendText("This text is in a rounded rectangle shape"); +text.getCharacterFormat().setTextColor(ColorSupport.getGreen()); +text.getCharacterFormat().setBold(true); +// Add another shape to the document. +paragraph = (WParagraph) section.addParagraph(); +paragraph.appendBreak(BreakType.LineBreak); +Shape pentagon = paragraph.appendShape(AutoShapeType.Pentagon, 100, 100); +paragraph = (WParagraph) pentagon.getTextBody().addParagraph(); +paragraph.appendText("This text is in a pentagon shape"); +// Set position for the shape. +pentagon.setHorizontalPosition(72); +pentagon.setVerticalPosition(200); +// Save and close the Word document instance. +document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The following code example illustrates how to create a simple table by dynamically adding rows. +### Format Shapes -{% tabs %} +Shapes can have formatting such as line color, fill color, positioning, wrap formats, etc. The following code example illustrates how to apply formatting options for a shape. + +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class +// Create a new Word document. WordDocument document = new WordDocument(); +// Add a new section to the document. IWSection section = document.addSection(); -section.addParagraph().appendText("Price Details"); -section.addParagraph(); -//Add a new table into Word document -IWTable table = section.addTable(); -//Add the first row into table -WTableRow row = table.addRow(); -//Add the first cell into first row -WTableCell cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("Item"); -//Add the second cell into first row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("Price($)"); -//Add the second row into table -row = table.addRow(true, false); -//Add the first cell into second row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("Apple"); -//Add the second cell into second row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("50"); -//Add the third row into table -row = table.addRow(true, false); -//Add the first cell into third row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("Orange"); -//Add the second cell into third row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("30"); -//Add the fourth row into table -row = table.addRow(true, false); -//Add the first cell into fourth row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("Banana"); -//Add the second cell into fourth row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("20"); -//Add the fifth row to table -row = table.addRow(true, false); -//Adds the first cell into fifth row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("Grapes"); -//Add the second cell into fifth row -cell = row.addCell(); -//Specify the cell width -cell.setWidth(200); -cell.addParagraph().appendText("70"); -//Save and close the document instance -document.save("Table.docx", FormatType.Docx); +// Add a new paragraph to the section. +IWParagraph paragraph = (WParagraph) section.addParagraph(); +// Append a shape to the paragraph. +Shape rectangle = paragraph.appendShape(AutoShapeType.RoundedRectangle, 150, 100); +rectangle.setVerticalPosition(72); +rectangle.setHorizontalPosition(72); +paragraph = (WParagraph) section.addParagraph(); +paragraph = (WParagraph) rectangle.getTextBody().addParagraph(); +IWTextRange text = paragraph.appendText("This text is in a rounded rectangle shape"); +// Apply format to the text. +text.getCharacterFormat().setTextColor(ColorSupport.getGreen()); +text.getCharacterFormat().setBold(true); +// Apply fill color for the shape. +rectangle.getFillFormat().setFill(true); +rectangle.getFillFormat().setColor(ColorSupport.getLightGray()); +// Apply wrap formats. +rectangle.getWrapFormat().setTextWrappingStyle(TextWrappingStyle.Square); +rectangle.getWrapFormat().setTextWrappingType(TextWrappingType.Right); +// Set horizontal and vertical origin. +rectangle.setHorizontalOrigin(HorizontalOrigin.Margin); +rectangle.setVerticalOrigin(VerticalOrigin.Page); +// Set line format. +rectangle.getLineFormat().setDashStyle(LineDashing.Dot); +rectangle.getLineFormat().setColor(ColorSupport.getDarkGray()); +// Save and close the Word document instance. +document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -## Nested Table +### Rotate Shapes -You can create a nested table by adding a new table into a cell. The following code example illustrates how to add a table into a cell. +You can rotate a shape and also apply flipping (horizontal and vertical) to it. The following code example explains how to rotate and flip a shape. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create a new Word document. WordDocument document = new WordDocument(); +// Add a new section to the document. IWSection section = document.addSection(); -section.addParagraph().appendText("Price Details"); -IWTable table = section.addTable(); -table.resetCells(3, 2); -table.get(0, 0).addParagraph().appendText("Item"); -table.get(0, 1).addParagraph().appendText("Price($)"); -table.get(1, 0).addParagraph().appendText("Items with same price"); -//Add a nested table into the cell (second row, first cell). -IWTable nestTable = table.get(1, 0).addTable(); -//Create the specified number of rows and columns to nested table. -nestTable.resetCells(3, 1); -//Access the instance of the nested table cell (first row, first cell). -WTableCell nestedCell = nestTable.getRows().get(0).getCells().get(0); -//Specify the width of the nested cell. -nestedCell.setWidth(200); -//Add the content into nested cell. -nestedCell.addParagraph().appendText("Apple"); -//Access the instance of the nested table cell (second row, first cell). -nestedCell = nestTable.getRows().get(1).getCells().get(0); -//Specify the width of the nested cell. -nestedCell.setWidth(200); -//Add the content into nested cell. -nestedCell.addParagraph().appendText("Orange"); -//Access the instance of the nested table cell (third row, first cell). -nestedCell = nestTable.getRows().get(2).getCells().get(0); -//Specify the width of the nested cell. -nestedCell.setWidth(200); -//Add the content into nested cell. -nestedCell.addParagraph().appendText("Mango"); -//Access the instance of the cell (second row, second cell). -nestedCell = table.getRows().get(1).getCells().get(1); -table.get(1, 1).addParagraph().appendText("85"); -table.get(2, 0).addParagraph().appendText("Pomegranate"); -table.get(2, 1).addParagraph().appendText("70"); -//Save and close the document instance. -document.save("NestedTable.docx", FormatType.Docx); +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); +Shape rectangle = paragraph.appendShape(AutoShapeType.RoundedRectangle, 150, 100); +// Set position for the shape. +rectangle.setVerticalPosition(72); +rectangle.setHorizontalPosition(72); +// Set 90-degree rotation. +rectangle.setRotation(90); +// Set horizontal flip. +rectangle.setFlipHorizontal(true); +paragraph = (WParagraph) section.addParagraph(); +paragraph = (WParagraph) rectangle.getTextBody().addParagraph(); +IWTextRange text = paragraph.appendText("This text is in a rounded rectangle shape"); +// Save the Word document. +document.save("Result.docx", FormatType.Docx); +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} + +## Grouping Shapes -## Align text within a table +The Word library now allows you to create or group multiple shapes, pictures, and text boxes as a group shape in a Word document (DOCX) and preserve it during DOCX and WordML format conversions. -You can iterate the cells within a table and align text for each cell. Find more information about iterating the cells from [here](https://help.syncfusion.com/document-processing/word/word-library/java/working-with-tables#iterating-through-table-elements) +You can create a document with group shapes by using Microsoft Word. It provides an option to group a set of shapes and images as a single shape or treat a group shape as an individual item. +![Create Group Shape in Microsoft Word](Working-with-Shapes_images/Working-with-Shapes_img1.jpeg) -The following code example illustrates how to align text within a table. +**Key Features:** + +1. You can easily manage a group of shapes, pictures, and text boxes as a group shape. +2. You can move several shapes or images simultaneously and apply the same formatting properties for children of group shapes. + +N> 1. While grouping the shapes or other objects, the shapes should be positioned relative to the “Page”. +N> 2. While grouping the shapes or other objects, the wrapping style should not be "In Line with Text". + +The following code example shows how to create a group shape in a Word document. {% tabs %} {% highlight JAVA %} -private void alignCellContent(WTableCell tableCell,VerticalAlignment verticalAlignment,HorizontalAlignment horizontalAlignment)throws Exception -{ - //Set vertical alignment to the cell. - tableCell.getCellFormat().setVerticalAlignment(verticalAlignment); - //Iterate body items in table cell and set horizontal alignment. - alignCellContentForTextBody(tableCell,horizontalAlignment); -} -private void alignCellContentForTextBody(WTextBody textBody,HorizontalAlignment horizontalAlignment)throws Exception -{ - for(int i = 0;i 1. `BorderStyle.None` is the default value of `BorderType` property in `Borders` class which will not show borders for the table or cell. It is equivalent to border style not defined and borders can be inherited from style or parent formats. -N> 2. To hide border for a table or cell in the Word Document, you can set `BorderType` property with `BorderStyle.Cleared`. It means border style defined as no border (Don’t show border) and shouldn’t inherit from style or parent formats. -N> 3. To show/display border for a table or cell in the Word Document, you can set `BorderType` property with `BorderStyle` values (except `BorderStyle.None` and `BorderStyle.Cleared`). +The following code example illustrates how to group nested group shapes as a group shape in a Word document. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class (Empty Word Document) +// Create a new Word document. WordDocument document = new WordDocument(); -//Open an existing Word document into DocIO instance -document.open("Table.docx", FormatType.Docx); -//Access the instance of the first section in the Word document -WSection section = document.getSections().get(0); -//Access the instance of the first table in the section -WTable table = section.getTables().get(0); -//Specify the title for the table -table.setTitle("PriceDetails"); -//Specify the description of the table -table.setDescription("This table shows the price details of various fruits"); -//Specify the left indent of the table -table.setIndentFromLeft(50); -//Specify the background color of the table -table.getTableFormat().setBackColor(ColorSupport.fromArgb(192, 192, 192)); -//Specify the horizontal alignment of the table -table.getTableFormat().setHorizontalAlignment(RowAlignment.Left); -//Specify the left, right, top and bottom padding of all the cells in the table -table.getTableFormat().getPaddings().setAll(10); -//Specify the auto resize of table to automatically resize all cell width based on its content -table.getTableFormat().setIsAutoResized(true); -//Specify the table top, bottom, left and right border line width -table.getTableFormat().getBorders().setLineWidth(2f); -//Specify the table horizontal border line width -table.getTableFormat().getBorders().getHorizontal().setLineWidth(2f); -//Specify the table vertical border line width -table.getTableFormat().getBorders().getVertical().setLineWidth(2f); -//Specify the tables top, bottom, left and right border color -table.getTableFormat().getBorders().setColor(ColorSupport.getRed()); -//Specify the table Horizontal border color -table.getTableFormat().getBorders().getHorizontal().setColor(ColorSupport.getRed()); -//Specify the table vertical border color -table.getTableFormat().getBorders().getVertical().setColor(ColorSupport.getRed()); -//Specify the table borders border type -table.getTableFormat().getBorders().setBorderType(BorderStyle.Double); -//Accesses the instance of the first row in the table -WTableRow row = table.getRows().get(0); -//Specify the row height -row.setHeight(20); -//Specify the row height type -row.setHeightType(TableRowHeightType.AtLeast); -//Save and close the document instance -document.save("TableFormatting.docx", FormatType.Docx); +// Add a new section to the document. +IWSection section = document.addSection(); +// Add a new paragraph to the section. +WParagraph paragraph = (WParagraph) section.addParagraph(); +// Create a new group shape. +GroupShape groupShape = new GroupShape(document); +// Add the group shape to the paragraph. +paragraph.getChildEntities().add(groupShape); +// Append a new shape to the document. +Shape shape = new Shape(document, AutoShapeType.RoundedRectangle); +// Set height and width for the shape. +shape.setHeight(100); +shape.setWidth(150); +// Set wrapping style for the shape. +shape.getWrapFormat().setTextWrappingStyle(TextWrappingStyle.InFrontOfText); +// Set horizontal and vertical position for the shape. +shape.setHorizontalPosition(72); +shape.setVerticalPosition(72); +// Set horizontal and vertical origin for the shape. +shape.setHorizontalOrigin(HorizontalOrigin.Page); +shape.setVerticalOrigin(VerticalOrigin.Page); +// Add the specified shape to the group shape. +groupShape.add(shape); +// Append a new picture to the document. +WPicture picture = new WPicture(document); +// Load image from the file. +FileStreamSupport imageStream = new FileStreamSupport("Image.png", FileMode.Open, FileAccess.ReadWrite); +picture.loadImage(imageStream.toArray()); +// Set wrapping style for the picture. +picture.setTextWrappingStyle(TextWrappingStyle.InFrontOfText); +// Set height and width for the picture. +picture.setHeight(100); +picture.setWidth(100); +// Set horizontal and vertical position for the picture. +picture.setHorizontalPosition(400); +picture.setVerticalPosition(150); +// Set horizontal and vertical origin for the picture. +picture.setHorizontalOrigin(HorizontalOrigin.Page); +picture.setVerticalOrigin(VerticalOrigin.Page); +// Add the specified picture to the group shape. +groupShape.add(picture); +// Create a new nested group shape. +GroupShape nestedGroupShape = new GroupShape(document); +// Append a new textbox to the document. +WTextBox textbox = new WTextBox(document); +// Set width and height for the textbox. +textbox.getTextBoxFormat().setWidth(150); +textbox.getTextBoxFormat().setHeight(75); +// Add new text to the textbox body. +IWParagraph textboxParagraph = textbox.getTextBoxBody().addParagraph(); +// Add new text to the textbox paragraph. +textboxParagraph.appendText("Text inside text box"); +// Set wrapping style for the textbox. +textbox.getTextBoxFormat().setTextWrappingStyle(TextWrappingStyle.Behind); +// Set horizontal and vertical position for the textbox. +textbox.getTextBoxFormat().setHorizontalPosition(200); +textbox.getTextBoxFormat().setVerticalPosition(200); +// Set horizontal and vertical origin for the textbox. +textbox.getTextBoxFormat().setVerticalOrigin(VerticalOrigin.Page); +textbox.getTextBoxFormat().setHorizontalOrigin(HorizontalOrigin.Page); +// Add the specified textbox to the nested group shape. +nestedGroupShape.add(textbox); +// Append a new shape to the document. +shape = new Shape(document, AutoShapeType.Oval); +// Set height and width for the new shape. +shape.setHeight(100); +shape.setWidth(150); +// Set horizontal and vertical position for the shape. +shape.setHorizontalPosition(200); +shape.setVerticalPosition(72); +// Set horizontal and vertical origin for the shape. +shape.setHorizontalOrigin(HorizontalOrigin.Page); +shape.setVerticalOrigin(VerticalOrigin.Page); +// Set horizontal and vertical position for the nested group shape. +nestedGroupShape.setHorizontalPosition(72); +nestedGroupShape.setVerticalPosition(72); +// Add the specified shape to the nested group shape. +nestedGroupShape.add(shape); +// Add the nested group shape to the group shape of the paragraph. +groupShape.add(nestedGroupShape); +// Save and close the Word document instance. +document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -### Applying cell formatting - -The following code example illustrates how to load an existing document and apply cell formatting options such as VerticalAlignment, TextDirection, Paddings, Borders, etc. +## Ungrouping Shapes -{% tabs %} +You can ungroup group shapes in the Word document to preserve each shape as an individual item. + +The following code example shows how to ungroup a group shape in a Word document. + +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. -WordDocument document = new WordDocument(); -document.open("Table.docx",FormatType.Docx); -WSection section = document.getSections().get(0); -//Access the instance of the first row in the table. -WTable table = section.getTables().get(0); -//Specify the row height. -WTableRow row = table.getRows().get(0); -row.setHeight(20); -//Specify the row height type. -row.setHeightType(TableRowHeightType.AtLeast); -//Access the instance of the first cell in the row. -WTableCell cell = row.getCells().get(0); -//Specify the cell back ground color. -cell.getCellFormat().setBackColor(ColorSupport.fromArgb(192,192,192)); -//Specify the same padding as table option as false to preserve current cell padding. -cell.getCellFormat().setSamePaddingsAsTable(false); -//Specify the left, right, top and bottom padding of the cell. -cell.getCellFormat().getPaddings().setLeft(5); -cell.getCellFormat().getPaddings().setRight(5); -cell.getCellFormat().getPaddings().setTop(5); -cell.getCellFormat().getPaddings().setBottom(5); -//Specify the vertical alignment of content of text. -cell.getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); -//Disable the text wrap option to avoid displaying longer text on multiple lines. -cell.getCellFormat().setTextWrap(false); -//Access the instance of the second cell in the row. -cell=row.getCells().get(1); -cell.getCellFormat().setBackColor(ColorSupport.fromArgb(192,192,192)); -cell.getCellFormat().setSamePaddingsAsTable(false); -//Specify the left, right, top and bottom padding of the cell. -cell.getCellFormat().getPaddings().setAll(5); -cell.getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); -//Disable the text wrap option to avoid displaying longer text on multiple lines. -cell.getCellFormat().setTextWrap(false); -//Save and close the document instance. -document.save("TableCellFormatting.docx",FormatType.Docx); +// Load the template document. +WordDocument document = new WordDocument("Template.docx", FormatType.Automatic); +// Get the last paragraph. +WParagraph lastParagraph = document.getLastParagraph(); +// Iterate through the paragraph items to get the group shape. +for (int i = 0; i < lastParagraph.getChildEntities().getCount(); i++) +{ + if (lastParagraph.getChildEntities().get(i) instanceof GroupShape) + { + GroupShape groupShape = (GroupShape) lastParagraph.getChildEntities().get(i); + // Ungroup the child shapes in the group shape. + groupShape.ungroup(); + break; + } +} +// Save and close the Word document instance. +document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ### Working with Table Style -A table style defines a set of table, row, cell and paragraph level formatting that can be applied to a table. `WTableStyle` instance represents table style in a Word document. +A table style defines a set of table, row, cell, and paragraph-level formatting that can be applied to a table. The `WTableStyle` instance represents table style in a Word document. -N> Essential® DocIO currently provides support for table styles in DOCX and WordML formats alone. The visual appearance is also preserved in Word to HTML conversion. +N> Essential® DocIO currently provides support for table styles in DOCX and WordML formats alone. The visual appearance is also preserved in Word-to-HTML conversion. The following code example illustrates how to apply the built-in table styles to the table. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create an instance of WordDocument class. WordDocument document = new WordDocument("Table.docx", FormatType.Docx); WSection section = document.getSections().get(0); WTable table = section.getTables().get(0); -//Apply "LightShading" built-in style to table. +// Apply "LightShading" built-in style to table. table.applyStyle(BuiltinTableStyle.LightShading); -//Save and close the document instance. +// Save and close the document instance. document.save("TableStyle.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -### Table style options +### Table Style Options -Once you have applied a table style, you can enable or disable the special formatting of the table. There are six options: first column, last column, banded rows, banded columns, header row and last row. +Once you have applied a table style, you can enable or disable the special formatting of the table. There are six options: first column, last column, banded rows, banded columns, header row, and last row. -The following code example illustrates how to enable and disable the special table formatting options of the table styles +The following code example illustrates how to enable and disable the special table formatting options of the table styles. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. -WordDocument document = new WordDocument("Table.docx",FormatType.Docx); +// Create an instance of WordDocument class. +WordDocument document = new WordDocument("Table.docx", FormatType.Docx); WSection section = document.getSections().get(0); WTable table = section.getTables().get(0); -//Apply"LightShading" built-in style to table. +// Apply "LightShading" built-in style to table. table.applyStyle(BuiltinTableStyle.LightShading); -//Enable special formatting for banded columns of the table. +// Enable special formatting for banded columns of the table. table.setApplyStyleForBandedColumns(true); -//Enable special formatting for banded rows of the table. +// Enable special formatting for banded rows of the table. table.setApplyStyleForBandedRows(true); -//Disables special formatting for first column of the table. +// Disable special formatting for the first column of the table. table.setApplyStyleForFirstColumn(false); -//Enable special formatting for header row of the table. +// Enable special formatting for the header row of the table. table.setApplyStyleForHeaderRow(true); -//Enable special formatting for last column of the table. +// Enable special formatting for the last column of the table. table.setApplyStyleForLastColumn(true); -//Disable special formatting for last row of the table. +// Disable special formatting for the last row of the table. table.setApplyStyleForLastRow(false); -//Save and close the document instance. -document.save("TableStyle.docx",FormatType.Docx); +// Save and close the document instance. +document.save("TableStyle.docx", FormatType.Docx); document.close(); {% endhighlight %} {% endtabs %} -### Custom table style +### Custom Table Style -The following code example illustrates how to apply a custom table style to table. +The following code example illustrates how to apply a custom table style to a table. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Creates an instance of WordDocument class. +// Create an instance of WordDocument class. WordDocument document = new WordDocument("Table.docx", FormatType.Docx); WSection section = document.getSections().get(0); WTable table = section.getTables().get(0); -//Adds a new custom table style. -WTableStyle tableStyle = (WTableStyle)document.addTableStyle("CustomStyle"); -//Applies formatting for whole table. +// Add a new custom table style. +WTableStyle tableStyle = (WTableStyle) document.addTableStyle("CustomStyle"); +// Apply formatting for the whole table. tableStyle.getTableProperties().setRowStripe(1); tableStyle.getTableProperties().setColumnStripe(1); tableStyle.getTableProperties().getPaddings().setTop(0); tableStyle.getTableProperties().getPaddings().setBottom(0); tableStyle.getTableProperties().getPaddings().setLeft(5.4f); tableStyle.getTableProperties().getPaddings().setRight(5.4f); -//Applies conditional formatting for first row. +// Apply conditional formatting for the first row. ConditionalFormattingStyle firstRowStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.FirstRow); firstRowStyle.getCharacterFormat().setBold(true); -firstRowStyle.getCharacterFormat().setTextColor(ColorSupport.fromArgb(255,255,255,255)); +firstRowStyle.getCharacterFormat().setTextColor(ColorSupport.fromArgb(255, 255, 255, 255)); firstRowStyle.getCellProperties().setBackColor(ColorSupport.getBlue()); -//Applies conditional formatting for first column. +// Apply conditional formatting for the first column. ConditionalFormattingStyle firstColumnStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.FirstColumn); firstColumnStyle.getCharacterFormat().setBold(true); -//Applies conditional formatting for odd row. +// Apply conditional formatting for odd rows. ConditionalFormattingStyle oddRowBandingStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.OddRowBanding); oddRowBandingStyle.getCellProperties().setBackColor(ColorSupport.getWhiteSmoke()); -//Applies the custom table style to the table. +// Apply the custom table style to the table. table.applyStyle("CustomStyle"); -//Saves and closes the document instance -document.save("TableStyle.docx",FormatType.Docx); +// Save and close the document instance. +document.save("TableStyle.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ### Apply Base Style -Table styles can be based on other table styles also. When applying a base style, the new style will inherit the values of the base style that are not explicitly redefined in the new style. You can apply a custom table style or a built-in table style as a base for the table style. +Table styles can be based on other table styles as well. When applying a base style, the new style will inherit the values of the base style that are not explicitly redefined in the new style. You can apply a custom table style or a built-in table style as a base for the table style. The following code example illustrates how to apply built-in and custom table styles as base styles for another custom table. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add one section and paragraph to the document. +// Add one section and paragraph to the document. document.ensureMinimal(); -WTable table = (WTable)document.getLastSection().addTable(); -table.resetCells(3,2); -table.get(0,0).addParagraph().appendText("Row 1 Cell 1"); -table.get(0,1).addParagraph().appendText("Row 1 Cell 2"); -table.get(1,0).addParagraph().appendText("Row 2 Cell 1"); -table.get(1,1).addParagraph().appendText("Row 2 Cell 2"); -table.get(2,0).addParagraph().appendText("Row 3 Cell 1"); -table.get(2,1).addParagraph().appendText("Row 3 Cell2"); - -//Add a new custom table style. -WTableStyle tableStyle = (WTableStyle)document.addTableStyle("CustomStyle1"); -tableStyle.getTableProperties().setRowStripe((long)1); -//Apply conditional formatting for the first row. +WTable table = (WTable) document.getLastSection().addTable(); +table.resetCells(3, 2); +table.get(0, 0).addParagraph().appendText("Row 1 Cell 1"); +table.get(0, 1).addParagraph().appendText("Row 1 Cell 2"); +table.get(1, 0).addParagraph().appendText("Row 2 Cell 1"); +table.get(1, 1).addParagraph().appendText("Row 2 Cell 2"); +table.get(2, 0).addParagraph().appendText("Row 3 Cell 1"); +table.get(2, 1).addParagraph().appendText("Row 3 Cell 2"); + +// Add a new custom table style. +WTableStyle tableStyle = (WTableStyle) document.addTableStyle("CustomStyle1"); +tableStyle.getTableProperties().setRowStripe((long) 1); +// Apply conditional formatting for the first row. ConditionalFormattingStyle firstRowStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.FirstRow); firstRowStyle.getCharacterFormat().setBold(true); -//Apply conditional formatting for the odd row. +// Apply conditional formatting for odd rows. ConditionalFormattingStyle oddRowBandingStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.OddRowBanding); oddRowBandingStyle.getCharacterFormat().setItalic(true); -//Apply built-in table style as base style for CustomStyle1. +// Apply built-in table style as base style for CustomStyle1. tableStyle.applyBaseStyle(BuiltinTableStyle.TableContemporary); -//Apply the custom table style to the table. +// Apply the custom table style to the table. table.applyStyle("CustomStyle1"); document.getLastSection().addParagraph(); -//Create another table in the Word document. -table=(WTable)document.getLastSection().addTable(); -table.resetCells(3,2); -table.get(0,0).addParagraph().appendText("Row 1 Cell 1"); -table.get(0,1).addParagraph().appendText("Row 1 Cell 2"); -table.get(1,0).addParagraph().appendText("Row 2 Cell 1"); -table.get(1,1).addParagraph().appendText("Row 2 Cell 2"); -table.get(2,0).addParagraph().appendText("Row 3 Cell 1"); -table.get(2,1).addParagraph().appendText("Row 3 Cell2"); - -//Add a new custom table style. -tableStyle=(WTableStyle)document.addTableStyle("CustomStyle2"); -tableStyle.getTableProperties().setRowStripe((long)1); - //Apply conditional formatting for the first row. -firstRowStyle=tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.FirstRow); +// Create another table in the Word document. +table = (WTable) document.getLastSection().addTable(); +table.resetCells(3, 2); +table.get(0, 0).addParagraph().appendText("Row 1 Cell 1"); +table.get(0, 1).addParagraph().appendText("Row 1 Cell 2"); +table.get(1, 0).addParagraph().appendText("Row 2 Cell 1"); +table.get(1, 1).addParagraph().appendText("Row 2 Cell 2"); +table.get(2, 0).addParagraph().appendText("Row 3 Cell 1"); +table.get(2, 1).addParagraph().appendText("Row 3 Cell 2"); + +// Add a new custom table style. +tableStyle = (WTableStyle) document.addTableStyle("CustomStyle2"); +tableStyle.getTableProperties().setRowStripe((long) 1); +// Apply conditional formatting for the first row. +firstRowStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.FirstRow); firstRowStyle.getParagraphFormat().setHorizontalAlignment(HorizontalAlignment.Center); -//Apply conditional formatting for the odd row. -oddRowBandingStyle=tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.OddRowBanding); +// Apply conditional formatting for odd rows. +oddRowBandingStyle = tableStyle.getConditionalFormattingStyles().add(ConditionalFormattingType.OddRowBanding); oddRowBandingStyle.getCharacterFormat().setTextColor((ColorSupport.getRed()).clone()); -//Add a new custom table style. -WTableStyle tableStyle2 = (WTableStyle)document.addTableStyle("CustomStyle3"); -tableStyle2.getTableProperties().setRowStripe((long)1); -//Apply conditional formatting for the first row. +// Add a new custom table style. +WTableStyle tableStyle2 = (WTableStyle) document.addTableStyle("CustomStyle3"); +tableStyle2.getTableProperties().setRowStripe((long) 1); +// Apply conditional formatting for the first row. ConditionalFormattingStyle firstRowStyle2 = tableStyle2.getConditionalFormattingStyles().add(ConditionalFormattingType.FirstRow); firstRowStyle2.getCellProperties().setBackColor((ColorSupport.getBlue()).clone()); -//Apply conditional formatting for the odd row. +// Apply conditional formatting for odd rows. ConditionalFormattingStyle oddRowStyle2 = tableStyle2.getConditionalFormattingStyles().add(ConditionalFormattingType.OddRowBanding); oddRowStyle2.getCellProperties().setBackColor((ColorSupport.getYellow()).clone()); -//Apply custom table style as base style for another custom table style. +// Apply custom table style as base style for another custom table style. tableStyle2.applyBaseStyle("CustomStyle2"); -//Apply the custom table style to the table. +// Apply the custom table style to the table. table.applyStyle("CustomStyle3"); -//Save the Word document. -document.save("Sample.docx",FormatType.Docx); -//Close the Word document +// Save the Word document. +document.save("Sample.docx", FormatType.Docx); +// Close the Word document. document.close(); {% endhighlight %} -{% endtabs %} - -## Merging cells vertically and horizontally +{% endtabs %} + +## Merging Cells Vertically and Horizontally You can combine two or more table cells located in the same row or column into a single cell. -The following code example illustrates how to apply horizontal merge to specified range of cells in a specified row. +The following code example illustrates how to apply horizontal merge to a specified range of cells in a specified row. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create an instance of WordDocument class. WordDocument document = new WordDocument(); IWSection section = document.addSection(); section.addParagraph().appendText("Horizontal merging of Table cells"); IWTable table = section.addTable(); -table.resetCells(5,5); -//Specify the horizontal merge from second cell to fifth cell in third row. -table.applyHorizontalMerge(2,1,4); -//Save and close the document instance. -document.save("HorizontalMerge.docx",FormatType.Docx); +table.resetCells(5, 5); +// Specify the horizontal merge from the second cell to the fifth cell in the third row. +table.applyHorizontalMerge(2, 1, 4); +// Save and close the document instance. +document.save("HorizontalMerge.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The following code example illustrates how to apply vertical merge to specified range of rows in a specified column. +The following code example illustrates how to apply vertical merge to a specified range of rows in a specified column. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create an instance of WordDocument class. WordDocument document = new WordDocument(); IWSection section = document.addSection(); section.addParagraph().appendText("Vertical merging of Table cells"); IWTable table = section.addTable(); -table.resetCells(5,5); -//Specify the vertical merge to the third cell, from second row to fifth row. -table.applyVerticalMerge(2,1,4); -//Save and close the document instance. -document.save("VerticalMerge.docx",FormatType.Docx); +table.resetCells(5, 5); +// Specify the vertical merge to the third cell, from the second row to the fifth row. +table.applyVerticalMerge(2, 1, 4); +// Save and close the document instance. +document.save("VerticalMerge.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The following code example illustrate how to create a table that contains horizontal merged cells. +The following code example illustrates how to create a table that contains horizontally merged cells. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create an instance of WordDocument class. WordDocument document = new WordDocument(); IWSection section = document.addSection(); section.addParagraph().appendText("Horizontal merging of Table cells"); IWTable table = section.addTable(); -table.resetCells(2,2); -//Add content to table cell. -table.get(0,0).addParagraph().appendText("First row, First cell"); -table.get(0,1).addParagraph().appendText("First row, Second cell"); -table.get(1,0).addParagraph().appendText("Second row, First cell"); -table.get(1,1).addParagraph().appendText("Second row, Second cell"); -//Specifies the horizontal merge start to first row, first cell. -table.get(0,0).getCellFormat().setHorizontalMerge(CellMerge.Start); -//Modify the cell content. -table.get(0,0).getParagraphs().get(0).setText("Horizontally merged cell"); -//Specify the horizontal merge continue to second row second cell. -table.get(0,1).getCellFormat().setHorizontalMerge(CellMerge.Continue); -//Save and close the document instance. -document.save("HorizontalMerge.docx",FormatType.Docx); +table.resetCells(2, 2); +// Add content to table cells. +table.get(0, 0).addParagraph().appendText("First row, First cell"); +table.get(0, 1).addParagraph().appendText("First row, Second cell"); +table.get(1, 0).addParagraph().appendText("Second row, First cell"); +table.get(1, 1).addParagraph().appendText("Second row, Second cell"); +// Specify the horizontal merge start to the first row, first cell. +table.get(0, 0).getCellFormat().setHorizontalMerge(CellMerge.Start); +// Modify the cell content. +table.get(0, 0).getParagraphs().get(0).setText("Horizontally merged cell"); +// Specify the horizontal merge continuation to the second row, second cell. +table.get(0, 1).getCellFormat().setHorizontalMerge(CellMerge.Continue); +// Save and close the document instance. +document.save("HorizontalMerge.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The following code example illustrates how to create a table with vertical merged cells. +The following code example illustrates how to create a table with vertically merged cells. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create an instance of WordDocument class. +// Create an instance of WordDocument class. WordDocument document = new WordDocument(); IWSection section = document.addSection(); section.addParagraph().appendText("Vertical merging of Table cells"); IWTable table = section.addTable(); -table.resetCells(2,2); -//Add content to table cells. -table.get(0,0).addParagraph().appendText("First row, First cell"); -table.get(0,1).addParagraph().appendText("First row, Second cell"); -table.get(1,0).addParagraph().appendText("Second row, First cell"); -table.get(1,1).addParagraph().appendText("Second row, Second cell"); -//Specify the vertical merge start to first row first cell. -table.get(0,0).getCellFormat().setVerticalMerge(CellMerge.Start); -//Modify the cell content. -table.get(0,0).getParagraphs().get(0).setText("Vertically merged cell"); -//Specify the vertical merge continue to second row first cell. -table.get(1,0).getCellFormat().setVerticalMerge(CellMerge.Continue); -//Save and close the document instance. -document.save("VerticalMerge.docx",FormatType.Docx); +table.resetCells(2, 2); +// Add content to table cells. +table.get(0, 0).addParagraph().appendText("First row, First cell"); +table.get(0, 1).addParagraph().appendText("First row, Second cell"); +table.get(1, 0).addParagraph().appendText("Second row, First cell"); +table.get(1, 1).addParagraph().appendText("Second row, Second cell"); +// Specify the vertical merge start to the first row, first cell. +table.get(0, 0).getCellFormat().setVerticalMerge(CellMerge.Start); +// Modify the cell content. +table.get(0, 0).getParagraphs().get(0).setText("Vertically merged cell"); +// Specify the vertical merge continuation to the second row, first cell. +table.get(1, 0).getCellFormat().setVerticalMerge(CellMerge.Continue); +// Save and close the document instance. +document.save("VerticalMerge.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} ## Specifying table header row to repeat on each page -You can specify one or more rows in a table to be repeated as header row at the top of each page, when the table spans across multiple pages. +You can specify one or more rows in a table to be repeated as header rows at the top of each page when the table spans across multiple pages. -* In the case of a single header row, it must be the first row in the table. -* In the case of multiple header rows, then header rows must be consecutive from the first row of the table. +* In the case of a single header row, it must be the first row in the table. +* In the case of multiple header rows, the header rows must be consecutive from the first row of the table. -N> Heading rows do not have any effect with nested tables in Microsoft Word as well as DocIO +N> Heading rows do not have any effect with nested tables in Microsoft Word as well as DocIO. The following code example illustrates how to create a table with a single header row. @@ -669,22 +635,22 @@ The following code example illustrates how to create a table with a single heade WordDocument document = new WordDocument(); IWSection section = document.addSection(); IWTable table = section.addTable(); -table.resetCells(50,1); +table.resetCells(50, 1); WTableRow row = table.getRows().get(0); //Specify the first row as a header row of the table. row.setIsHeader(true); row.setHeight(20); row.setHeightType(TableRowHeightType.AtLeast); row.getCells().get(0).addParagraph().appendText("Header Row"); -for(int i = 1;i<50;i++) -{ - row=table.getRows().get(i); - row.setHeight(20); - row.setHeightType(TableRowHeightType.AtLeast); - row.getCells().get(0).addParagraph().appendText("Text in Row" + i); +for (int i = 1; i < 50; i++) { + + row = table.getRows().get(i); + row.setHeight(20); + row.setHeightType(TableRowHeightType.AtLeast); + row.getCells().get(0).addParagraph().appendText("Text in Row" + i); } //Save and close the document instance. -document.save("TableWithHeaderRow.docx",FormatType.Docx); +document.save("TableWithHeaderRow.docx", FormatType.Docx); document.close(); {% endhighlight %} @@ -692,33 +658,35 @@ document.close(); ## Keeping rows from breaking across pages -You can enable or disable the table row content to split across multiple pages, when the row contents do not fit in a previous page. +You can enable or disable the table row content to split across multiple pages when the row contents do not fit in a previous page. The following code example illustrates how to disable all the table rows from splitting across multiple pages. {% tabs %} {% highlight JAVA %} -//Creates an instance of WordDocument class. +//Create an instance of WordDocument class. WordDocument document = new WordDocument("Template.docx"); WSection section = document.getSections().get(0); WTable table = section.getTables().get(0); //Disable breaking across pages for all rows in the table. -for(Object row_tempObj : table.getRows()) -{ - WTableRow row = (WTableRow)row_tempObj; - row.getRowFormat().setIsBreakAcrossPages(false); +for (Object row_tempObj : table.getRows()) { + + WTableRow row = (WTableRow) row_tempObj; + row.getRowFormat().setIsBreakAcrossPages(false); } //Save and close the document instance. -document.save("Result.docx",FormatType.Docx); +document.save("Result.docx", FormatType.Docx); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} + + ## Iterating through table elements -The following code example illustrates how to iterate through the table and apply back color to a particular cell. +The following code example illustrates how to iterate through the table and apply a background color to a particular cell. {% tabs %} @@ -728,34 +696,34 @@ WordDocument document = new WordDocument("Template.docx"); WSection section = document.getSections().get(0); WTable table = section.getTables().get(0); //Iterate the rows of the table. -for(Object row_tempObj : table.getRows()) -{ - WTableRow row = (WTableRow)row_tempObj; - //Iterate through the cells of rows. - for(Object cell_tempObj : row.getCells()) - { - WTableCell cell = (WTableCell)cell_tempObj; - //Iterate through the paragraphs of the cell. - for(Object paragraph_tempObj : cell.getParagraphs()) - { - WParagraph paragraph = (WParagraph)paragraph_tempObj; - //When the paragraph contains text Panda then apply green as back color to cell. - if(paragraph.getText().contains("panda")) - cell.getCellFormat().setBackColor(ColorSupport.getGreen()); - } - } +for (Object row_tempObj : table.getRows()) { + + WTableRow row = (WTableRow) row_tempObj; + //Iterate through the cells of rows. + for (Object cell_tempObj : row.getCells()) { + + WTableCell cell = (WTableCell) cell_tempObj; + //Iterate through the paragraphs of the cell. + for (Object paragraph_tempObj : cell.getParagraphs()) { + + WParagraph paragraph = (WParagraph) paragraph_tempObj; + //When the paragraph contains text "Panda" then apply green as the background color to the cell. + if (paragraph.getText().contains("Panda")) + cell.getCellFormat().setBackColor(ColorSupport.getGreen()); + } + } } //Save and close the document instance. -document.save("Sample.docx",FormatType.Docx); +document.save("Sample.docx", FormatType.Docx); document.close(); -document.Close(); + {% endhighlight %} {% endtabs %} ## Removing the table -You can remove a table from a text body by its instance or by its index position in the text body item collection. The following code example shows how to remove a table in Word document. +You can remove a table from a text body by its instance or by its index position in the text body item collection. The following code example shows how to remove a table in a Word document. {% tabs %} @@ -769,7 +737,7 @@ WTable table = section.getTables().get(0); //Remove a table from the text body. section.getBody().getChildEntities().remove(table); //Save the Word document. -document.save("Sample.docx",FormatType.Docx); +document.save("Sample.docx", FormatType.Docx); //Close the document. document.close(); {% endhighlight %} diff --git a/java-file-formats/word-library/working-with-word-document.md b/java-file-formats/word-library/working-with-word-document.md index 9f40f20..67c98ce 100644 --- a/java-file-formats/word-library/working-with-word-document.md +++ b/java-file-formats/word-library/working-with-word-document.md @@ -1,381 +1,381 @@ --- -title: Working with Word document | DocIO | Syncfusion -description: Learn about combining multiple Word documents as one, printing Word document, applying styles, document properties, & iterating through DOM elements +title: Working with Word Document | DocIO | Syncfusion +description: Learn about combining multiple Word documents into one, printing Word documents, applying styles, document properties, and iterating through DOM elements platform: java-file-formats control: Word library documentation: UG --- -# Working with Word document +# Working with Word Document -## Iterating through document elements +## Iterating Through Document Elements -The following are the important points to be remembered while iterating the document elements +The following are the important points to remember while iterating through the document elements: -* Document consists of one or more sections. -* Section contains the contents present in Headers, Footers and main document through the instances of `WTextBody`. -* `WTextBody` contains three type of elements – either paragraph, table or block content control. +* A document consists of one or more sections. +* A section contains the contents present in headers, footers, and the main document through instances of `WTextBody`. +* `WTextBody` contains three types of elements – either paragraph, table, or block content control. -The following code example shows how to iterate throughout the Word document and remove the paragraph with a particular style. +The following code example shows how to iterate through a Word document and remove the paragraph with a particular style. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Open an existing document from file system through constructor of WordDocument class. +// Open an existing document from the file system through the constructor of the WordDocument class. WordDocument document = new WordDocument("TestDocument.docx"); -//Process the body contents for each section in the Word document. -for(Object section_tempObj : document.getSections()) -{ - //Access the Body of section where all the contents in document are apart. - WSection section = (WSection)section_tempObj; - WTextBody sectionBody = section.getBody(); - iterateTextBody(sectionBody); - //Consider that OddHeader and OddFooter are applied to this document. - //Iterate through the TextBody of OddHeader and OddFooter. - WHeadersFooters headersFooters = section.getHeadersFooters(); - iterateTextBody(headersFooters.getOddHeader()); - iterateTextBody(headersFooters.getOddFooter()); +// Process the body contents for each section in the Word document. +for (Object section_tempObj : document.getSections()) { + + // Access the body of the section where all the contents in the document are located. + WSection section = (WSection) section_tempObj; + WTextBody sectionBody = section.getBody(); + iterateTextBody(sectionBody); + // Consider that OddHeader and OddFooter are applied to this document. + // Iterate through the TextBody of OddHeader and OddFooter. + WHeadersFooters headersFooters = section.getHeadersFooters(); + iterateTextBody(headersFooters.getOddHeader()); + iterateTextBody(headersFooters.getOddFooter()); } -//Save and close the document instance. +// Save and close the document instance. document.save("Result.docx"); document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} The following code example provides supporting methods for the above code. -{% tabs %} +{% tabs %} {% highlight JAVA %} -private void iterateTextBody(WTextBody textBody)throws Exception -{ - //Iterate through each of the child items of WTextBody. - for(int i = 0;i You can use Content Type Properties only in documents that are saved in the DOCX or WordML Format. +N> You can use Content Type Properties only in documents that are saved in the DOCX or WordML format. -### Accessing and modifying the Content Type Properties +### Accessing and Modifying the Content Type Properties You can access and modify the value of existing metadata in the Word document (DOCX, WordML). -The following code example explains how to access and modify the value of an existing metadata in the Word document. -{% tabs %} +The following code example explains how to access and modify the value of existing metadata in the Word document. + + +{% tabs %} {% highlight JAVA %} -// Loads the template document +// Load the template document. WordDocument document = new WordDocument("Template.docx"); -// Processes the metaproperty collection in the Word document +// Process the metaproperty collection in the Word document. MetaProperties metaProperties = document.getContentTypeProperties(); -// Iterates through each of the child items of metaproperties -for (int i = 0; i < metaProperties.getCount(); i++) -{ - // Checks for particular display name of meta data and modifies its value - switch (metaProperties.get(i).getDisplayName()) - { - case "ProgressStatus": - if (metaProperties.get(i).getType() == MetaPropertyType.Text && !metaProperties.get(i).getIsReadOnly()) - metaProperties.get(i).setValue("Completed"); - break; - case "Reviewed": - if (metaProperties.get(i).getType() == MetaPropertyType.Boolean && !metaProperties.get(i).getIsReadOnly()) - metaProperties.get(i).setValue(true); - break; - case "Date": - if (metaProperties.get(i).getType() == MetaPropertyType.DateTime && !metaProperties.get(i).getIsReadOnly()) - metaProperties.get(i).setValue(LocalDateTime.now(ZoneId.of("UTC"))); - break; - case "Salary": - if ((metaProperties.get(i).getType() == MetaPropertyType.Number || metaProperties.get(i).getType() == MetaPropertyType.Currency) && !metaProperties.get(i).getIsReadOnly()) - metaProperties.get(i).setValue(12000); - break; - case "Url": - if (metaProperties.get(i).getType() == MetaPropertyType.Url && !metaProperties.get(i).getIsReadOnly()) - { - String[] value = { "https://www.syncfusion.com", "Syncfusion page" }; - metaProperties.get(i).setValue(value); - } - break; - case "User": - if (metaProperties.get(i).getType() == MetaPropertyType.User && !metaProperties.get(i).getIsReadOnly()) - { - String[] value = { "1234", "Syncfusion" }; - metaProperties.get(i).setValue(value); - } - break; - default: - break; - } +// Iterate through each of the child items of metaproperties. +for (int i = 0; i < metaProperties.getCount(); i++) { + + // Check for particular display name of metadata and modify its value. + switch (metaProperties.get(i).getDisplayName()) { + + case "ProgressStatus": + if (metaProperties.get(i).getType() == MetaPropertyType.Text && !metaProperties.get(i).getIsReadOnly()) + metaProperties.get(i).setValue("Completed"); + break; + case "Reviewed": + if (metaProperties.get(i).getType() == MetaPropertyType.Boolean && !metaProperties.get(i).getIsReadOnly()) + metaProperties.get(i).setValue(true); + break; + case "Date": + if (metaProperties.get(i).getType() == MetaPropertyType.DateTime && !metaProperties.get(i).getIsReadOnly()) + metaProperties.get(i).setValue(LocalDateTime.now(ZoneId.of("UTC")); + break; + case "Salary": + if ((metaProperties.get(i).getType() == MetaPropertyType.Number || metaProperties.get(i).getType() == MetaPropertyType.Currency) && !metaProperties.get(i).getIsReadOnly()) + metaProperties.get(i).setValue(12000); + break; + case "Url": + if (metaProperties.get(i).getType() == MetaPropertyType.Url && !metaProperties.get(i).getIsReadOnly()) { + + String[] value = {"https://www.syncfusion.com", "Syncfusion page"}; + metaProperties.get(i).setValue(value); + } + break; + case "User": + if (metaProperties.get(i).getType() == MetaPropertyType.User && !metaProperties.get(i).getIsReadOnly()) { + + String[] value = {"1234", "Syncfusion"}; + metaProperties.get(i).setValue(value); + } + break; + default: + break; + } } -// Saves the Word document +// Save the Word document. document.save("Sample.docx", FormatType.Docx); -// Closes the document +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} - -## Setting the Background for a Word document +{% endtabs %} + +## Setting the Background for a Word Document -Essential® DocIO allows to apply background such as color, gradient and picture to the Word document. A background of a Word document is represented by `Background` property of `WordDocument' class. +Essential® DocIO allows you to apply backgrounds such as color, gradient, and picture to the Word document. A background of a Word document is represented by the `Background` property of the `WordDocument` class. -The following code illustrates how to apply gradient as background to the document. +The following code illustrates how to apply a gradient as a background to the document. {% tabs %} {% highlight JAVA %} -//Create a new Word document. +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document. +// Add a new section to the document. WSection section = (WSection) document.addSection(); -//Add new paragraph to the section +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Append text to the paragraph. +// Append text to the paragraph. paragraph.appendText("Sample for applying document background"); -//Set the background type as gradient. +// Set the background type as gradient. document.getBackground().setType(BackgroundType.Gradient); -//Set color for gradient. +// Set the color for the gradient. document.getBackground().getGradient().setColor1(ColorSupport.getLightGray()); document.getBackground().getGradient().setColor2(ColorSupport.getLightGreen()); -//Set the shading style . +// Set the shading style. document.getBackground().getGradient().setShadingStyle(GradientShadingStyle.DiagonalUp); document.getBackground().getGradient().setShadingVariant(GradientShadingVariant.ShadingDown); -//Save the document. +// Save the document. document.save("Sample.docx", FormatType.Docx); -//Close the document. +// Close the document. document.close(); {% endhighlight %} -{% endtabs %} +{% endtabs %} -The following code illustrates how to apply image as background for the document. +The following code illustrates how to apply an image as a background for the document. -{% tabs %} +{% tabs %} {% highlight JAVA %} -//Create a new Word document +// Create a new Word document. WordDocument document = new WordDocument(); -//Add new section to the document +// Add a new section to the document. IWSection section = document.addSection(); -//Add new paragraph to the section +// Add a new paragraph to the section. IWParagraph paragraph = section.addParagraph(); -//Append text to the paragraph +// Append text to the paragraph. paragraph.appendText("Sample for applying document background"); -//Set the background type as picture +// Set the background type as picture. document.getBackground().setType(BackgroundType.Picture); MemoryStreamSupport inputStream = new MemoryStreamSupport( new FileInputStream(new File("Image.png"))); -document.getBackground().setPicture (inputStream.toArray()); -//Save the document +document.getBackground().setPicture(inputStream.toArray()); +// Save the document. document.save("Sample.docx", FormatType.Docx); -//Close the document +// Close the document. document.close(); {% endhighlight %} {% endtabs %} -## Working with Alternate chunks +## Working with Alternate Chunks + +Updating alternate chunks in the Word document imports the content from the embedded alternate chunk into the main document. When saving the Word document containing alternate chunks as a DOCX format document, the alternate chunk content is preserved by default. However, when saving as DOC format or other formats, the alternate chunk content will not be preserved. You can use the `updateAlternateChunks` method to preserve the alternate chunk content by importing it into the main document. -Updating Alternate chunk in the Word document, imports the content from the embedded alternate chunk into the main document. When saving the Word document containing alternate chunk as DOCX format document, the alternate chunk content preserved by default. But, when saving as DOC format or other formats, the alternate chunk content will not be preserved. You can use `updateAlternateChunks` method to preserve the alternate chunk content by importing into the main document. +The following examples show how to update the alternate chunk in the Word document. -The following examples show how to update the alternate chunk in the word document. -{% tabs %} +{% tabs %} + + + {% highlight JAVA %} -//Open an existing document from file system through constructor of WordDocument class. -try(WordDocument document = new WordDocument("Sample.docx",FormatType.Docx)) -{ - //Update the alternate chunks in the document - document.updateAlternateChunks(); - //Save and closes the document instance - document.save("Result.docx"); +// Open an existing document from the file system through the constructor of the WordDocument class. +try (WordDocument document = new WordDocument("Sample.docx", FormatType.Docx)) { + + // Update the alternate chunks in the document. + document.updateAlternateChunks(); + // Save and close the document instance. + document.save("Result.docx"); } {% endhighlight %} -{% endtabs %} +{% endtabs %} \ No newline at end of file