You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: File-Formats/DocIO/html.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -470,6 +470,58 @@ document.Close()
470
470
471
471
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/HTML-conversions/Customize-Word-to-HTML-conversion).
472
472
473
+
474
+
### Export HTML with body content alone
475
+
476
+
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 <body> tags, excluding other elements through HtmlExportBodyContentAlone API.
477
+
478
+
The following code example illustrates how to export the HTML file with only the body content.
479
+
480
+
{% tabs %}
481
+
482
+
{% highlight c# tabtitle="C# [Cross-Platform]" %}
483
+
//Load an existing Word document.
484
+
using (FileStream fileStreamPath = new FileStream("Input.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
485
+
{
486
+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
487
+
{
488
+
//Enable the flag, to save HTML with elements inside body tags alone.
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/HTML-conversions/Export-HTML-with-body-content)
524
+
473
525
## Supported and unsupported items
474
526
475
527
The following document elements and attributes are supported by DocIO in Word to HTML and HTML to Word conversions.
Copy file name to clipboardExpand all lines: File-Formats/DocIO/word-to-pdf.md
+164Lines changed: 164 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2367,6 +2367,170 @@ In .NET Core and latest target, we have limitation in metafile. Refer {{'[here](
2367
2367
</tr>
2368
2368
</table>
2369
2369
2370
+
## Show Warning for Unsupported Elements
2371
+
2372
+
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.
2373
+
2374
+
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.
2375
+
2376
+
The following code demonstrates how to stop conversion if the input Word document has an unsupported element like SmartArt during Word to PDF conversion.
2377
+
2378
+
2379
+
{% tabs %}
2380
+
2381
+
{% highlight c# tabtitle="C# [Cross-platform]" %}
2382
+
using (FileStream fileStream = new FileStream("Input.docx", FileMode.Open))
2383
+
{
2384
+
//Loads an existing Word document.
2385
+
using (WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic))
2386
+
{
2387
+
//Creates an instance of DocIORenderer.
2388
+
using (DocIORenderer renderer = new DocIORenderer())
2389
+
{
2390
+
renderer.Settings.Warning = new DocumentWarning();
2391
+
//Converts Word document into a PDF document.
2392
+
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
2393
+
{
2394
+
//If the IsCanceled boolean is enabled, the input document will contain an unsupported element.
2395
+
if (renderer.IsCanceled)
2396
+
{
2397
+
Console.WriteLine("The execution stopped due to unsupported element.");
2398
+
Console.ReadKey();
2399
+
}
2400
+
else
2401
+
{
2402
+
//Saves the PDF file.
2403
+
FileStream outputFile = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);
Dim wordDocument As New WordDocument("Input.docx")
2437
+
Dim converter As New DocToPDFConverter()
2438
+
converter.Settings.Warning = New DocumentWarning()
2439
+
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(document)
2440
+
2441
+
' If the IsCanceled boolean is enabled, the input document will contain an unsupported element.
2442
+
If converter.IsCanceled Then
2443
+
Console.WriteLine("The execution stopped due to unsupported element.")
2444
+
Console.ReadKey()
2445
+
Else
2446
+
' Saves the PDF file.
2447
+
Using outputFile As New FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite)
2448
+
pdfDocument.Save(outputFile)
2449
+
Console.WriteLine("Success")
2450
+
End Using
2451
+
End If
2452
+
{% endhighlight %}
2453
+
2454
+
{% endtabs %}
2455
+
2456
+
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.
2457
+
2458
+
{% tabs %}
2459
+
2460
+
{% highlight c# tabtitle="C# [Cross-platform]" %}
2461
+
public class DocumentWarning : IWarning
2462
+
{
2463
+
public bool ShowWarnings(List<WarningInfo> warningInfo)
2464
+
{
2465
+
bool isContinueConversion = true;
2466
+
foreach (WarningInfo warning in warningInfo)
2467
+
{
2468
+
//Based on the WarningType enumeration, you can do your manipulation.
2469
+
//Skip the Word to PDF conversion by setting the isContinueConversion value to false.
2470
+
//To stop execution if the input document has a SmartArt.
2471
+
if (warning.WarningType == WarningType.SmartArt)
2472
+
isContinueConversion = false;
2473
+
2474
+
//Warning messages for unsupported elements in the input document.
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.
2531
+
2532
+
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)
2533
+
2370
2534
## See Also
2371
2535
2372
2536
*[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)
0 commit comments