From 3fcac469f8edfc53d6e77bb8bd39ccf8cce2e3a1 Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Thu, 1 Feb 2024 12:04:22 +0530 Subject: [PATCH 1/5] Added apply math justification --- File-Formats/DocIO/Working-with-LaTeX.md | 58 +++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/File-Formats/DocIO/Working-with-LaTeX.md b/File-Formats/DocIO/Working-with-LaTeX.md index 4b60fefa3..a82c80f8a 100644 --- a/File-Formats/DocIO/Working-with-LaTeX.md +++ b/File-Formats/DocIO/Working-with-LaTeX.md @@ -1835,4 +1835,60 @@ document.Save("Result.docx", FormatType.Docx) {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/LaTeX-equations/Format%20Equation). \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/LaTeX-equations/Format%20Equation). + +## Apply Math Justification + +Apply justification, such as Left, Right, and more to the equation in a Word document using the .NET Word Library. + +The following code examples show how to apply the justification to equations in a Word document. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" %} +// Create a new Word document. +using (WordDocument document = new WordDocument()) +{ + //Add one section and one paragraph to the document. + document.EnsureMinimal(); + //Append an border box equation using LaTeX. + WMath math = document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}"); + //Apply math justification. + math.MathParagraph.Justification = MathJustification.Left; + using (FileStream outputFileStream = new FileStream("Output.docx", FileMode.Create, FileAccess.ReadWrite)) + { + //Save Word document. + document.Save(outputFileStream, FormatType.Docx); + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Create a new Word document. +WordDocument document = new WordDocument(); +//Add one section and one paragraph to the document. +document.EnsureMinimal(); +//Append an border box equation using LaTeX. +WMath math = document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}"); +//Apply math justification. +math.MathParagraph.Justification = MathJustification.Left; +//Save Word document. +document.Save("Output.docx", FormatType.Docx); +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Create a new Word document. +Dim document As New WordDocument() +'Add one section and one paragraph to the document. +document.EnsureMinimal() +'Append a border box equation using LaTeX. +Dim math As WMath = document.LastParagraph.AppendMath("\boxed{{x}^{2}+{y}^{2}={z}^{2}}") +'Apply math justification. +math.MathParagraph.Justification = MathJustification.Left +'Save Word document. +document.Save("Output.docx", FormatType.Docx) +{% endhighlight %} + +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/Apply-math-justification). From ce0110d4aebf0ff0470cdb8467868e8b8f3aab20 Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Thu, 1 Feb 2024 15:38:22 +0530 Subject: [PATCH 2/5] Added youtube link --- File-Formats/DocIO/Word-document/Split-Word-documents.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/File-Formats/DocIO/Word-document/Split-Word-documents.md b/File-Formats/DocIO/Word-document/Split-Word-documents.md index 77e346aa3..96c5cfeab 100644 --- a/File-Formats/DocIO/Word-document/Split-Word-documents.md +++ b/File-Formats/DocIO/Word-document/Split-Word-documents.md @@ -13,6 +13,9 @@ By using this feature, you can be able to split/extract the necessary parts from You can save the resultant document as a Word document (DOCX, WordML, DOC), PDF, image, HTML, RTF, and more. +To quickly start splitting Word documents, please check out this video: +{% youtube "https://www.youtube.com/watch?v=w9np2NSfq94" %} + ## Split by Section The following code example illustrates how to split the Word document by sections. From a6ef32e737df90c1eef44cf7df6e5409c1e8bc76 Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Fri, 2 Feb 2024 16:28:05 +0530 Subject: [PATCH 3/5] Updated markdown --- File-Formats/DocIO/Overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/DocIO/Overview.md b/File-Formats/DocIO/Overview.md index 5dbf3d5bb..96a59415f 100644 --- a/File-Formats/DocIO/Overview.md +++ b/File-Formats/DocIO/Overview.md @@ -19,7 +19,7 @@ It is a non-UI component that provides a full-fledged document instance model si * Support to [create Word document](https://help.syncfusion.com/file-formats/docio/getting-started) from scratch. * Support to open, modify and save existing Word documents. * Advanced [Mail merge](https://help.syncfusion.com/file-formats/docio/working-with-mail-merge) support with different data sources. -* Ability to create or edit Word 97-2003 and later version documents, and convert them to commonly used file formats such as [RTF](https://help.syncfusion.com/file-formats/docio/rtf), [WordML](https://help.syncfusion.com/file-formats/docio/word-file-formats#word-processing-xml-xml), [TXT](https://help.syncfusion.com/file-formats/docio/text), [HTML](https://help.syncfusion.com/file-formats/docio/html) and vice versa. +* Ability to create or edit Word 97-2003 and later version documents, and convert them to commonly used file formats such as [RTF](https://help.syncfusion.com/file-formats/docio/rtf), [WordML](https://help.syncfusion.com/file-formats/docio/word-file-formats#word-processing-xml-xml), [TXT](https://help.syncfusion.com/file-formats/docio/text), [HTML](https://help.syncfusion.com/file-formats/docio/html), [Markdown](https://help.syncfusion.com/file-formats/docio/convert-word-document-to-markdown-in-csharp) and vice versa. * Ability to export a Word document as an [Image](https://help.syncfusion.com/file-formats/docio/word-to-image), [PDF](https://help.syncfusion.com/file-formats/docio/word-to-pdf) file, and [EPUB](https://help.syncfusion.com/file-formats/docio/word-to-epub) in high quality. * Ability to [merge](https://help.syncfusion.com/file-formats/docio/word-document/merging-word-documents) and [split](https://help.syncfusion.com/file-formats/docio/word-document/split-word-documents) Word documents. * Support to [compare](https://help.syncfusion.com/file-formats/docio/word-document/compare-word-documents) two DOCX format documents. From 831e119f5f376975ca958ea5d5936ecb831e1c9c Mon Sep 17 00:00:00 2001 From: Deepak Raj Sundar Date: Mon, 5 Feb 2024 16:54:43 +0530 Subject: [PATCH 4/5] IN-179913 Added File-Formats/Release-Notes/v24.2.4.md along with its entry in File-Formats-toc.html --- File-Formats-toc.html | 2 +- File-Formats/Release-Notes/v24.2.4.md | 98 +++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 File-Formats/Release-Notes/v24.2.4.md diff --git a/File-Formats-toc.html b/File-Formats-toc.html index 68d09502d..088baa45a 100644 --- a/File-Formats-toc.html +++ b/File-Formats-toc.html @@ -1713,7 +1713,7 @@
  • Release Notes -
    • 2023 Volume 4 - v24.*
    • 2023 Volume 3 - v23.*
    • 2023 Volume 2 - v22.*
    • +
      • 2023 Volume 4 - v24.*
      • 2023 Volume 3 - v23.*
      • 2023 Volume 2 - v22.*
      • 2023 Volume 1 - v21.*
      • 2022 Volume 4 - v20.4.0.*
      • 2022 Volume 3 - v20.3.0.*
      • 2022 Volume 2 - v20.2.0.*
      • 2022 volume 1 - v20.1.0.*
      • 2021 Volume 4 - v19.4.0.*
      • 2021 volume 3 - v19.3.0.*
      • 2021 Volume 2 - v19.2.0.*
      • 2021 Volume 1 - v19.1.0.*
      • 2020 Volume 4 - v18.4.0.*
      • 2020 Volume 3 - v18.3.0.*
      • 2020 Volume 2 - v18.2.0.*
      • 2020 Volume 1 - v18.1.0.*
      • 2019 Volume 4 - v17.4.0.*
      • 2019 Volume 3 - v17.3.0.* diff --git a/File-Formats/Release-Notes/v24.2.4.md b/File-Formats/Release-Notes/v24.2.4.md new file mode 100644 index 000000000..5597d36d1 --- /dev/null +++ b/File-Formats/Release-Notes/v24.2.4.md @@ -0,0 +1,98 @@ +--- +title : Essential Studio for File Formats Weekly Nuget Release Release Notes +description : Essential Studio for File Formats Weekly Nuget Release Release Notes +platform : file-formats +documentation: ug +--- + +# Essential Studio for File Formats Release Notes + +{% include release-info.html date="February 06, 2024" version="v24.2.4" %} + + +## DocIO + +* [EJ2 ASP.NET Core Release Notes](https://ej2.syncfusion.com/aspnetcore/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [EJ2 ASP.NET MVC Release Notes](https://ej2.syncfusion.com/aspnetmvc/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [EJ2 Angular Release Notes](https://ej2.syncfusion.com/angular/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [Blazor Release Notes](https://blazor.syncfusion.com/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [EJ2 React Release Notes](https://ej2.syncfusion.com/react/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [EJ2 Vue Release Notes](https://ej2.syncfusion.com/vue/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [EJ2 JavaScript Release Notes](https://ej2.syncfusion.com/javascript/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [EJ2 TypeScript Release Notes](https://ej2.syncfusion.com/documentation/release-notes/24.2.4#docio){:target="_blank"} +* [.NET MAUI Release Notes](/maui/release-notes/v24.2.4#docio){:target="_blank"} +* [Xamarin.Forms Release Notes](/xamarin/release-notes/v24.2.4#docio){:target="_blank"} +* [Xamarin.Android Release Notes](/xamarin-android/release-notes/v24.2.4#docio){:target="_blank"} +* [Xamarin.iOS Release Notes](/xamarin-ios/release-notes/v24.2.4#docio){:target="_blank"} +* [Flutter Release Notes](/flutter/release-notes/v24.2.4#docio){:target="_blank"} +* [WinUI Release Notes](/winui/release-notes/v24.2.4#docio){:target="_blank"} +* [UWP Release Notes](/uwp/release-notes/v24.2.4#docio){:target="_blank"} +* [Windows Forms Release Notes](/windowsforms/release-notes/v24.2.4#docio){:target="_blank"} +* [WPF Release Notes](/wpf/release-notes/v24.2.4#docio){:target="_blank"} + + + +## PDF + +* [EJ2 ASP.NET Core Release Notes](https://ej2.syncfusion.com/aspnetcore/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [EJ2 ASP.NET MVC Release Notes](https://ej2.syncfusion.com/aspnetmvc/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [EJ2 Angular Release Notes](https://ej2.syncfusion.com/angular/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [Blazor Release Notes](https://blazor.syncfusion.com/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [EJ2 React Release Notes](https://ej2.syncfusion.com/react/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [EJ2 Vue Release Notes](https://ej2.syncfusion.com/vue/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [EJ2 JavaScript Release Notes](https://ej2.syncfusion.com/javascript/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [EJ2 TypeScript Release Notes](https://ej2.syncfusion.com/documentation/release-notes/24.2.4#pdf){:target="_blank"} +* [.NET MAUI Release Notes](/maui/release-notes/v24.2.4#pdf){:target="_blank"} +* [Xamarin.Forms Release Notes](/xamarin/release-notes/v24.2.4#pdf){:target="_blank"} +* [Xamarin.Android Release Notes](/xamarin-android/release-notes/v24.2.4#pdf){:target="_blank"} +* [Xamarin.iOS Release Notes](/xamarin-ios/release-notes/v24.2.4#pdf){:target="_blank"} +* [Flutter Release Notes](/flutter/release-notes/v24.2.4#pdf){:target="_blank"} +* [WinUI Release Notes](/winui/release-notes/v24.2.4#pdf){:target="_blank"} +* [UWP Release Notes](/uwp/release-notes/v24.2.4#pdf){:target="_blank"} +* [Windows Forms Release Notes](/windowsforms/release-notes/v24.2.4#pdf){:target="_blank"} +* [WPF Release Notes](/wpf/release-notes/v24.2.4#pdf){:target="_blank"} + + +## Presentation + +* [EJ2 ASP.NET Core Release Notes](https://ej2.syncfusion.com/aspnetcore/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [EJ2 ASP.NET MVC Release Notes](https://ej2.syncfusion.com/aspnetmvc/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [Blazor Release Notes](https://blazor.syncfusion.com/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [EJ2 Angular Release Notes](https://ej2.syncfusion.com/angular/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [EJ2 React Release Notes](https://ej2.syncfusion.com/react/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [EJ2 Vue Release Notes](https://ej2.syncfusion.com/vue/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [EJ2 JavaScript Release Notes](https://ej2.syncfusion.com/javascript/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [EJ2 TypeScript Release Notes](https://ej2.syncfusion.com/documentation/release-notes/24.2.4#presentation){:target="_blank"} +* [.NET MAUI Release Notes](/maui/release-notes/v24.2.4#presentation){:target="_blank"} +* [Xamarin.Forms Release Notes](/xamarin/release-notes/v24.2.4#presentation){:target="_blank"} +* [Xamarin.Android Release Notes](/xamarin-android/release-notes/v24.2.4#presentation){:target="_blank"} +* [Xamarin.iOS Release Notes](/xamarin-ios/release-notes/v24.2.4#presentation){:target="_blank"} +* [Flutter Release Notes](/flutter/release-notes/v24.2.4#presentation){:target="_blank"} +* [WinUI Release Notes](/winui/release-notes/v24.2.4#presentation){:target="_blank"} +* [Windows Forms Release Notes](/windowsforms/release-notes/v24.2.4#presentation){:target="_blank"} +* [WPF Release Notes](/wpf/release-notes/v24.2.4#presentation){:target="_blank"} +* [UWP Release Notes](/uwp/release-notes/v24.2.4#presentation){:target="_blank"} + + + +## XlsIO + +* [EJ2 ASP.NET Core Release Notes](https://ej2.syncfusion.com/aspnetcore/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [EJ2 ASP.NET MVC Release Notes](https://ej2.syncfusion.com/aspnetmvc/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [EJ2 Angular Release Notes](https://ej2.syncfusion.com/angular/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [Blazor Release Notes](https://blazor.syncfusion.com/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [EJ2 React Release Notes](https://ej2.syncfusion.com/react/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [EJ2 Vue Release Notes](https://ej2.syncfusion.com/vue/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [EJ2 JavaScript Release Notes](https://ej2.syncfusion.com/javascript/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [EJ2 TypeScript Release Notes](https://ej2.syncfusion.com/documentation/release-notes/24.2.4#xlsio){:target="_blank"} +* [.NET MAUI Release Notes](/maui/release-notes/v24.2.4#xlsio){:target="_blank"} +* [Xamarin.Forms Release Notes](/xamarin/release-notes/v24.2.4#xlsio){:target="_blank"} +* [Xamarin.Android Release Notes](/xamarin-android/release-notes/v24.2.4#xlsio){:target="_blank"} +* [Xamarin.iOS Release Notes](/xamarin-ios/release-notes/v24.2.4#xlsio){:target="_blank"} +* [Flutter Release Notes](/flutter/release-notes/v24.2.4#xlsio){:target="_blank"} +* [WinUI Release Notes](/winui/release-notes/v24.2.4#xlsio){:target="_blank"} +* [UWP Release Notes](/uwp/release-notes/v24.2.4#xlsio){:target="_blank"} +* [Windows Forms Release Notes](/windowsforms/release-notes/v24.2.4#xlsio){:target="_blank"} +* [WPF Release Notes](/wpf/release-notes/v24.2.4#xlsio){:target="_blank"} + + From f7957ab0720757bf501a296a15086c9123d75035 Mon Sep 17 00:00:00 2001 From: "sneha.biju" Date: Mon, 5 Feb 2024 19:46:39 +0530 Subject: [PATCH 5/5] Added ShowWarning and HTMLBodyContentAlone API content --- File-Formats/DocIO/html.md | 52 ++++++++++ File-Formats/DocIO/word-to-pdf.md | 164 ++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) diff --git a/File-Formats/DocIO/html.md b/File-Formats/DocIO/html.md index 17ec797a6..32b97bc6b 100644 --- a/File-Formats/DocIO/html.md +++ b/File-Formats/DocIO/html.md @@ -470,6 +470,58 @@ document.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/HTML-conversions/Customize-Word-to-HTML-conversion). + +### Export HTML with body content alone + +While saving a Word document as a HTML file using .NET Word Library, there is an option to save the HTML file with only the content within the tags, excluding other elements through HtmlExportBodyContentAlone API. + +The following code example illustrates how to export the HTML file with only the body content. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-Platform]" %} +//Load an existing Word document. +using (FileStream fileStreamPath = new FileStream("Input.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) +{ + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) + { + //Enable the flag, to save HTML with elements inside body tags alone. + document.SaveOptions.HtmlExportBodyContentAlone = true; + + using (FileStream outputFileStream = new FileStream("WordToHTML.html", FileMode.Create, FileAccess.ReadWrite)) + { + //Save Word document as HTML. + document.Save(outputFileStream, FormatType.Html); + } + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Loads an existing document +//Load an existing Word document. +WordDocument document = new WordDocument("Input.docx", FormatType.Docx); +//Enable the flag, to save HTML with elements inside body tags alone. +document.SaveOptions.HtmlExportBodyContentAlone = true; +//Saves the document as html file +document.Save(document, "WordtoHtml.html"); +document.Close(); +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Loads an existing document +Dim document As New WordDocument("Input.docx") +'Enable the flag, to save HTML with elements inside body tags alone. +document.SaveOptions.HtmlExportBodyContentAlone = true +'Saves the document as html file +document.Save(document, "WordtoHtml.html") +document.Close() +{% endhighlight %} + +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/HTML-conversions/Export-HTML-with-body-content) + ## Supported and unsupported items The following document elements and attributes are supported by DocIO in Word to HTML and HTML to Word conversions. diff --git a/File-Formats/DocIO/word-to-pdf.md b/File-Formats/DocIO/word-to-pdf.md index 253c451ee..e7d20ee68 100644 --- a/File-Formats/DocIO/word-to-pdf.md +++ b/File-Formats/DocIO/word-to-pdf.md @@ -2367,6 +2367,170 @@ In .NET Core and latest target, we have limitation in metafile. Refer {{'[here]( +## Show Warning for Unsupported Elements + +When converting a Word document to a PDF, the presence of unsupported elements in the input Word document can lead to preservation issues in the converted PDF. The .NET Word library (DocIO) contains [Warning](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocToPDFConverter.DocToPDFConverterSettings.html#Syncfusion_DocToPDFConverter_DocToPDFConverterSettings_Warning) API, which helps to detect and handle these unsupported elements during the conversion process. This API holds the information of unsupported elements once found in the input Word document. + +Users can display warning messages for the unsupported elements using the [WarningType](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.WarningInfo.html#Syncfusion_DocIO_DLS_WarningInfo_WarningType) during Word to PDF conversion. Users can set a flag to stop the conversion process based on the warning. + +The following code demonstrates how to stop conversion if the input Word document has an unsupported element like SmartArt during Word to PDF conversion. + + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (FileStream fileStream = new FileStream("Input.docx", FileMode.Open)) +{ + //Loads an existing Word document. + using (WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic)) + { + //Creates an instance of DocIORenderer. + using (DocIORenderer renderer = new DocIORenderer()) + { + renderer.Settings.Warning = new DocumentWarning(); + //Converts Word document into a PDF document. + using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument)) + { + //If the IsCanceled boolean is enabled, the input document will contain an unsupported element. + if (renderer.IsCanceled) + { + Console.WriteLine("The execution stopped due to unsupported element."); + Console.ReadKey(); + } + else + { + //Saves the PDF file. + FileStream outputFile = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); + pdfDocument.Save(outputFile); + outputFile.Dispose(); + Console.WriteLine("Success"); + } + } + } + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +WordDocument wordDocument = new WordDocument("Input.docx"); +DocToPDFConverter converter = new DocToPDFConverter(); +converter.Settings.Warning = new DocumentWarning(); +PdfDocument pdfDocument = converter.ConvertToPDF(document); +//If the IsCanceled boolean is enabled, the input document will contain an unsupported element. +if (converter.IsCanceled) +{ + Console.WriteLine("The execution stopped due to unsupported element."); + Console.ReadKey(); +} +else +{ + //Saves the PDF file. + FileStream outputFile = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); + pdfDocument.Save(outputFile); + outputFile.Dispose(); + Console.WriteLine("Success"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Dim wordDocument As New WordDocument("Input.docx") +Dim converter As New DocToPDFConverter() +converter.Settings.Warning = New DocumentWarning() +Dim pdfDocument As PdfDocument = converter.ConvertToPDF(document) + +' If the IsCanceled boolean is enabled, the input document will contain an unsupported element. +If converter.IsCanceled Then + Console.WriteLine("The execution stopped due to unsupported element.") + Console.ReadKey() +Else + ' Saves the PDF file. + Using outputFile As New FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite) + pdfDocument.Save(outputFile) + Console.WriteLine("Success") + End Using +End If +{% endhighlight %} + +{% endtabs %} + +The following code demonstrates how to initialize the [Warning](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocToPDFConverter.DocToPDFConverterSettings.html#Syncfusion_DocToPDFConverter_DocToPDFConverterSettings_Warning) API and display warning messages for all unsupported elements in the input document. Additionally, this code shows how to set a flag to stop Word to PDF conversion if an unsupported element is identified. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" %} +public class DocumentWarning : IWarning +{ + public bool ShowWarnings(List warningInfo) + { + bool isContinueConversion = true; + foreach (WarningInfo warning in warningInfo) + { + //Based on the WarningType enumeration, you can do your manipulation. + //Skip the Word to PDF conversion by setting the isContinueConversion value to false. + //To stop execution if the input document has a SmartArt. + if (warning.WarningType == WarningType.SmartArt) + isContinueConversion = false; + + //Warning messages for unsupported elements in the input document. + Console.WriteLine("The input document contains " + warning.WarningType + " unsupported element."); + } + return isContinueConversion; + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +public class DocumentWarning : IWarning +{ + public bool ShowWarnings(List warningInfo) + { + bool isContinueConversion = true; + foreach (WarningInfo warning in warningInfo) + { + //Based on the WarningType enumeration, you can do your manipulation. + //Skip the Word to PDF conversion by setting the isContinueConversion value to false. + //To stop execution if the input document has a SmartArt. + if (warning.WarningType == WarningType.SmartArt) + isContinueConversion = false; + + //Warning messages for unsupported elements in the input document. + Console.WriteLine("The input document contains " + warning.WarningType + " unsupported element."); + } + return isContinueConversion; + } +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Public Class DocumentWarning + Implements IWarning + + Public Function ShowWarnings(warningInfo As List(Of WarningInfo)) As Boolean Implements IWarning.ShowWarnings + Dim isContinueConversion As Boolean = True + + For Each warning As WarningInfo In warningInfo + ' Based on the WarningType enumeration, you can perform your manipulation. + ' Skip the Word to PDF conversion by setting the isContinueConversion value to false. + ' To stop execution if the input document has a SmartArt. + If warning.WarningType = WarningType.SmartArt Then + isContinueConversion = False + End If + + ' Warning messages for unsupported elements in the input document. + Console.WriteLine("The input document contains " & warning.WarningType & " unsupported element.") + Next + + Return isContinueConversion + End Function +End Class +{% endhighlight %} + +{% endtabs %} + +T> Using the above Warning API, handle logic to identify the documents with unsupported elements and notify the end users to use supported elements for good preservation in the output PDF. + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Word-to-PDF-Conversion/Show-Warning-for-unsupported-elements) + ## See Also * [How to perform font substitution in Word to PDF conversion](https://support.syncfusion.com/kb/article/7499/how-to-perform-font-substitution-in-word-to-pdf-conversion)