Currently I am using HtmlToPdfConverter in my project to convert HTML into PDF. I am trying to add support for Word conversion too... Does DocIO have support for Html to Docx (With Javascript) or PDF to Docx (With editable text NOT as image)...?
|
Does DocIO have support for Html to Docx (With Javascript) |
DocumenteditorContainer : Toolbar options open html document, in backend convert html to Sfdt and load the same in Documenteditor.
Also, if you want to create custom button, in DocumentEditor, you can open html file using Syncfusion Docio library. So, we need to write server side WebAPI either in Asp.Net MVC or Core to achieve your requirement. To open html file, we need to use Syncfusion.Docio library to convert the stream to document editor internal structure. Then convert the internal structure to json. Finally, open that json in document editor.
Sample code snippet to open html in document editor.
| |
|
PDF to Docx (With editable text NOT as image)...? |
At present, we do not have direct support for PDF to Word conversion. We have already logged a feature request for converting PDF files to editable Word documents. We do not have any immediate plans to implement this feature. We usually have an interval of at least three months between releases and at the planning stage for every release cycle, we review all open features. We will consider this feature and update the details once it is implemented.
You can track the status of this feature request from the following feedback link,
|
Hi Gowthamraj,
Thanks for reply. By "With Javascript" in HTML to Docx request I meant to render the HTML after processing Javascript like in HTML to PDF Converter.
|
saveAsPDF(): void {
var obj=this;
this.container.documentEditor.saveAsBlob('Docx').then(function (exportedDocument) {
// The blob can be processed further
var fileName = (obj.container.documentEditor.documentName ? obj.container.documentEditor.documentName : 'Untitled') + ".pdf";
var formData = new FormData();
formData.append('data', exportedDocument);
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'http://localhost:50574/api/DocumentEditor/DocToPDF?fileName=' + fileName, true);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200 || httpRequest.status === 304) {
alert('Document saved successFully');
} else {
//alert('Fail to save the document');
}
}
}
httpRequest.send(formData);
});
} |
|
[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("DocToPDF")]
public string DocToPDF(string fileName)
{
Stream stream = new MemoryStream();
IFormFile file = HttpContext.Request.Form.Files[0];
file.CopyTo(stream);
stream.Position = 0;
Syncfusion.DocIO.DLS.WordDocument wordDocument = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx);
//Instantiation of DocIORenderer for Word to PDF conversion
DocIORenderer render = new DocIORenderer();
//Converts Word document into PDF document
PdfDocument pdfDocument = render.ConvertToPDF(wordDocument);
//Saves the PDF file
FileStream fileStream = new FileStream(_hostingEnvironment.ContentRootPath + "\\App_Data\\" + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
pdfDocument.Save(fileStream);
//Closes the instance of PDF document object
render.Dispose();
wordDocument.Dispose();
pdfDocument.Dispose();
fileStream.Close();
return "Success";
} |