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)) }) })
コメント
2件のコメント
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.
Thanks, I know. How can I use it synchronously?
サインインしてコメントを残してください。