|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
I am receiving a strange result when attempting to render a page using Acm. The closest I can tell is that it may have to do with rendering tables or adding cells to tables, however when I get close to trying to narrow down the offending call seems to be thrown elsewhere. Below is the error and stack trace I'm receiving. Should this exception really ever happen? If it is something I am doing, a friendlier message would be appreciated.
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.Collections.Generic.List`1.get_Item(Int32 index) +14707204 EO.Pdf.Internal.bc.a(kf A_0) +336 EO.Pdf.Internal.i.m() +179 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +354 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmBlock A_0) +104 EO.Pdf.Acm.AcmRender.Render(AcmContent[] contents) +189
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
I believe I have more information regarding this error. In some circumstances this seems to happen when using the Children collection of a AcmTableCell object to add content objects rather than the constructor. For example:
The following causes the above exception. AcmTableCell cell = new AcmTableCell(); cell.Children.Add(new AcmText("Test"));
The following seems to work. AcmTableCell cell = new AcmTableCell(new AcmText("Test"));
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Thanks for the additional information. We are able to locate the error location based on the stack trace you provided but we have not been able to duplicate the error. The error occurs when we try to access our internal "Lines" collection during the layout phase. It might have to do with vertical alignment (which is related to table cell), but whether the AcmText is added through constructor or added later should not matter. In any case, this would look more like a bug on our side other than a code error on your side. So if you can isolate the problem into a test app and send it to us, we will be able to look into and get to the bottom of this.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Any luck on locating the issue here? I'm not sure I am able to provide a test app as this is incredibly frustrating and seemingly random. I was actually able to get this to work by passing items to the constructor rather than the Children collection as described above in the previous description. I did however also change some order of operations to complete this, which may have affected things.
Now I'm running into the same issue with some AcmBlock elements which seems to have something to do with the number of elements being rendered and/or nested elements. I can comment out one section/block from rendering and it will work, but it doesn't seem to have anything to do with what I'm commenting out or the actual call, content, or otherwise. For example I have two blocks of code adding two AcmBlocks of content to the document (see below). If I comment out one block or the other, the document is rendered without an exception/error. If I try to render BOTH, an exception with the exact stack trace as described in my previous comment occurs.
AcmBlock section = new AcmBlock(); AcmContent content = new AcmBlock(); content.StyleName = "Header" AcmText heading = new AcmText(headerText); heading.StyleName = "Heading1"; content.Children.Add(heading); section.Children.Add(content);
if (!String.IsNullOrEmpty(form.Instructions)) { AcmText instructions = new AcmText(form.Instructions); AcmParagraph paragraph = new AcmParagraph(instructions); section.Children.Add(paragraph); }
These two blocks are part of a larger document, that, when I comment out one AcmBlock within the document, it seems to render. Could this have something to do with a division/remainder problem on your part?
I'm baffled... and frustrated and troubleshooting on my part is nearly impossible. Any help getting this resolved ASAP would be greatly appreciated.
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Also if this helps, I was able to eliminate the error by commenting out a single line of code that applied a stylename to an AcmBlock in the document which only added Padding to it. For example:
AcmBlock container = new AcmBlock(); //container.StyleName = DocumentStyle.AnswerContainer.ToString(); // Commenting out this line made the exception go away. questionContainer.Children.Add(container);
The style: AcmStyle answerContainer = new AcmStyle(); answerContainer.Name = DocumentStyle.AnswerContainer.ToString(); answerContainer.Padding = new AcmPadding(new AcmUnit(2)); sheet.Add(answerContainer);
I was also able to eliminate the exception by increasing the padding number. AcmStyle answerContainer = new AcmStyle(); answerContainer.Name = DocumentStyle.AnswerContainer.ToString(); answerContainer.Padding = new AcmPadding(new AcmUnit(5)); // Increasing the padding number eliminated the exception. sheet.Add(answerContainer);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We have to have a test project in order to look further. One of the most important reason that we need a test project for this kind of problem is we need to be sure that indeed we are working on the same problem and we need a way to positive confirm that we did fix the issue for you. We don't do "can you try this", "ok let's try another thing" kind of trouble shoot. We see an issue, fix it, verify it, close it. That's why we need a test project to move forward on this.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
I understand and appreciate very well the need of a clear example of where the issue is so that it can be tested and corrected but I'm a little frustrated with this response as this is clearly an issue on your end and I've already spent countless hours trying to even diagnose this issue feeling like my hands are tied. I'm not suggesting that you "try this" and "try that", but help me route out the issue because you understand and have access to your source code. The level of complexity of this issue is significant and the amount of coding I need to do to create a test project is not a small feat, given that it seems to be related to a significant content of the page and related to a number of elements (see my example above). I'd be happy to step through the problem if I had access to the source but I don't. I've given you several examples and a stack trace and that should be a good to help you help me troubleshoot.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I understand your frustration. We are not saying that we won't look into it. But in order for us to troubleshoot a problem, we have to see it happening first. As for now you are the only one that can see it and we can't see it yet. So we need your help to help us to see it. It doesn't have to be a test project. For example, if you can take our sample project, makes a few modifications and make the problem happen, then you can give us the steps and we will take from there. The bottom line is we can't chase a ghost that we can't see.
You are in a much better position to put this ghost into view since you have seen it many times, and based on your description, you are actually able to make it appear or disappear by making various changes. And you are the only one who has the source code that can make it happen. That's why we ask you to create a test project for us. We will work closely with you, but since you have the unique source code combination that can creates the problem, so you create the problem, and we have the source code that can fix the problem, so we fix the problem. We think this is the most efficient and effective way to get this problem resolved. You can try to spend more time to tweak here and here to make the problem to go away, but that does not lead the root of the problem and you never know when it will come up again, so we don't think you should invest more time on that. The only thing you need to do is to reproduce it, and we will then take over from there.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Okay, I will try and do so... but like I said, it is seemingly completely random and as I am pulling information from a database to create the document it's going to take significant manual labor to create this issue as it has something to do with the number of elements as well as the configuration of those elements. I'm a little disappointed that your bug has become my problem. I can comment out one part of code and make it work, but it has nothing to do with that code that creates the issue. I can reenable the code and comment out another block and vice versa to make it work but not both. I also can remove one level of nesting that only applies some padding or change the amount of padding and it also will work.
I'm a little confused at why an index out of range issue is so difficult to troubleshoot on your end. Why is it difficult to backtrack from the call and see where there may be a condition that creates a scenario where you may be accessing an index out of bounds? I would be happy to do a net meeting with anyone willing to observe the problem. Spending a good amount of a day (or more) to recreate your bug for you seems like a dismissal of what I'm saying. I'm a seasoned developer and understand when a report creates me "chasing ghosts" but this is not the case here.
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Okay, I have a test project to demonstrate your problem for you. I believe it has something to do with the boundaries of the page and the edge and/or padding of a content item falling on the boundary. I have modified one of your demo projects to demonstrate the error, specifically the "hello world" sample in the Creator samples. How exactly to I send this to you? There doesn't seem to be any method here to do so.
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
public enum DocumentStyle { Normal, Cover, Header, Heading1, Heading2, Heading3, Heading4, Heading5, Question, QuestionContainer, Answer, AnswerContainer, Label, PageHeader, PageFooter, TextBox, Signature, Notes }
public void ExportTestForm(string fileName) { PdfDocument document = new PdfDocument(); AcmContent section = new AcmContent(); section.StyleSheet = CreateStyleSheet(); section.StyleName = DocumentStyle.Normal.ToString(); AddHeader(section, "Test Questionnaire");
AcmText instructions = new AcmText("This is a test questionnaire."); AcmParagraph paragraph = new AcmParagraph(instructions); section.Children.Add(paragraph);
AcmBlock container = new AcmBlock(); container.Style.Padding = new AcmPadding(0); AcmLineInfo borderStyle = new AcmLineInfo(AcmLineStyle.Solid, System.Drawing.Color.Black, new AcmUnit(1)); container.Style.Border.Top = borderStyle;
for (var i = 0; i < 20; i++) { AcmBlock questionContainer = AddQuestionTest(container, String.Format("Question {0}:", i), true); AcmBlock answerContainer = new AcmBlock(); answerContainer.StyleName = DocumentStyle.AnswerContainer.ToString(); AcmText text = new AcmText(); text.StyleName = DocumentStyle.Answer.ToString(); text.Style.Margin.Bottom = 0.20f; answerContainer.Children.Add(text); questionContainer.Children.Add(answerContainer); }
section.Children.Add(container); System.Drawing.SizeF pageSize = new System.Drawing.SizeF(8.5f, 11f); AcmPadding pageMargin = new AcmPadding(0.75f, 0.75f, 0.75f, 0.75f); AcmPageLayout layout = new AcmPageLayout(pageSize, pageMargin); AcmRender renderer = new AcmRender(document, layout); renderer.Render(section); document.Save(fileName); }
AcmBlock AddQuestionTest(AcmContent section, string questionText, bool includeBorder = true) { AcmBlock container = new AcmBlock(); if (includeBorder) { AcmLineInfo borderStyle = new AcmLineInfo(AcmLineStyle.Solid, System.Drawing.Color.Black, new AcmUnit(1)); container.Style.Border.Bottom = borderStyle; container.Style.Border.Left = borderStyle; container.Style.Border.Right = borderStyle; } container.Style.Padding = new AcmPadding(new AcmUnit(3)); AcmText text = new AcmText(questionText); text.StyleName = DocumentStyle.Question.ToString(); section.Children.Add(container); return container; }
private AcmText AddHeader(AcmContent section, string headerText) { AcmContent content = new AcmBlock(); content.StyleName = DocumentStyle.Header.ToString(); AcmText heading = new AcmText(headerText); heading.StyleName = DocumentStyle.Heading1.ToString(); content.Children.Add(heading); section.Children.Add(content); return heading; }
AcmStyleSheet CreateStyleSheet() {
AcmStyleSheet sheet = new AcmStyleSheet();
AcmStyle normal = new AcmStyle(); normal.Name = DocumentStyle.Normal.ToString(); normal.FontSize = 10; normal.FontName = "Arial"; normal.HorizontalAlign = AcmHorizontalAlign.Left; normal.VerticalAlign = AcmVerticalAlign.Top; normal.ForegroundColor = System.Drawing.Color.Black; sheet.Add(normal);
AcmStyle cover = new AcmStyle(); cover.Name = DocumentStyle.Cover.ToString(); cover.FontName = "Arial"; cover.FontSize = 10; cover.HorizontalAlign = AcmHorizontalAlign.Center; cover.FontSize = 22; cover.FontStyle = System.Drawing.FontStyle.Bold; cover.ForegroundColor = System.Drawing.Color.Black; sheet.Add(cover);
AcmStyle header = new AcmStyle(); header.Name = DocumentStyle.Header.ToString(); header.BackgroundColor = System.Drawing.Color.FromArgb(200, 200, 200); header.Padding = new AcmPadding(new AcmUnit(4)); header.Margin = new AcmPadding(0, 0, 0, new AcmUnit(14)); header.HorizontalAlign = AcmHorizontalAlign.Center; header.VerticalAlign = AcmVerticalAlign.Middle; sheet.Add(header);
AcmStyle heading1 = new AcmStyle(); heading1.Name = DocumentStyle.Heading1.ToString(); heading1.FontSize = 13; heading1.FontStyle = System.Drawing.FontStyle.Bold; heading1.ForegroundColor = System.Drawing.Color.Black; sheet.Add(heading1);
AcmStyle heading2 = new AcmStyle(); heading2.Name = DocumentStyle.Heading2.ToString(); heading2.HorizontalAlign = AcmHorizontalAlign.Left; heading2.FontSize = 13; heading2.FontStyle = System.Drawing.FontStyle.Bold; heading2.ForegroundColor = System.Drawing.Color.Black; heading2.Margin.Top = new AcmUnit(16); heading2.Margin.Bottom = new AcmUnit(8); heading2.Border.Bottom = new AcmLineInfo(AcmLineStyle.Solid, System.Drawing.Color.Black, 0.1f); sheet.Add(heading2);
AcmStyle heading3 = new AcmStyle(); heading3.Name = DocumentStyle.Heading3.ToString(); heading3.HorizontalAlign = AcmHorizontalAlign.Left; heading3.FontSize = 13; heading3.FontStyle = System.Drawing.FontStyle.Bold; heading3.Margin.Top = new AcmUnit(14); heading3.Margin.Bottom = new AcmUnit(8); sheet.Add(heading3);
AcmStyle heading4 = new AcmStyle(); heading4.Name = DocumentStyle.Heading4.ToString(); heading4.HorizontalAlign = AcmHorizontalAlign.Left; heading4.FontSize = 11; heading4.FontStyle = System.Drawing.FontStyle.Bold; heading4.Margin.Top = new AcmUnit(12); heading4.Margin.Bottom = new AcmUnit(8); sheet.Add(heading4);
AcmStyle heading5 = new AcmStyle(); heading5.Name = DocumentStyle.Heading5.ToString(); heading5.FontStyle = System.Drawing.FontStyle.Bold; heading4.Margin.Top = new AcmUnit(6); heading4.Margin.Bottom = new AcmUnit(2); sheet.Add(heading5);
AcmStyle question = new AcmStyle(); question.Name = DocumentStyle.Question.ToString(); question.HorizontalAlign = AcmHorizontalAlign.Left; question.FontSize = 9; question.LineHeight = new AcmUnit(9); question.FontStyle = System.Drawing.FontStyle.Bold; sheet.Add(question);
AcmStyle questionContainer = new AcmStyle(); questionContainer.Name = DocumentStyle.QuestionContainer.ToString(); questionContainer.BackgroundColor = System.Drawing.Color.FromArgb(200, 200, 200); questionContainer.Padding = new AcmPadding(new AcmUnit(1)); sheet.Add(questionContainer);
AcmStyle answerContainer = new AcmStyle(); answerContainer.Name = DocumentStyle.AnswerContainer.ToString(); answerContainer.Padding = new AcmPadding(new AcmUnit(6)); sheet.Add(answerContainer);
AcmStyle signature = new AcmStyle(); signature.Name = DocumentStyle.Signature.ToString(); signature.FontName = "Brush Script MT"; signature.FontStyle = System.Drawing.FontStyle.Italic; signature.FontSize = 15; sheet.Add(signature);
AcmStyle label = new AcmStyle(); label.Name = DocumentStyle.Label.ToString(); label.FontStyle = System.Drawing.FontStyle.Bold; label.ForegroundColor = System.Drawing.Color.FromArgb(185, 185, 185); sheet.Add(label);
AcmStyle answer = new AcmStyle(); answer.Name = DocumentStyle.Answer.ToString(); answer.FontStyle = System.Drawing.FontStyle.Regular; sheet.Add(answer);
AcmStyle notes = new AcmStyle(); notes.Name = DocumentStyle.Notes.ToString(); notes.ForegroundColor = System.Drawing.Color.Red; sheet.Add(notes);
AcmStyle pageHeader = new AcmStyle(); pageHeader.Name = DocumentStyle.PageHeader.ToString(); pageHeader.FontSize = 8; pageHeader.FontName = "Arial"; pageHeader.ForegroundColor = System.Drawing.Color.FromArgb(100, 100, 100); sheet.Add(pageHeader);
AcmStyle pageFooter = new AcmStyle(); pageFooter.Name = DocumentStyle.PageFooter.ToString(); pageFooter.FontSize = 8; pageFooter.FontName = "Arial"; pageFooter.ForegroundColor = System.Drawing.Color.FromArgb(100, 100, 100); sheet.Add(pageFooter);
return sheet; }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Thank you very much for the test code. This is just to let you know that we were able to reproduce the problem with your code. We are looking into this and will get back to you as soon as we have an update.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Do you have an ETA on this? This is seriously holding up our project. The reason we went with your company was the claim for great customer support and claim to object quality. I would very much appreciate your prompt assistance in resolving this. Thank you.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We have already fixed this problem internally yesterday. The official build should be out either today or tomorrow.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Thank you very much!!! I appreciate the promptness of the fix.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We have posted the new build that should fix this issue. You can download it from our download page.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
Great thank you. I can do that. Any plans on updating the nuget package?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Yes. It will be updated shortly.
|
|
Rank: Advanced Member Groups: Member
Joined: 1/22/2014 Posts: 38
|
I downloaded the new build and it was working much better initially, but apparently the problem has not been fully fixed. I'm hoping I don't need to troubleshoot and build another test case for you.
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.Collections.Generic.List`1.get_Item(Int32 index) +14707204 EO.Pdf.Internal.bc.a(kg A_0) +272 EO.Pdf.Internal.i.m() +179 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +354 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmContent A_0) +249 EO.Pdf.Acm.AcmRender.a(AcmBlock A_0) +104 EO.Pdf.Acm.AcmRender.Render(AcmContent[] contents) +189
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We can make a small change and provide you another update to see if it fixes this problem for you. If it still does not, then we will need a test case.
Thanks!
|
|