@@ -76,32 +76,64 @@ The following way illustrates how to convert the document as PDF:
76
76
* Using Save API in server-side, you can convert the sfdt to stream.
77
77
* Finally, convert the stream to PDF using ` Syncfusion.DocIORenderer.Net.Core ` library.
78
78
79
+ ``` csharp
80
+ [AcceptVerbs (" Post" )]
81
+ [HttpPost ]
82
+ [EnableCors (" AllowAllOrigins" )]
83
+ [Route (" ExportPdf" )]
84
+ public void ExportPdf ([FromBody ]SaveParameter data )
85
+ {
86
+ // Converts the sfdt to stream
87
+ Stream document = WordDocument .Save (data .content , FormatType .Docx );
88
+ Syncfusion .DocIO .DLS .WordDocument doc = new Syncfusion .DocIO .DLS .WordDocument (document , Syncfusion .DocIO .FormatType .Docx );
89
+ // Instantiation of DocIORenderer for Word to PDF conversion
90
+ DocIORenderer render = new DocIORenderer ();
91
+ // Converts Word document into PDF document
92
+ PdfDocument pdfDocument = render .ConvertToPDF (doc );
93
+ // Saves the document to server machine file system, you can customize here to save into databases or file servers based on requirement.
94
+ FileStream fileStream = new FileStream (" sample.pdf" , FileMode .OpenOrCreate , FileAccess .ReadWrite );
95
+ // Saves the PDF file
96
+ pdfDocument .Save (fileStream );
97
+ pdfDocument .Close ();
98
+ fileStream .Close ();
99
+ document .Close ();
100
+ }
101
+
102
+ ```
103
+
79
104
{% elsif page.publishingplatform == "aspnet-mvc" %}
80
105
81
106
* Using Save API in server-side, you can convert the sfdt to stream.
82
107
* Finally, convert the stream to PDF using ` Syncfusion.DocToPdfConverter.AspNet.Mvc5 ` library.
83
108
84
- {% endif %}
85
-
86
- {% if page.publishingplatform == "aspnet-core" %}
87
-
88
- {% tabs %}
89
- {% highlight cshtml tabtitle="CSHTML" %}
90
- {% endhighlight %}
91
- {% highlight c# tabtitle="DocumentEditorController.cs" %}
92
- {% include code-snippet/document-editor/export-pdf/aspnet-core.cs %}
93
- {% endhighlight %}
94
- {% endtabs %}
95
-
96
- {% elsif page.publishingplatform == "aspnet-mvc" %}
97
-
98
- {% tabs %}
99
- {% highlight cshtml tabtitle="CSHTML" %}
100
- {% endhighlight %}
101
- {% highlight c# tabtitle="DocumentEditorController.cs" %}
102
- {% include code-snippet/document-editor/export-pdf/aspnet-mvc.cs %}
103
- {% endhighlight %}
104
- {% endtabs %}
109
+ ``` csharp
110
+
111
+ using Syncfusion .DocIO ;
112
+ using Syncfusion .DocIO .DLS ;
113
+ using Syncfusion .Pdf ;
114
+ using Syncfusion .DocToPDFConverter ;
115
+
116
+ [HttpPost ]
117
+ public void ExportPdf ([FromBody ] SaveParameter data )
118
+ {
119
+ // Converts the sfdt to stream
120
+ Stream document = WordDocument .Save (data .Content , Syncfusion .EJ2 .DocumentEditor .FormatType .Docx );
121
+ Syncfusion .DocIO .DLS .WordDocument doc = new Syncfusion .DocIO .DLS .WordDocument (document , Syncfusion .DocIO .FormatType .Docx );
122
+ // Instantiation of DocIORenderer for Word to PDF conversion
123
+ DocToPDFConverter render = new DocToPDFConverter ();
124
+ // Converts Word document into PDF document
125
+ PdfDocument pdfDocument = render .ConvertToPDF (doc );
126
+ string filePath = Path .Combine (AppDomain .CurrentDomain .BaseDirectory , " App_Data" , " sample.pdf" );
127
+ // Saves the document to server machine file system, you can customize here to save into databases or file servers based on requirement.
128
+ FileStream fileStream = new FileStream (filePath , FileMode .OpenOrCreate , FileAccess .ReadWrite );
129
+ // Saves the PDF file
130
+ pdfDocument .Save (fileStream );
131
+ pdfDocument .Close ();
132
+ fileStream .Close ();
133
+ document .Close ();
134
+ }
135
+
136
+ ```
105
137
{% endif %}
106
138
107
139
Get the complete working sample in this [ ` link ` ] ( https://github.com/SyncfusionExamples/Export-document-as-PDF-in-Document-Editor/ ) .
0 commit comments