admin管理员组文章数量:1430924
My requirement is to convert a word file(docx) to a pdf file in the client side before sending the file to the server.
I have already found solutions to implement this using c# and nodejs, but it doesn't meet my requirement since I'm not using nodejs in my project and to convert using c# I need to send the files to the server.
Any alternate methods such as converting the word file to html or a canvas before exporting as a pdf is fine.
My requirement is to convert a word file(docx) to a pdf file in the client side before sending the file to the server.
I have already found solutions to implement this using c# and nodejs, but it doesn't meet my requirement since I'm not using nodejs in my project and to convert using c# I need to send the files to the server.
Any alternate methods such as converting the word file to html or a canvas before exporting as a pdf is fine.
- Sorry, i don't know neither could i find such thing. – Bárbara Peres Commented Oct 13, 2019 at 9:50
1 Answer
Reset to default 1gamage,
I am not sure if you are still looking for answer to this question but let me try to provide solution anyway for anyone in same scenario.
As you are not looking for nodejs solution, We can solve this by calling external api endpoint which does this work for us.
In one of my previous project I have used PDF.co library to extract data from PDF. PDF.co also has endpoint to convert Documents such as doc, docx to PDF.
Following is the pdf.co api endpoint and code snippets for converting doc to pdf.
API Endpoint: https://api.pdf.co/v1/pdf/convert/from/doc
Sample Request:
{
"url": "https://bytescout-.s3-us-west-2.amazonaws./files/demo-files/cloud-api/doc-to-pdf/sample.docx",
"pages": "0-",
"name": "result.pdf"
}
Sample Output
{
"url": "https://pdf-temp-files.s3.amazonaws./ce9c93849b604956bc9abadb0ce4b0b3/result.pdf",
"pageCount": 1,
"error": false,
"status": 200,
"name": "result.pdf",
"remainingCredits": 930668,
"credits": 21
}
Following is postman generated code snippet in case you want to consume this using jQuery.
var settings = {
"url": "https://api.pdf.co/v1/pdf/convert/from/doc",
"method": "POST",
"timeout": 0,
"headers": {
"x-api-key": "--your-pdf-co-api-key--",
"Content-Type": "application/json"
},
"data": JSON.stringify({"url":"https://bytescout-.s3-us-west-2.amazonaws./files/demo-files/cloud-api/doc-to-pdf/sample.docx","pages":"0-","name":"result.pdf"}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
Explore more about this API endpoint with documentation at here. https://apidocs.pdf.co/23-pdf-from-doc-docx-rtf-txt-xps-document-to-pdf
Thank you!
本文标签: Convert Word file to PDF using JavascriptJqueryStack Overflow
版权声明:本文标题:Convert Word file to PDF using JavascriptJquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745546536a2662729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论