Node.js Help
April 4, 2024
What is Node.jS used for
Node.js is a powerful tool that has transformed the landscape of web development, enabling developers to use JavaScript to build various applications
The Node.js PDF Library
import {PdfDocument} from "@ironsoftware/ironpdf";
(async () => {
// Create a PDF from an HTML string
const pdf = await PdfDocument.fromHtml("<h1>Hello World</h1>");
// Export the PDF to a file
await pdf.saveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external HTML assets: Images, CSS, and JavaScript.
const htmlContentWithAssets = "<img src='icons/iron.png'>";
const advancedPdf = await PdfDocument.fromHtml(htmlContentWithAssets);
// Save the PDF with loaded assets
await advancedPdf.saveAs("html-with-assets.pdf");
})();
import {PdfDocument} from "@ironsoftware/ironpdf";
(async () => {
// Render the HTML file
const pdf = await PdfDocument.fromHtml("example.html");
// Export the PDF document
await pdf.saveAs("output.pdf");
})();
import {PdfDocument} from "@ironsoftware/ironpdf";
(async () => {
// Render the web URL to PDF
const pdf = await PdfDocument.fromUrl("https://ironpdf.com/");
// Export the PDF document
await pdf.saveAs("url.pdf");
})();
import {PdfGenerator} from "@ironsoftware/ironpdf";
import fs from 'fs';
(async () => {
// Specify the directory path
const directoryPath = './images';
// Read the contents of the directory
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading directory:', err);
return;
}
// Filter file names to include only .jpg and .jpeg extensions
const jpegFiles = files.filter((file) =>
file.toLowerCase().endsWith('.jpg') || file.toLowerCase().endsWith('.jpeg')
);
// Construct full file paths for the filtered files
const filePaths = jpegFiles.map((file) => `${directoryPath}/${file}`);
// Converts the images to a PDF and save it.
const pdf = PdfGenerator.imageToPdf(filePaths).then(
(returnedPdf)=> {
returnedPdf.saveAs("composite.pdf");
});
// Also see PdfDocument.rasterizeToImageFiles() method to flatten a PDF to images or thumbnails
});
})();
April 4, 2024
What is Node.jS used for
Node.js is a powerful tool that has transformed the landscape of web development, enabling developers to use JavaScript to build various applications
30-day Trial Key instantly.
30-day Trial Key instantly.
Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Have a question? Get in touch with our development team.
Want to deploy IronPDF to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Want to deploy IronPDF to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Want to deploy IronPDF to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Want to deploy IronPDF to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Get started for FREE
No credit card required
Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
No credit card or account creation required
Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Get started for FREE
No credit card required
Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
No credit card or account creation required
Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Fully-functional product, get the key instantly
9 .NET API products for your office documents
Thank you!
Your license key has been delivered to the email provided. Contact us
24-Hour Upgrade Offer:
Save 50% on a
Professional Upgrade
Go Professional to cover 10 developers
and unlimited projects.
:
:
Professional
$600 USD
$299 USD
5 .NET Products for the Price of 2
Total Suite Value:
$7,192 USD
Upgrade price
TODAY
ONLY
$499 USD
After 24 Hrs
$1,098 USD