Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
convertapi
Advanced tools
Readme
The ConvertAPI helps in converting various file formats. Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes. Merge, Encrypt, Split, Repair and Decrypt PDF files and many other file manipulations. You can integrate it into your application in just a few minutes and use it easily.
npm install convertapi --save
The package needs to be configured with your account's secret key which is available at https://www.convertapi.com/a
Require it with the key's value:
var convertapi = require('convertapi')('your-api-secret');
Or using ES modules:
import ConvertAPI from 'convertapi';
const convertapi = new ConvertAPI('your-api-secret');
You can specify additional options, like proxy configuration and timeouts, when initializing the client:
var convertapi = require('convertapi')('your-api-secret', {
conversionTimeout: 60,
uploadTimeout: 60,
downloadTimeout: 60,
proxy: {
host: '127.0.0.1',
port: 9000,
auth: {
username: 'testuser',
password: 'secret'
}
},
keepAlive: true
});
If using ES module:
const convertapi = new ConvertAPI('your-api-secret', { conversionTimeout: 60 });
Convert file to PDF example. All supported file formats and options can be found here.
convertapi.convert('pdf', { File: '/path/to/my_file.docx' })
.then(function(result) {
// get converted file url
console.log("Converted file url: " + result.file.url);
// save to file
return result.file.save('/path/to/save/file.pdf');
})
.then(function(file) {
console.log("File saved: " + file);
})
.catch(function(e) {
console.error(e.toString());
});
Other result operations:
// save all result files to folder
result.saveFiles('/path/to/save/files').then(function(files) {
console.log("Files saved: " + files);
});
// get conversion cost
console.log("Conversion cost: " + result.conversionCost);
var resultPromise = convertapi.convert('pdf', { File: 'https://website/my_file.docx' });
var resultPromise = convertapi.convert('pdf', { File: 'https://website/my_file' }, 'docx');
ConvertAPI accepts additional conversion parameters depending on selected formats. All conversion parameters and explanations can be found here.
var resultPromise = convertapi.convert(
'pdf',
{
File: '/path/to/my_file.docx',
PageRange: '1-10',
PdfResolution: '150',
}
);
You can always check your conversion counts by fetching user information.
convertapi.getUser().then(function(info) {
console.log("ConversionsTotal: " + info.ConversionsTotal);
console.log("ConversionsConsumed: " + info.ConversionsConsumed);
});
convertapi
.convert('pdf', { File: 'https://website/my_file.docx' })
.catch(function(e) {
console.error(e.toString());
console.debug(e.request);
console.debug(e.response);
});
Set base_uri
parameter to use other service domains. Dedicated to the region domain list.
var convertapi = require('../lib')(process.env.CONVERT_API_SECRET, { baseUri: 'https://eu-v2.convertapi.com/' });
Find more advanced examples in the examples/ folder.
npm run clean
- Remove the lib/
directorynpm test
- Run tests with linting and coverage results.npm run test:only
- Run tests without linting or coverage.npm run test:watch
- You can even re-run tests on file changes!npm run test:prod
- Run tests with minified code.npm run test:examples
- Test written examples on pure JS for better understanding module usage.npm run lint
- Run ESlint with airbnb-confignpm run cover
- Get coverage report for your code.npm run build
- Babel will transpile ES6 => ES5 and minify the code.npm run prepublish
- Hook for npm. Do all the checks before publishing your module.Bug reports and pull requests are welcome on GitHub at https://github.com/ConvertAPI/convertapi-node. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
ConvertAPI Node.js Client is available as open source under the terms of the MIT License.
FAQs
Official convertapi.com API client
The npm package convertapi receives a total of 12,490 weekly downloads. As such, convertapi popularity was classified as popular.
We found that convertapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.