Load document from URL
Leave feedback
The following code snippet shows how to convert a document from an URL:
const fetch = require('node-fetch');
async function fetchUrl(url) {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`URL fetch error: ${response.statusText}`);
}
const stream = response.body;
return stream;
} catch (error) {
throw new Error(error);
}
}
const url = 'https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java/blob/master/Examples/Resources/SampleFiles/sample.docx?raw=true'
try {
const stream = await fetchUrl(url)
const converter = new groupdocs.conversion.Converter(stream);
const convertOptions = new groupdocs.conversion.PdfConvertOptions();
converter.convert('loadDocumentFromUrl.pdf', convertOptions);
}catch(e){
throw new Error(e);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.