When I try to add more than 31 segments to a section, each with its own TextInfo settings, I get an Index out of bounds exception in Aspose.Pdf.Dll!!!
Why?
static void Fn3()
{
System.String[] s = new System.String[]{
“CPI-RG__.”,
“fbrg____.”,
“FRN_____.”,
“ftblc___.”,
“ftbl____.”,
“ftebc___.”,
“ftr_____.”,
“ftubl___.”,
“fubo____.”,
“fub_____.”,
“fuho____.”,
“fuh_____.”,
“fuo_____.”,
“fuwo____.”,
“fuw_____.”,
“fu______.”,
“gal_____.”,
“GDBI____.”,
“GDB_____.”,
“GDI_____.”,
“GDRG____.”,
“GDSBI___.”,
“GDSB____.”,
“haebc___.”,
“hk2_____.”,
“hvbl____.”,
“hvbo____.”,
“hvcbo___.”,
“hvcb____.”,
“hvcdo___.”,
“hvc_____.”,
“hvk_____.”,
“LOBL____.”,
“LORG____.”,
“MOBCI___.”,
“MOBC____.”,
“MOCI____.”,
“MOC_____.”,
“MOOR____.”,
“mtr_____.”,
“nxrg____.”,
“oaalt___.”,
“oq______.”,
“PVCH1___.”,
“qg______.”,
“s_boy___.”,
“uddc2___.”,
“UTI_____.”,
“UTRG____.”,
“UTSBI___.”,
“UTSB____.”,
“uu______.”,
“UVCB____.”,
“uvc_____.”,
“uvf_____.”,
“VABXE___.”,
“VARG____.”,
“vpin____.”,
“VWB_____.”,
“VWRG____.”,
“VXBV____.”,
“VXR_____.”,
“VYL_____.”,
“VYR_____.”,
“WC______.”,
“wg______.”,
“WI______.”,
“WMBI____.”,
“WMB_____.”,
“WMI_____.”,
“WMR_____.”,
“WMTIL___.”,
“wu______.”,
“XPRG____.”,
“xtdr____.”,
“xzi_____.”,
“ZJI__000.”,
“ZJI__001.”,
“ZJI__002.”,
“ZJI__003.”,
“ZJI__004.”,
“ZJI__005.”,
“ZJI__006.”,
“ZJI__007.”,
“ZJI__008.”,
“ZJI_____.”,
“ZJRG_000.”,
“ZJRG_001.”,
“ZJRG_002.”,
“ZJRG_003.”,
“ZJRG_004.”,
“ZJRG_005.”,
“ZJRG_006.”,
“ZJRG_007.”,
“ZJRG_008.”,
“ZJRG____.”,
“ZX______.”,
“ZY______.”};
System.String[] ss = new System.String[]{
“CPI-Regular”,
“Mojo”,
“Frobisher-Normal”,
“Frutiger-BlackCn”,
“Frutiger-Black”,
“Frutiger-ExtraBlackCn”,
“Frutiger-Roman”,
“Frutiger-UltraBlack”,
“Futura-BoldOblique”,
“Futura-Bold”,
“Futura-HeavyOblique”,
“Futura-Heavy”,
“Futura-Oblique”,
“Futura-BookOblique”,
“Futura-Book”,
“Futura”,
“Garamond-Light”,
“AGaramond-BoldItalic”,
“AGaramond-Bold”,
“AGaramond-Italic”,
“AGaramond-Regular”,
“AGaramond-SemiboldItalic”,
“AGaramond-Semibold”,
“Hadriano-ExtraBoldCondensed”,
“Khaki-Two”,
“Helvetica-Black”,
“Helvetica-BoldOblique”,
“Helvetica-Condensed-BoldObl”,
“Helvetica-Condensed-Bold”,
“Helvetica-Condensed-Oblique”,
“Helvetica-Condensed”,
“Helvetica-Compressed”,
“Lithos-Black”,
“Lithos-Regular”,
“Minion-BoldCondensedItalic”,
“Minion-BoldCondense”,
“Minion-CondensedItalic”,
“Minion-Condensed”,
“Minion-Ornaments”,
“TimesNewRomanPS”,
“Nyx”,
“OCRA-Alternate”,
“Ouch”,
“Poetica-ChanceryI”,
“GreymantleMVB”,
“Shuriken-Boy”,
“BermudaLP-Squiggle”,
“Utopia-Italic”,
“Utopia-Regular”,
“Utopia-SemiboldItalic”,
“Utopia-Semibold”,
“SpumoniLP”,
“Univers-CondensedBold”,
“Univers-Condensed”,
“Univers-ExtraBlack”,
“Viva-BoldExtraExtende”,
“Viva-Regular”,
“Pompeia-Inline”,
“CaflischScript-Bold”,
“CaflischScript-Regular”,
“Nueva-BoldExtended”,
“Nueva-Roman”,
“Sanvito-Light”,
“Sanvito-Roman”,
“Critter”,
“Giddyup”,
“Willow”,
“Myriad-BoldItalic”,
“Myriad-Bold”,
“Myriad-Italic”,
“Myriad-Roman”,
“Myriad-Tilt”,
“Cutout”,
“ExPonto-Regular”,
“Chaparral-Display”,
“Postino-Italic”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM-Oblique”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“TektonMM”,
“AdobeSansMM”,
“AdobeSerifMM”
};
Aspose.Pdf.TextInfo[] fonts = new Aspose.Pdf.TextInfo[ss.Length ];
for (int i = 0; i {
fonts[i] = new Aspose.Pdf.TextInfo();
fonts[i].FontName = ss[i];
fonts[i].FontSize = 12;
fonts[i].FontAfmFile = @“C:\PSFONTS\PFM” + s[i] + @“PFM”;
fonts[i].FontOutlineFile = @“C:\PSFONTS” + s[i] + @“PFB”;
fonts[i].IsFontEmbedded = true;
}
MarginInfo margin = new MarginInfo();
margin.Left = 60;
margin.Top = 50;
margin.Right = 95;
margin.Bottom = 60;
Pdf pdf = new Pdf();
pdf.OpenType = OpenType.Auto;
pdf.DestinationType = DestinationType.FitHeight;
pdf.PageSetup.Margin = margin;
Section section1 = pdf.Sections.Add();
Text text1 = new Text(section1);
section1.Paragraphs.Add(text1);
Section section2 = pdf.Sections.Add();
Text text2 = new Text(section2);
section2.Paragraphs.Add(text2);
Section section3 = pdf.Sections.Add();
Text text3 = new Text(section3);
section3.Paragraphs.Add(text3);
Section section4 = pdf.Sections.Add();
Text text4 = new Text(section4);
section4.Paragraphs.Add(text4);
// we are not allowed more than 32 segments
// per Text ???
int n = 0;
for (int i = 0; i {
Segment seg = text1.Segments.Add(fonts[n].FontName );
seg.TextInfo = fonts[n];
}
for (int i = 0; i {
Segment seg = text2.Segments.Add(fonts[n].FontName );
seg.TextInfo = fonts[n];
}
for (int i = 0; i {
Segment seg = text3.Segments.Add(fonts[n].FontName);
seg.TextInfo = fonts[n];
}
for (; n {
Segment seg = text4.Segments.Add(fonts[n].FontName);
seg.TextInfo = fonts[n];
}
pdf.Save(“C:/WINNT/ACTIVEPDF/Fallbeurteilung2.pdf”);
// INDEX OUT OF BOUNDS EXCEPTION IN ASPOSE.PDF.DLL
}
Hi,
Thank you for considering Aspose.
I am unable to reproduce the error. There is no restriction of segments. I have checked with the following code and it worked for me. Please paste or send me your code and I will investigate this issue. For your reference. Here is the code I use:
[ C# ]
Pdf pdf = new Pdf();
Section section1 = pdf.Sections.Add();
Aspose.Pdf.TextInfo textInfo = new Aspose.Pdf.TextInfo();
// define fonts, etc.
textInfo.FontName = "Arial";
textInfo.FontSize = 12;
textInfo.Alignment = Aspose.Pdf.AlignmentType.Justify;
pdf.TextInfo = textInfo;
Aspose.Pdf.Text txtLeft = new Aspose.Pdf.Text("Testing 32 Segments", textInfo);
Segment seg1 = new Segment(" This is Test Segment ");
Segment seg2 = (Segment)seg1.CompleteClone();
Segment seg3 = (Segment)seg1.CompleteClone();
Segment seg4 = (Segment)seg1.CompleteClone();
Segment seg5 = (Segment)seg1.CompleteClone();
Segment seg6 = (Segment)seg1.CompleteClone();
Segment seg7 = (Segment)seg1.CompleteClone();
Segment seg8 = (Segment)seg1.CompleteClone();
Segment seg9 = (Segment)seg1.CompleteClone();
Segment seg21 = (Segment)seg1.CompleteClone();
Segment seg22 = (Segment)seg1.CompleteClone();
Segment seg23 = (Segment)seg1.CompleteClone();
Segment seg24 = (Segment)seg1.CompleteClone();
Segment seg25 = (Segment)seg1.CompleteClone();
Segment seg26 = (Segment)seg1.CompleteClone();
Segment seg27 = (Segment)seg1.CompleteClone();
Segment seg28 = (Segment)seg1.CompleteClone();
Segment seg29 = (Segment)seg1.CompleteClone();
Segment seg20 = (Segment)seg1.CompleteClone();
Segment seg11 = (Segment)seg1.CompleteClone();
Segment seg12 = (Segment)seg1.CompleteClone();
Segment seg14 = (Segment)seg1.CompleteClone();
Segment seg13 = (Segment)seg1.CompleteClone();
Segment seg15 = (Segment)seg1.CompleteClone();
Segment seg16 = (Segment)seg1.CompleteClone();
Segment seg17 = (Segment)seg1.CompleteClone();
Segment seg18 = (Segment)seg1.CompleteClone();
Segment seg19 = (Segment)seg1.CompleteClone();
Segment seg10 = (Segment)seg1.CompleteClone();
Segment seg30 = (Segment)seg1.CompleteClone();
Segment seg31 = (Segment)seg1.CompleteClone();
Segment seg32 = (Segment)seg1.CompleteClone();
Segment seg33 = (Segment)seg1.CompleteClone();
Segment seg34 = (Segment)seg1.CompleteClone();
Segment seg35 = (Segment)seg1.CompleteClone(); Segment seg36 = (Segment)seg1.CompleteClone();
Segment seg37 = (Segment)seg1.CompleteClone();
txtLeft.Segments.Add(seg1);
txtLeft.Segments.Add(seg2);
txtLeft.Segments.Add(seg3);
txtLeft.Segments.Add(seg4);
txtLeft.Segments.Add(seg5);
txtLeft.Segments.Add(seg6);
txtLeft.Segments.Add(seg7);
txtLeft.Segments.Add(seg8); txtLeft.Segments.Add(seg9);
txtLeft.Segments.Add(seg10);
txtLeft.Segments.Add(seg11);
txtLeft.Segments.Add(seg12); txtLeft.Segments.Add(seg13);
txtLeft.Segments.Add(seg14);
txtLeft.Segments.Add(seg15);
txtLeft.Segments.Add(seg16); txtLeft.Segments.Add(seg17);
txtLeft.Segments.Add(seg18);
txtLeft.Segments.Add(seg19);
txtLeft.Segments.Add(seg20); txtLeft.Segments.Add(seg21);
txtLeft.Segments.Add(seg22);
txtLeft.Segments.Add(seg23);
txtLeft.Segments.Add(seg24); txtLeft.Segments.Add(seg25);
txtLeft.Segments.Add(seg26);
txtLeft.Segments.Add(seg27);
txtLeft.Segments.Add(seg28); txtLeft.Segments.Add(seg29);
txtLeft.Segments.Add(seg30);
txtLeft.Segments.Add(seg31);
txtLeft.Segments.Add(seg32); txtLeft.Segments.Add(seg33);
txtLeft.Segments.Add(seg34);
txtLeft.Segments.Add(seg35);
txtLeft.Segments.Add(seg36);
section1.Paragraphs.Add(txtLeft);
pdf.Save("D:/AsposeTest/SegmentsTest.pdf");
If you still got error please try with latest version of Aspose.PDF.
Thanks.
Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html