PDF 도구 How to Convert PDF to Image in NodeJS 커티스 차우 업데이트됨:6월 22, 2025 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 Converting PDF documents to image formats such as PNG, JPG, GIF can be a valuable feature in various applications, ranging from document management systems to image processing software. In this article, we will learn how to convert PDF to image files using Node.js. We will leverage the power of a popular npm (Node Package Manager) package called pdf-poppler to achieve this task. Prerequisites First, make sure you have Node.js and npm (Node Package Manager) installed on your machine. You can check Node installations by running the following commands in your command prompt (cmd): node --version npm --version node --version npm --version SHELL If it is not installed, you will need to download it from the Node.js website. Setting Up the Project To get started, create a new directory for your project. For this tutorial, let's name this directory NodeJS_PDFtoImage. Next, navigate to it in the command prompt and initialize a new Node.js project by running: npm init -y npm init -y SHELL Running the above command will produce a package.json file that will allow us to install our project's required dependencies. Installing Dependencies The dependency we will use is pdf-poppler, a package that provides an easy-to-use API for converting PDFs to images. Install it by running the following command in Windows PowerShell or Command Prompt: npm install pdf-poppler npm install pdf-poppler SHELL All done! Let's write the logic to convert PDF to images. Converting PDF to Image File Once the installation is complete, create a new file in our project's root directory and name it pdfToImage.js. Open the file in your preferred text editor, and add the required modules: const pdfPoppler = require('pdf-poppler'); A sample 28-page PDF file is shown below. Next, define a function called convertPdfToImage that takes in the path to the PDF file (pdfPath) and the output directory path (outputPath). This function will convert our sample PDF document into images. async function convertPdfToImage(pdfPath, outputPath) { const options = { format: 'jpeg', // You can choose other formats like png or tiff out_dir: outputPath, out_prefix: 'page', page: null // Specify the page number here to convert a specific page, otherwise null to convert all pages }; try { await pdfPoppler.convert(pdfPath, options); console.log('PDF converted to image successfully!'); } catch (error) { console.error('Error converting PDF to image:', error); } } The function uses the pdf-poppler package to convert the PDF to JPEG image format. We set the format option to 'jpeg' in this case, but you can choose other formats such as 'png' or 'tiff'. The out_dir option specifies the directory where the output images will be saved, and out_prefix sets a prefix for the output image files. The page option allows you to specify a particular page to convert, or you can leave it as null to convert all pages. To convert a PDF file to images, you can call the convertPdfToImage function with the appropriate file paths. For example: const pdfPath = '/path/to/input.pdf'; const outputPath = '/path/to/output/folder'; convertPdfToImage(pdfPath, outputPath); Note: Replace pdfPath value "/path/to/input.pdf" with the actual path to the input PDF file and "/path/to/output/folder" with the desired output directory path. The complete code is as follows: const pdfPoppler = require('pdf-poppler'); const pdfPath = 'C:\\Users\\hp\\Desktop\\NodeJS_PDFtoImage\\pdf_files\\input.pdf'; const outputDir = 'C:\\Users\\hp\\Desktop\\NodeJS_PDFtoImage\\pdf_images'; async function convertPdfToImage(pdfPath, outputPath) { const opts = { format: 'jpeg', // You can choose other formats like png or tiff out_dir: outputPath, out_prefix: 'page', page: null // Specify the page number here to convert a specific page, otherwise null to convert all pages }; try { await pdfPoppler.convert(pdfPath, opts); console.log('PDF converted to image successfully!'); } catch (error) { console.error('Error converting PDF to image:', error); } } convertPdfToImage(pdfPath, outputDir); Execute the Node.js Script Run the Node.js script by executing the following command: node pdfToImage.js node pdfToImage.js SHELL This will run the Node.js script and convert the PDF to image files using pdf-poppler. Output Folder Rasterize PDF File to Image in C# IronPDF for C# .NET IronPDF is a versatile .NET library that allows C# developers to work with PDF documents on the fly. It provides comprehensive features for creating, manipulating, and converting PDF files within C#. IronPDF offers a convenient way to convert PDF documents into image files using C#. This functionality is particularly useful when there is a need to extract images or generate image thumbnails from PDF files programmatically. To convert to images using IronPDF, you can follow the steps in the code snippet below: using IronPdf; using IronSoftware.Drawing; var pdf = PdfDocument.FromFile("input.pdf"); // Extract all pages to a folder as image files pdf.RasterizeToImageFiles(@"C:\image\folder\*.png"); // Dimensions and page ranges may be specified pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", 100, 80); // Extract all pages as AnyBitmap objects AnyBitmap [] pdfBitmaps = pdf.ToBitmap(); using IronPdf; using IronSoftware.Drawing; var pdf = PdfDocument.FromFile("input.pdf"); // Extract all pages to a folder as image files pdf.RasterizeToImageFiles(@"C:\image\folder\*.png"); // Dimensions and page ranges may be specified pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", 100, 80); // Extract all pages as AnyBitmap objects AnyBitmap [] pdfBitmaps = pdf.ToBitmap(); $vbLabelText $csharpLabel This is how easy it is to convert PDF to image file using IronPDF. For more details on PDF to image conversion, please visit this code examples page. Conclusion In this article, we explored how to convert PDF files to images in Node.js using the pdf-poppler package. By following the steps outlined, you can integrate PDF-to-image conversion capabilities into your Node.js applications, enabling a wide range of possibilities for handling and manipulating PDF documents programmatically. On the other hand, IronPDF is a powerful C# library that facilitates PDF manipulation and conversion tasks. Its ability to convert PDF to images offers a convenient way to extract images or generate image representations of PDF pages programmatically. By leveraging IronPDF's features, developers can seamlessly integrate PDF-to-image conversion functionality into their C# applications. IronPDF is free for development and can be licensed for commercial use. Moreover, you can also use it in commercial mode with a free trial. 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다. 커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다. 관련 기사 업데이트됨 6월 22, 2025 Discover the Best PDF Redaction Software for 2025 Explore top PDF redaction solutions for 2025, including Adobe Acrobat Pro DC, Nitro PDF Pro, Foxit PDF Editor, and PDF-XChange Editor. Learn how IronPDF automates redaction in .NET for enhanced security and compliance. 더 읽어보기 업데이트됨 6월 22, 2025 Best PDF Reader for iPhone (Free & Paid Tools Comparison) In this article, we will explore some of the best PDF readers for iPhone and conclude why IronPDF stands out as the best option. 더 읽어보기 업데이트됨 6월 26, 2025 Best Free PDF Editor for Windows (Free & Paid Tools Comparison) This article explores the top free PDF editors available in 2025 and concludes with the most powerful and flexible option: IronPDF. 더 읽어보기 How to Open PDF Files in ChromeHow to View PDF Files in C++
업데이트됨 6월 22, 2025 Discover the Best PDF Redaction Software for 2025 Explore top PDF redaction solutions for 2025, including Adobe Acrobat Pro DC, Nitro PDF Pro, Foxit PDF Editor, and PDF-XChange Editor. Learn how IronPDF automates redaction in .NET for enhanced security and compliance. 더 읽어보기
업데이트됨 6월 22, 2025 Best PDF Reader for iPhone (Free & Paid Tools Comparison) In this article, we will explore some of the best PDF readers for iPhone and conclude why IronPDF stands out as the best option. 더 읽어보기
업데이트됨 6월 26, 2025 Best Free PDF Editor for Windows (Free & Paid Tools Comparison) This article explores the top free PDF editors available in 2025 and concludes with the most powerful and flexible option: IronPDF. 더 읽어보기