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

Free Support Forum - aspose.com

pdfFileEditor.Concatenate fails with large files

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,


Thanks for contacting support.

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.

Can you please try using latest release and in case you encounter any issue, please share some details regarding your working environment i.e. Operating System, .NET Framework and Visual Studio version etc.

We are sorry for this inconvenience.

[C#]

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.


Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
PreferredWidth lWidth = PreferredWidth.FromPercent(20);
PreferredWidth dWidth = PreferredWidth.FromPercent(30);
PreferredWidth span3WithLabel = PreferredWidth.FromPercent(80);
PreferredWidth fullWidth = PreferredWidth.FromPercent(100);
builder.Font.Size = 14;
builder.Font.Bold = true;
builder.ParagraphFormat.Style.Font.Name = “Calibri”;

builder.StartTable();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.CellFormat.Borders.Color = System.Drawing.Color.White;
builder.CellFormat.Borders.Bottom.Color = System.Drawing.ColorTranslator.FromHtml("#000000");
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.InsertCell();

builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Bottom;
builder.CellFormat.PreferredWidth = span3WithLabel;


builder.Write(“TESTING”);
builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.CellFormat.PreferredWidth = lWidth;


MemoryStream outstream = new MemoryStream();
Console.WriteLine(“Get test file”);
FileStream tempInstream = new FileStream(“C:\test.pdf”, FileMode.Open, FileAccess.Read);
MemoryStream tempInSream2 = new MemoryStream();
doc.Save(tempInSream2, Aspose.Words.SaveFormat.Pdf);

List lst = new List { tempInSream2, tempInstream };

Aspose.Pdf.Facades.PdfFileEditor editor = new Aspose.Pdf.Facades.PdfFileEditor();
Aspose.Pdf.License lic = new Aspose.Pdf.License();
lic.SetLicense(“Aspose.Total.lic”);

Console.WriteLine(“concatenate document file to pdf file.”);
editor.Concatenate(lst.ToArray(), outstream);

Console.WriteLine(“write to output file”);
var fileStream = File.Create(“C:\testoutput”);
outstream.Seek(0, SeekOrigin.Begin);
outstream.CopyTo(fileStream);

fileStream.Close();
tempInstream.Close();
outstream.Close();

Thanks,
Ashley




Hi Ashley,


Thanks for sharing the details.

I have tested the scenario and have managed to reproduce that when using following code snippet, a resultant file of 0KB is being generated. For the sake of correction, I have logged it as PDFNEWNET-40631 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

[C#]

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,


Thanks for your patience.

As we recently have noticed earlier reported issue, so its pending for review and is not yet resolved. However the product team will surely consider investigating/fixing it as per development schedule and as soon as we have some definite updates regarding its resolution, we will let you know. Please be patient and spare us little time. We are sorry for this delay and inconvenience.

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,

Ashley

Hi Ashley,


Thanks for your patience.

The issue reported earlier is pending for review as the team has been busy fixing other previously reported high priority issues. However I have recorded your concerns with product team and they will surely consider them during the resolution of this problem. As soon as we have some definite updates, we will let you know.

PS, The issues are resolved in first come first serve basis as we believe its the fairest policy to all the customers.

Hi there,


any progress here?

Greetings,

Johannes

I haven’t gotten a reply. We still really need this to be resolved as well.

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).

[C#]

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 Asad,

Thank you for your response. I downloaded the latest version dll's for aspose word and pdf for .Net and built a sample web application to test out the concatenation issue, but unfortunately the problem still exists even with upgraded dll's ( version Aspose word and Pdf for .Net 17.4.0)

I have attached my application here (excluded the license file)...
Please let me know if you think this is still an issue or advise of any corrections.

Thanks!
Kana

Hi Kanakesh,


Thanks for sharing the sample project.

We are working on testing the scenario and will get back to you soon.

Hi Kanakesh,


Thanks for your patience.

I have tried executing your project but I am afraid I am encountering an issue while running the solution. However in order to replicate the issue, I have copied the same code snippet and have tried executing it in VisualStudio 2010 using Aspose.Pdf for .NET 17.4.0 and I am unable to notice any issue.

For your reference, I have attached the output generated over my end.

[C#]

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, may i know what error are you running into when trying to run my solution?

- If its related to license file not found, please remove that line and try again
- if its related to source file path, then you will have to make sure the file exists in the right path.

Hi Kanakesh,


Thanks for contacting support.

The issue has been related to IIS and in order to replicate the scenario, I copied the same code snippet to another WebApplication and I am unable to notice any issue. Please find attached the sample web application that I have used for testing purposes.

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.

We are sorry for the delay and inconvenience.
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, i am still having issues. Here is the sample file. PLease use this file with the above sent sample web application.

Hi Kanakesh,


Thanks for sharing input document.

I have tried the scenario with the input file that you have just shared and noticed an issue. The code generated a 0KB output file and it was corrupted also. Please note that when I tried with same code snippet in a sample Console Application, all went well and output file was also valid.

It seemed that API is generating invalid document when using in Web Application. As it seems environment specific issue, so I have updated the issue details in context of environment and intimated the relevant team about it. We really appreciate your patience in this regard. We will certainly keep you informed about the status updates within this thread.

Please cooperate with us and spare us a little time. We are sorry for this delay and inconvenience.


Best Regards,

Can you provide an update on this? we are still waiting on the fix

Hi Kanakesh,


Thanks for your inquiry.

I have checked the status of the logged issue and I am afraid that it is not resolved yet as development team has been busy in resolving other issues in the queue. We have recorded your concerns and intimated relevant team about them. We are sure that they will soon plan to provide a fix against your issue as per their development schedule. We greatly appreciate your cooperation and patience in this regard. Please spare us little time.

We are sorry for the delay and inconvenience.


Best Regards,