Community

processDocument order off

Hi,

 

I'm using the submitImage method to submit several images. Afterwards I'm calling the processDocument method to get a single pdf back. Issue is that the single pdf contains the images in a random order. My expectation is to get it with order of submission.

My code:

const fromImages = inputPaths => new Promise((resolve, reject) => {

let taskId
if (!inputPaths || inputPaths.length === 0)  reject('No images given')


client.submitImage({}, inputPaths.shift(), (err, res) => {

if (err) reject(err)
   taskId = res


Promise.all(

   inputPaths.map(inputPath => new Promise((mapResolve, mapReject) => client.submitImage({ taskId }, inputPath, (err, res) => err ? mapReject(err) : mapResolve(res)))) )

.then(res => client.processDocument({ ...defaultApiParameters, taskId }, (err, res) => err ? reject(err) : resolve(res))) .catch(err => reject(err)) }) })

Was this article helpful?

0 out of 0 found this helpful

Comments

2 comments

  • Avatar
    Aleksandra Zendrikova

    Hi,
    It seems like you asynchronously use submitImage method. 
    In that case, there is no guarantee to get images in order of submission because different threads can finish their task at different times depends on size, time or something else.

    0
  • Avatar
    Permanently deleted user

    Thanks, I know. How can I use it synchronously?

    0

Please sign in to leave a comment.