Converting PDF to JPG: ArgumentException:Parameter is not valid

Sample file: sample.zip (168.4 KB)

Exception: ArgumentException

Message: Parameter is not valid.

Stack Trace:
at #=z4pxlTymWFZAq9xBCcanvliiPMShe.#=z5AZdpp8=(Int32 #=zkuRf4NQ=, Int32 #=zTB8GW9I=, PixelFormat #=zlkKb$fM=)
at #=zqDRunKUcmf09b$a0Ju1MkLPoawITrK8hlX_wAnY=…ctor(#=zMyX41D1nvBOvxbvC5h3oHQKpBhgUxSGz57INCi0= #=ztY$yMds=, #=zy1foblUmOUkhW11Q2nEjfjuQWfnHZTHXUA== #=zSnJiFlDbnWpWkmCtBUHA4HU=)
at #=zih08V4gB4xc0FgPfbJLAlRDJmJisS7_JcA==.#=zVpFerX8=(#=zMyX41D1nvBOvxbvC5h3oHQKpBhgUxSGz57INCi0= #=zYZ3jxzyqfeN3, #=zy1foblUmOUkhW11Q2nEjfjuQWfnHZTHXUA== #=zSnJiFlDbnWpWkmCtBUHA4HU=)
at #=zvyAnqqVZdIpwDv6PB5HRl3eJFgHVNFiJPs_Z4FX51Yvm…ctor(#=zTH6PrMfaoFpnf0ESVHZckyDkGmfn #=zV3xI_s0=, #=zwiHnLPO_pZ01jMkPUb7SifBDR3cx5TyIxQ== #=zlfkGWYU=, #=zMyX41D1nvBOvxbvC5h3oHQKpBhgUxSGz57INCi0= #=zYZ3jxzyqfeN3)
at #=zP$o6nDguzZgNXWNcyLXOM_mEpLY2WEd4a91Yhgs=.#=z87BCFNi3XutA(#=zTH6PrMfaoFpnf0ESVHZckyDkGmfn #=zV3xI_s0=, #=zwiHnLPO_pZ01jMkPUb7SifBDR3cx5TyIxQ== #=zlfkGWYU=, #=zMyX41D1nvBOvxbvC5h3oHQKpBhgUxSGz57INCi0= #=zYZ3jxzyqfeN3)
at #=z8E6sfPfruhOHxqT0VnXFWR9UYSEt0ZmbKD9T0nG_PArS.#=zidqiF7M=(#=zTH6PrMfaoFpnf0ESVHZckyDkGmfn #=zV3xI_s0=, #=zwiHnLPO_pZ01jMkPUb7SifBDR3cx5TyIxQ== #=zlfkGWYU=, #=zMyX41D1nvBOvxbvC5h3oHQKpBhgUxSGz57INCi0= #=ztY$yMds=, #=zvyAnqqVZdIpwDv6PB5HRl3eJFgHVNFiJPs_Z4FX51Yvm& #=zzgVJG$U=)
at #=zR1Oi6rwYaUycfVi4o4ielbLOP5tf.#=zbU5p_EA=(#=zvyAnqqVZdIpwDv6PB5HRl3eJFgHVNFiJPs_Z4FX51Yvm& #=zzgVJG$U=)
at Aspose.Pdf.Devices.ImageDevice.#=zbU5p_EA=(Page #=zlfkGWYU=)
at Aspose.Pdf.Devices.JpegDevice.Process(Page page, Stream output)
at Aspose.Pdf.Devices.PageDevice.Process(Page page, String outputFileName)
at Filestar.Plugin.AsposePdf.ConvertToImagesSkill.<>c__DisplayClass0_0.b__0() in D:\a\1\s\Filestar.Plugin.AsposePdf\ConvertToImagesSkill.cs:line 61
— End of stack trace from previous location —
at Filestar.Plugin.AsposePdf.ConvertToImagesSkill.<>c__DisplayClass0_0.b__0() in D:\a\1\s\Filestar.Plugin.AsposePdf\ConvertToImagesSkill.cs:line 80
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
— End of stack trace from previous location —
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
— End of stack trace from previous location —
at Filestar.Plugin.AsposePdf.ConvertToImagesSkill.Run(SkillRequest request, IRunArguments arguments) in D:\a\1\s\Filestar.Plugin.AsposePdf\ConvertToImagesSkill.cs:line 32
at Filestar.Core.AbstractRunner._ExecuteNode(AbstractSkillManifest manifestNode, SkillRequest skillRequest, Nullable1 recipeIndex, HashSet1 visitedFallbacks, String path, Int32 depth, Stack1 nodeIds, CancellationTokenSource cancellationTokenSource, IProgress1 progress)
at Filestar.Core.AbstractRunner._ExecuteJob(Job job)

@nielsbosma

Could you please also share the sample code snippet that you have used to convert this PDF into JPG? We will test the scenario in our environment and address it accordingly.

Note that this works fine with other PDFs.

        await Task.Run(() =>
        {
            LicenseManager.SetLicense();
            try
            {
                var doc = loadOptions != null ? new Document(inputPath, loadOptions) : new Document(inputPath);

                int pages = doc.Pages.Count();

                if (doc.Pages.Any())
                {
                    int p = 1;
                    foreach (var page in doc.Pages)
                    {
                        if (arguments.CancellationTokenSource != null &&
                            arguments.CancellationTokenSource.IsCancellationRequested)
                        {
                            isAborted = true;
                            return;
                        }

                        var rect = page.GetPageRect(true);
                        var device = Utils.GetImageDevice(fileTypeId,
                            new PageSize((float)rect.Width, (float)rect.Height), request.Model);

                        var outputFile = IntegrationUtils.GetTempFilePath(fileTypeId);

                        if (device is ImageDevice imageDevice)
                        {
                            imageDevice.Process(page, outputFile);
                        }
                        else if (device is DocumentDevice documentDevice)
                        {
                            documentDevice.Process(doc, p, p, outputFile);
                        }
                        else
                        {
                            throw new NotImplementedException(nameof(ConvertToImagesSkill));
                        }

                        result.Output.Add(new FileOutput(outputFile, fileTypeId));
                        arguments.Progress.Report(Convert.ToInt32(Math.Round((double)p / (double)pages * 100.0)));
                        p++;
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionDispatchInfo.Capture(Utils.MapException(e, inputPath)).Throw();
            }
        });

@nielsbosma

Have you used 23.1 version of the API? We tried using the latest version and could not reproduce the exception that you mentioned. Please try to use it and let us know if issue still persists. image1_out.jpg (428.2 KB)