pdf2image icon indicating copy to clipboard operation
pdf2image copied to clipboard

Empty string output

Open dontwork opened this issue 3 years ago • 7 comments

const options = {
    density: 300, // ppi
    format: "png",
    width,
    height
  }
  return pdf2pic.fromBuffer(buffer, options).bulk(1, true)
    .then(resizedImageBase64 => {

Hi I use your library regularly, thank you for making it.

I recently had an issue where the resizedImageBase64 above was an empty string. I was actually unable to replicate the issue on either my windows machine or within WSL.... I have it running in docker with the imagemagick and ghostscript packages installed and this is where the error is occurring.

However some research showed that ghostscript might silently fail if a font is not included in the PDF and the PDF i had the issue did not have the font included that the text used. I was hoping it might be possible to pass options through to ghostscript through this library in order to test this hypothesis. Is this possible?

Thanks

dontwork avatar Nov 19 '20 16:11 dontwork

I also have the same issue. Here's my code

  let res = await fetch(url);
  let buffer = await res.buffer();

  const options = {
    width: 2550,
    height: 3300,
    density: 330,
    savePath: "./output/from-buffer-to-base64"
  }

  // let convert = fromPath('pdf.pdf', options);
  let convert = fromBuffer(buffer, options);
  console.log(convert)

  let output = await convert(1, true)
  console.log('output')
  console.log(output)

  let base64 = output.base64;
  console.log('base64')
  console.log(base64)

fetch is the npm library node-fetch here.

See the console outputs:

[Function: r] {
  bulk: [Function],
  setOptions: [Function],
  setGMClass: [Function]
}
output
{ base64: '', size: '2550x3300', page: 1 }
base64

Edit: Does not work with the specimen1.pdf or other pdf's I tried

kuzdogan avatar Jan 13 '21 21:01 kuzdogan

Ok this is dumb but I actually didn't install the dependencies ghostscript and graphicsmagick :facepalm:. Now it works. Just install it as here.

Unfortunately I won't be able to use the library since I'll use it in a Google Cloud Function. If you are looking for an alternative like me you can use external API's such as cloudconver

kuzdogan avatar Jan 13 '21 22:01 kuzdogan

Ok this is dumb but I actually didn't install the dependencies ghostscript and graphicsmagick 🤦. Now it works. Just install it as here.

Unfortunately I won't be able to use the library since I'll use it in a Google Cloud Function. If you are looking for an alternative like me you can use external API's such as cloudconver 2022-04-19 (6) When I try to install the ghostscript4js package it gives this error. What could it be from? Can you please help?

simaybocu avatar Apr 19 '22 09:04 simaybocu

Ok this is dumb but I actually didn't install the dependencies ghostscript and graphicsmagick facepalm. Now it works. Just install it as here. Unfortunately I won't be able to use the library since I'll use it in a Google Cloud Function. If you are looking for an alternative like me you can use external API's such as cloudconver 2022-04-19 (6) When I try to install the ghostscript4js package it gives this error. What could it be from? Can you please help?

I think I was referring to the Ubuntu packages: https://github.com/yakovmeister/pdf2image/blob/master/docs/gm-installation.md Follow the Windows instructions there

kuzdogan avatar Apr 20 '22 17:04 kuzdogan

Ok this is dumb but I actually didn't install the dependencies ghostscript and graphicsmagick facepalm. Now it works. Just install it as here. Unfortunately I won't be able to use the library since I'll use it in a Google Cloud Function. If you are looking for an alternative like me you can use external API's such as cloudconver 2022-04-19 (6) When I try to install the ghostscript4js package it gives this error. What could it be from? Can you please help?

I think I was referring to the Ubuntu packages: https://github.com/yakovmeister/pdf2image/blob/master/docs/gm-installation.md Follow the Windows instructions there

yes, I installed both under C:\Program Files, but it still doesn't work, base64 is an empty string :(( Do you know a different package with a similar function?

simaybocu avatar Apr 22 '22 08:04 simaybocu

Unfortunately, I also only get an empty string back. Am I doing something wrong? I have installed ghostscript and graphicsmagick. Is there anything else I should be aware of? I am currently using Windows 10. screenshot_cmd

AndreasSauer avatar Jun 09 '22 18:06 AndreasSauer

is there any update regarding the issue? guys, it's working fine before now it's broken.

Suraj59 avatar Aug 04 '22 10:08 Suraj59