Hello,
I am experiencing a stack overflow error when trying to concatenate a very large pdf file to another pdf.
This is the location of the file I am trying to concatenate that is causing the failure.
Download and test the file titled "Problem File.pdf"
My code simply reads the file with New IO.Filestream method.
creates a filestream array with another pdf file.
Passes them into concatenate function.
The concatenate function errors out every time with a stack overflow error.
Is there a known limitation with the size of files allowed when using this funtion? Or a page limit of some kind?
Thanks,
Ashley
Hi Ashley,
In order to test the scenario, I have created a copy of earlier shared document and have tried concatenating both documents using following code snippet and I am unable to notice any issue. For testing purposes, I have used the latest release of Aspose.Pdf for .NET 11.5.0.
Dim document As Aspose.Pdf.Document = New Document("c:/pdftest/Problem File.pdf")
Dim document2 As Aspose.Pdf.Document = New Document("c:/pdftest/Problem File - Copy.pdf")
document.Pages.Add(document2.Pages)
document.Save(“c:/pdftest/Problem File_Concatenated.pdf”)
Hi,
I have tested with the latest release and the initial problem, the stack overflow issue is resolved. But In our system we are concatenating a pdf created using the Apose.Words DocumentBuilder to the pdf attached to my initial post.
I will past the simplified code which we use to build up the first file and concatenate the two below.
When concatenating two pdf files from my machine, the function works fine. When concatenating the pdf built up by the document builder to a pdf from my machine, I get a {“Incorect file format”} exception.
Thanks,
Ashley
Hi Ashley,
Aspose.Words.Document doc = new Aspose.Words.Document();<o:p></o:p>
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);<o:p></o:p>
PreferredWidth lWidth = PreferredWidth.FromPercent(20);<o:p></o:p>
PreferredWidth dWidth = PreferredWidth.FromPercent(30);<o:p></o:p>
PreferredWidth span3WithLabel = PreferredWidth.FromPercent(80);<o:p></o:p>
PreferredWidth fullWidth = PreferredWidth.FromPercent(100);<o:p></o:p>
builder.Font.Size = 14;<o:p></o:p>
builder.Font.Bold = true;<o:p></o:p>
builder.ParagraphFormat.Style.Font.Name = “Calibri”;<o:p></o:p>
builder.StartTable();<o:p></o:p>
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;<o:p></o:p>
builder.CellFormat.Borders.Color = System.Drawing.Color.White;<o:p></o:p>
builder.CellFormat.Borders.Bottom.Color = System.Drawing.ColorTranslator.FromHtml("#000000");<o:p></o:p>
builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;<o:p></o:p>
builder.InsertCell();
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Bottom;<o:p></o:p>
builder.CellFormat.PreferredWidth = span3WithLabel;
builder.Write(“TESTING”);<o:p></o:p>
builder.InsertCell();<o:p></o:p>
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;<o:p></o:p>
builder.CellFormat.PreferredWidth = lWidth;
MemoryStream outstream = new MemoryStream();<o:p></o:p>
Console.WriteLine(“Get test file”);<o:p></o:p>
FileStream tempInstream = new FileStream(“C:\pdftest\Problem File.pdf”, FileMode.Open,FileAccess.Read);<o:p></o:p>
MemoryStream tempInSream2 = new MemoryStream();<o:p></o:p>
doc.Save(tempInSream2, Aspose.Words.SaveFormat.Pdf);<o:p></o:p>
Console.WriteLine(tempInSream2.Length);
List<Stream> lst = new List<Stream> { tempInSream2, tempInstream };
Aspose.Pdf.Facades.PdfFileEditor editor = new Aspose.Pdf.Facades.PdfFileEditor();
Console.WriteLine(“concatenate document file to pdf file.”);<o:p></o:p>
editor.Concatenate(lst.ToArray(), new FileStream(“c:/pdftest/ConcatenatedFile.pdf”, FileMode.Create));<o:p></o:p>
tempInstream.Close();
tempInSream2.Close();
Hi,
Just wondering if there is any update on this issue?
Thanks,
Ashley
Hi Ashley,
Hello,
We have clients that are not able to use our system due to this defect. They are asking us for a timeline on when we can have this defect fixed.
Can you please provide an ETA on this fix? Is it something you are currently in progress on? Or is it something you are not prioritizing? If possible can we escalate this so it is fixed sooner?
Thanks,
Hi Ashley,
Hi there,
I haven’t gotten a reply. We still really need this to be resolved as well.
Hi Ashley,
Aspose.Words.Document doc = new Aspose.Words.Document();<o:p></o:p>
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);<o:p></o:p>
PreferredWidth lWidth = PreferredWidth.FromPercent(20);<o:p></o:p>
PreferredWidth dWidth = PreferredWidth.FromPercent(30);<o:p></o:p>
PreferredWidth span3WithLabel = PreferredWidth.FromPercent(80);<o:p></o:p>
PreferredWidth fullWidth = PreferredWidth.FromPercent(100);<o:p></o:p>
builder.Font.Size = 14;<o:p></o:p>
builder.Font.Bold = true;<o:p></o:p>
builder.ParagraphFormat.Style.Font.Name = “Calibri”;<o:p></o:p>
builder.StartTable();<o:p></o:p>
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;<o:p></o:p>
builder.CellFormat.Borders.Color = System.Drawing.Color.White;<o:p></o:p>
builder.CellFormat.Borders.Bottom.Color = System.Drawing.ColorTranslator.FromHtml("#000000");<o:p></o:p>
builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;<o:p></o:p>
builder.InsertCell();
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Bottom;<o:p></o:p>
builder.CellFormat.PreferredWidth = span3WithLabel;
builder.Write(“TESTING”);<o:p></o:p>
builder.InsertCell();<o:p></o:p>
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;<o:p></o:p>
builder.CellFormat.PreferredWidth = lWidth;
MemoryStream outstream = new MemoryStream();<o:p></o:p>
Console.WriteLine(“Get test file”);<o:p></o:p>
FileStream tempInstream = new FileStream(“C:\pdftest\Problem File.pdf”, FileMode.Open,FileAccess.Read);<o:p></o:p>
MemoryStream tempInSream2 = new MemoryStream();<o:p></o:p>
doc.Save(tempInSream2, Aspose.Words.SaveFormat.Pdf);<o:p></o:p>
Console.WriteLine(tempInSream2.Length);
List<Stream> lst = new List<Stream> { tempInSream2, tempInstream };
Aspose.Pdf.Facades.PdfFileEditor editor = new Aspose.Pdf.Facades.PdfFileEditor();
Console.WriteLine(“concatenate document file to pdf file.”);<o:p></o:p>
editor.Concatenate(lst.ToArray(), new FileStream(“c:/pdftest/ConcatenatedFile.pdf”, FileMode.Create));<o:p></o:p>
tempInstream.Close();
tempInSream2.Close();
I have also attached the output file generated by the above code for your reference. Please try using latest version of the API to perform the concatenation and in case if you still face any issue please feel free to let us know.
Best Regards,
asad.ali:Hi Ashley,Thanks for your patience.I would like to share with you that I have tested the whole scenario with the latest release of Aspose.Pdf for .NET and Aspose.Words for .NET and successfully generated the output file. The code executed fine without generating exception which was reported earlier. I believe that the issue has been fixed in the latest version of API. I have used following code snippet and same input file (Problem File.pdf).
Hi Kanakesh,
Hi Kanakesh,
Aspose.Words.Document
doc = new Aspose.Words.Document();<o:p></o:p>
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
Aspose.Words.Tables.PreferredWidth lWidth = Aspose.Words.Tables.PreferredWidth.FromPercent(20);
Aspose.Words.Tables.PreferredWidth dWidth = Aspose.Words.Tables.PreferredWidth.FromPercent(30);
Aspose.Words.Tables.PreferredWidth span3WithLabel = Aspose.Words.Tables.PreferredWidth.FromPercent(80);
Aspose.Words.Tables.PreferredWidth fullWidth = Aspose.Words.Tables.PreferredWidth.FromPercent(100);
builder.Font.Size = 14;
builder.Font.Bold = true;
builder.ParagraphFormat.Style.Font.Name = "Calibri";
builder.StartTable();
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
builder.CellFormat.Borders.Color = System.Drawing.Color.White;
builder.CellFormat.Borders.Bottom.Color = System.Drawing.ColorTranslator.FromHtml("#000000");
builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
builder.InsertCell();
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Bottom;
builder.CellFormat.PreferredWidth = span3WithLabel;
builder.Write("TESTING");
builder.InsertCell();
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
builder.CellFormat.PreferredWidth = lWidth;
MemoryStream outstream = new MemoryStream();
Console.WriteLine("Get test file");
FileStream tempInstream = new FileStream("C:\\pdftest\\footnote.pdf", FileMode.Open, FileAccess.Read);
MemoryStream tempInSream2 = new MemoryStream();
doc.Save(tempInSream2, Aspose.Words.SaveFormat.Pdf);
Console.WriteLine(tempInSream2.Length);
List<Stream> lst = new List<Stream> { tempInSream2, tempInstream };
Aspose.Pdf.Facades.PdfFileEditor editor = new Aspose.Pdf.Facades.PdfFileEditor();
Console.WriteLine("concatenate document file to pdf file.");
editor.Concatenate(lst.ToArray(), new FileStream("C:\\pdftest\\New Problem File.pdf", FileMode.Create));
tempInstream.Close();
tempInSream2.Close();
codewarior:Thanks for your patience.I have tried executing your project but I am afraid I am encountering an issue while running the solution.
Hi Kanakesh,
codewarior:As an input, I used one of my sample PDF files, so the issue might be related to the source PDF file which you are using. Can you please again test the scenario using attached solution and in case you still face the same problem, please share the input PDF file.
Hi Kanakesh,
Can you provide an update on this? we are still waiting on the fix
Hi Kanakesh,