Closed dev3py closed 3 months ago
Hi @dev3py,
This repository holds pdf2pic npm package. You run it by installing it in your node.js project and using library's API.
Library's API can be found in the README. You can also reference repository with examples
I have installed all the pre-requsites. When i ran the npm run build command the dist folder was formed. And in dump folder i can see the images That were converted from the pdf1.pdf & pdf2.pdf which was in the /test/data/ folder. But how can i convert my pdfs to images. Can someone give me the step to convert my pdfs to images. I replace the pdf1.pdf & pdf2.pdf with my pdfs and ran the build and i got this error
graphics 1) should return page numbers 2) should return page numbers (from stream) ✔ should return file information (630ms) ✔ should return all of the options (default options) ✔ should set and return all of the options (custom options) ✔ should by default use width as height if no height is given ✔ should by not set height if preserveAspectRatio is
true
✔ should save first page as image file (995ms) 3) should save second page as image file 4) should save second page as base64 string 5) should save second page as bufferPDF2Pic Core ✔ should use default options (367ms) ✔ should convert pdf to pic (file input, first page) (425ms) ✔ should convert pdf to pic (buffer input, first page) (442ms) ✔ should convert pdf to pic (base64 input, first page) (459ms) 6) should convert pdf to pic (file input, second page, base64 output) 7) should convert pdf to pic (buffer input, second page, base64 output) 8) should convert pdf to pic (base64 input, second page, base64 output) 9) should convert pdf to pic (file input, bulk 2 pages) 10) should convert pdf to pic (file input, bulk all pages) 11) should convert pdf to pic (buffer input, bulk all pages) 12) should convert pdf to pic (base64 input, bulk all pages) responseType: buffer 13) should convert pdf to pic (file input, first page) 14) should convert pdf to pic (buffer input, second page) 15) should convert pdf to pic (base64 input, second page) 16) should convert pdf to pic (base64 input, bulk all pages) preserveAspectRatio 17) should preserve aspect ratio of pages ✔ should set height automatically (360ms) ✔ should set width automatically (411ms)
resolveResponseType ✔ should resolve to image if convertOptions is undefined ✔ should resolve to image if responseType is image ✔ should resolve to base64 if responseType is base64 ✔ should resolve to buffer if responseType is buffer ✔ should throw an error if convertOptions is invalid type ✔ should throw an error if convertOptions is invalid responseType
18 passing (8s) 17 failing
1) graphics should return page numbers:
2) graphics should return page numbers (from stream):
3) graphics should save second page as image file: Error: Command failed: Requested FirstPage is greater than the number of pages in the file: 1 No pages will be processed (FirstPage > LastPage). gm convert: Postscript delegate failed (C:\Users\rampr\AppData\Local\Temp\gmm8apF3).
4) graphics should save second page as base64 string: Error: Command failed: gm identify: Improper image header (./dump/savefiletest/frombase64.png). gm identify: Request did not return an image.
5) graphics should save second page as buffer: Error: Command failed: gm identify: Improper image header (./dump/savefiletest/tobuffer.png). gm identify: Request did not return an image.
6) PDF2Pic Core should convert pdf to pic (file input, second page, base64 output): Error: Command failed: gm identify: Improper image header (./dump/fromfiletest/frombase64.png). gm identify: Request did not return an image.
7) PDF2Pic Core should convert pdf to pic (buffer input, second page, base64 output): Error: Command failed: gm identify: Improper image header (./dump/fromfiletest/frombase64.png). gm identify: Request did not return an image.
8) PDF2Pic Core should convert pdf to pic (base64 input, second page, base64 output): Error: Command failed: gm identify: Improper image header (./dump/fromfiletest/frombase64.png). gm identify: Request did not return an image.
9) PDF2Pic Core should convert pdf to pic (file input, bulk 2 pages): Error: Command failed: Requested FirstPage is greater than the number of pages in the file: 1 No pages will be processed (FirstPage > LastPage). gm convert: Postscript delegate failed (C:\Users\rampr\AppData\Local\Temp\gm598kYb).
10) PDF2Pic Core should convert pdf to pic (file input, bulk all pages):
11) PDF2Pic Core should convert pdf to pic (buffer input, bulk all pages):
12) PDF2Pic Core should convert pdf to pic (base64 input, bulk all pages):
13) PDF2Pic Core responseType: buffer should convert pdf to pic (file input, first page): Error: Command failed: gm identify: Improper image header (./dump/fromfiletest/out-buffer-1.png). gm identify: Request did not return an image.
14) PDF2Pic Core responseType: buffer should convert pdf to pic (buffer input, second page): Error: Command failed: gm identify: Improper image header (./dump/fromfiletest/out-buffer-2.png). gm identify: Request did not return an image.
15) PDF2Pic Core responseType: buffer should convert pdf to pic (base64 input, second page): Error: Command failed: gm identify: Improper image header (./dump/fromfiletest/out-buffer-3.png). gm identify: Request did not return an image.
16) PDF2Pic Core responseType: buffer should convert pdf to pic (base64 input, bulk all pages):
17) PDF2Pic Core preserveAspectRatio should preserve aspect ratio of pages: Error: Command failed: Requested FirstPage is greater than the number of pages in the file: 1 No pages will be processed (FirstPage > LastPage). gm convert: Postscript delegate failed (C:\Users\rampr\AppData\Local\Temp\gmyHKCGV).