We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Stack overflow exception when trying to convert TIFF to PDF using Aspose.Pdf

Hi,

We are getting stack overflow exceptions when trying to convert tiff to PDF file using the below code.

==============
Code Snippet

        string astrFilePath = @"D:\Test\Input\Fassino.tiff";
        string astrDestinationFilePath = @"D:\Test\Output\";
        string astrDestinationFileName = @"Fassino.pdf";
        string filePath = @"";
        string ConvertedFileName = "";
        string root = "";
        using (Aspose.Pdf.Document pdf1 = new Aspose.Pdf.Document())
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (FileStream fs = new FileStream(astrFilePath, FileMode.Open))
                { fs.CopyTo(ms); }
                Bitmap myimage = new Bitmap(ms);

                FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
                int frameCount = myimage.GetFrameCount(dimension);
                for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
                {
                    Page sec = pdf1.Pages.Add();

                    myimage.SelectActiveFrame(dimension, frameIdx);
                    Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
                    using (MemoryStream currentImage = new MemoryStream())
                    {
                        myimage.Save(currentImage, ImageFormat.Tiff);

                        imageht.ImageStream = currentImage;

                        if (myimage.Width > myimage.Height)
                        {
                            sec.PageInfo.IsLandscape = true;
                        }
                        else
                        {
                            sec.PageInfo.IsLandscape = false;
                        }

                        imageht.IsBlackWhite = false;
                        sec.Paragraphs.Add(imageht);
                        TextStamp stamp = new TextStamp("Windows Fax and Scan");
                        stamp.Background = false;
                        // Specify font name for Stamp object
                        stamp.TextState.Font = FontRepository.FindFont("Arial");

                        // Specify Font size for TextStamp
                        stamp.TextState.FontSize = 12;
                        //stamp.TextState.Font.
                        // Specify character specing as 1f
                        stamp.TextState.CharacterSpacing = 1f;
                        // Set the XIndent for Stamp
                        stamp.XIndent = 100;
                        // Set the YIndent for Stamp
                        stamp.YIndent = 500;
                        // Add textual stamp to page instance
                        sec.AddStamp(stamp);

                        if (astrDestinationFilePath != null || astrDestinationFileName != null)
                        {
                            filePath = System.IO.Path.ChangeExtension(astrDestinationFilePath, null);
                            ConvertedFileName = filePath + astrDestinationFileName;
                        }
                        else
                        {
                            filePath = System.IO.Path.ChangeExtension(astrFilePath, null);
                            root = System.IO.Path.GetDirectoryName(astrFilePath);
                            ConvertedFileName = root + "\\" + System.IO.Path.GetFileNameWithoutExtension(astrFilePath) + ".pdf";
                        }
                        pdf1.Save(ConvertedFileName);

                    }
                }
            }
        }

==============================
Memory dump with the stack overflow

0000005eb6739510 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739590 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739610 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739690 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739710 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739790 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739810 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739890 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739910 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739990 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739a10 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739a90 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739b10 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739b90 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739c10 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739c90 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739d10 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739d90 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739e10 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739e90 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739f10 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb6739f90 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a010 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a090 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a110 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a190 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a210 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a290 00007ffc773b1ce4 #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z$TwKSu0f$ecX(#=zMyX41D1nvBOvxbvC5h3oHb2LM_kch65wES4ZSv4=, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a310 00007ffc773b0fcf #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z1mHvWDs=(System.IO.Stream, #=zhFzEwn9qbLCoq2$$MTFJOE$V4jJPCQvKXqCmmoo=)

0000005eb673a350 00007ffc773b0f6d #=z1LyLMLtCLlpsyehG4ThqYS9xGdDdFlQMrg==.#=z1mHvWDs=(System.IO.Stream)

0000005eb673a380 00007ffc765fda06 Aspose.Pdf.Image.#=ztjhr9pM=(Double ByRef, Double ByRef, Double ByRef, Boolean, Aspose.Pdf.MarginInfo, Double, Double, Aspose.Pdf.Page, System.Collections.Generic.List`1, Boolean, Boolean, Boolean, Aspose.Pdf.Paragraphs ByRef, Double, Double, Int32)

0000005eb673cc28 00007ffcd1a89a11 [HelperMethodFrame: 0000005eb673cc28]

0000005eb673cd10 00007ffccc11a333 System.Drawing.Bitmap…ctor(System.IO.Stream)

0000005eb673cd80 00007ffc765fcc85 Aspose.Pdf.Image.#=ztjhr9pM=(Double ByRef, Double ByRef, Double ByRef, Boolean, Aspose.Pdf.MarginInfo, Double, Double, Aspose.Pdf.Page, System.Collections.Generic.List`1, Boolean, Boolean, Boolean, Aspose.Pdf.Paragraphs ByRef, Double, Double, Int32)

0000005eb673cec0 00007ffc765fa353 #=zsda8k_Asr525gfN9ANXaD$I=.#=ztjhr9pM=()

0000005eb673d070 00007ffc765f8344 Aspose.Pdf.Page.#=zUKoOYm8=(Aspose.Pdf.Page)

0000005eb673d1d0 00007ffc765f7954 Aspose.Pdf.Page.#=zcOBT5LH_T3GHX5WOZQ==()

0000005eb673d200 00007ffc765f6075 Aspose.Pdf.Document.ProcessParagraphs()

0000005eb673d280 00007ffc765f55df Aspose.Pdf.Document.#=z191VBrPmsrWS(System.IO.Stream, Aspose.Pdf.SaveOptions)

0000005eb673d2e0 00007ffc765f4672 Aspose.Pdf.Document.#=zpcTDqMYRNLY7(System.String)

0000005eb673d340 00007ffc765f45b9 Aspose.Pdf.Document.Save(System.String)

@AbilashSekharan

Can you please share the source file so that we may try to reproduce the same on our end.

Program.zip (2.4 KB)
Please find attached the code

@AbilashSekharan

Please share the source TIFF file for our investigations.

I can’t provide the source tiff since it has pi data.

@AbilashSekharan

It is hard to determine the cause of the issue without replicating it in our environment. Therefore, I request you to please share any dummy file that is actually reproducing the issue so that we may asses and after that log that in our issue tracking system.