Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jul 14, 2020 5:06 am

Hi All,
I am trying to convert 2 mb html file to pdf stream getting below error.


Index was outside the bounds of the array.
at spr᡽.ᜀ(Stream A_0)
at spr᡽.ᜀ(Stream A_0, Boolean A_1)
at spr᡽..ctor(Stream A_0)
at Spire.Pdf.PdfDocument.LoadFromStream(Stream stream)
at ProviderSearchApi.PDFHelper.Htmltopdf(String myModel, String printTmestampstring) in C:\ProviderSearch\PhaseV\API\ProviderSearchApi\ProviderSearchApi\PDFHelper.cs:line 240


Here My code :
myModel = myModel.Replace("cdk-global-scrollblock ratna", "#");
MemoryStream pdfstream = new MemoryStream();
Spire.Pdf.HtmlConverter.Qt.HtmlConverter.Convert(myModel,
pdfstream,
//enable javascript`
true,
//load timeout
100 * 50000,
//page size
PdfPageSize.A4,
//page margins
new Spire.Pdf.Graphics.PdfMargins(20,40),
//load from content type
LoadHtmlType.SourceCode
);

PdfDocument doc = new PdfDocument();
doc.LoadFromStream(pdfstream);
AddTimeStamp(doc, printTmestampstring);
// AddPageNumber(doc);
doc.SaveToStream(pdfstream);

pdfstream.Position = 0;
FileStreamResult filestreamResult = new FileStreamResult(pdfstream, "application/octet-stream");
return filestreamResult;

Please check attaced file and help me on this.

Thanks
Madhu

myarra1228
 
Posts: 8
Joined: Mon Jun 29, 2020 2:59 am

Tue Jul 14, 2020 7:42 am

Hello,

Thanks for your inquiry.
I tested your code and found that the PDF was not generated during the conversion process, please see the attached image. Thus, when using the LoadFromStream method to load the pdfstream, you will get the error "Index was outside the bounds of the array". This issue has been logged into our bug tracking system with the ticket SPIREPDF-3419.
We will inform you if there is any update. Sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Oct 09, 2020 5:19 am

Hi Team, I am also facing same issue could you please give solution for this please. Why the document is not loading.
Thank you.

manojraog
 
Posts: 11
Joined: Mon Aug 03, 2020 4:51 am

Fri Oct 09, 2020 7:10 am

Hello Manoj,

Thanks for your inquiry.
You mean you got the error "Index was outside the bounds of the array" when loading a PDF file, right? Could you please share your PDF file with us for further investigation? You could upload it here or send it to us (support@e-iceblue.com) via email.
Or if I misunderstood, please provide more details to help us further look into your issue. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Oct 09, 2020 3:15 pm

Getting issue like this in production environment. Please suggest me what to do

System.IndexOutOfRangeException: Index was outside the bounds of the array. at spr㯷.ᜀ(Stream A_0) at spr㯷..ctor(Stream A_0, Boolean A_1) at
Spire.Pdf.PdfDocument.LoadFromFile(String filename)

manojraog
 
Posts: 11
Joined: Mon Aug 03, 2020 4:51 am

Sat Oct 10, 2020 1:51 am

Hello,

Thanks for your response.
You mean you use the plugin method to convert html to PDF, but the application throws exception when loading the generated PDF file?
Now the latest version is Spire.PDF Pack(Hot Fix) Version:6.9.16, if you are using an older version, I'd suggest you download this version and try again.
If the issue persists after trying, please provide your input files (HTML file and PDF file) and your test code to help us reproduce your issue and solve it. Thanks in advance for your assistance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Oct 23, 2020 9:25 am

Hi Team,
We need fix for older version only because we did not get permission to upgrade spire version due to some dependencies. Please help us to resolve this issue on older viersion.

manojraog
 
Posts: 11
Joined: Mon Aug 03, 2020 4:51 am

Fri Oct 23, 2020 9:46 am

Hello,

Sorry we do not maintain the old version. The bug fixes will only be included in the latest version of our Spire.PDF. Hope you can understand.
Now the latest version is Spire.PDF Pack(Hot Fix) Version:6.10.4. If you still get errors when using this version, please provide your input files (HTML file and PDF file) and your test code to help us reproduce your issue and solve it. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Nov 03, 2020 10:09 am

Hi Team,
I am facing System.IndexOutOfRangeException: Index was outside the bounds of the array. at spr㯷.ᜀ(Stream A_0) at spr㯷..ctor(Stream A_0, Boolean A_1) some times and if I generate PDF for second time after getting this issue its working. what will be the issue. I need to know why this issue is coming are we missing any thing to include while generating PDF file?
Please give us your suggestions.
Thank you

manojraog
 
Posts: 11
Joined: Mon Aug 03, 2020 4:51 am

Wed Nov 04, 2020 1:39 am

Hello,

Sorry to tell you that based on the information currently known, we are unable to infer what caused your issue. Could you please provide more detailed information to help us further analyze? For example, your input files (HTML file and PDF file) and your full test code. We appreciate for your assistance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Mar 09, 2021 1:03 pm

attached html give me the error: index was outside.....

Can you please check and revert it.

This below line of code causing the error:
PdfSharp.Pdf.PdfDocument doc = PdfGenerator.GeneratePdf(result, PdfSharp.PageSize.A4);

result containing that html string.

Version:Assembly HtmlRenderer.PdfSharp, Version=1.5.1.0, Culture=neutral, PublicKeyToken=null

Nishadh333
 
Posts: 1
Joined: Tue Mar 09, 2021 12:56 pm

Wed Mar 10, 2021 7:54 am

Hello,

Thanks for your post.

Sorry the code you used has nothing to do with our Spire.PDF component.

However, our Spire.PDF also supports converting HTML string to PDF. You can refer to this tutorial and give it a try. If you have any questions related to our products, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Mar 19, 2021 7:36 am

Hello,

Has your issue been resolved? Have you tried to use our Spire.PDF? Do you think there are any improvements in our products?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Nov 16, 2023 8:15 am

Hi,

I'm using Spire.PDF 9.11.4 and I'm suprised that this issued has not been fixed yet.
Is ticket SPIREPDF-3419 fixed?

I tried to use HtmlConverter.Convert() to a stream with a big string HTML but the stream returned is empty. So LoadFromStream() return the error index out of range.
I tried also to use HtmlConverter.Convert to a file with a big string HTML but the file is not even created but not error is returned by the function. So when I call LoadFromFile(), it throw an error "File not exist".

Thank you
Jonathan

jonathan.joaquim
 
Posts: 3
Joined: Tue Aug 30, 2022 8:25 am

Thu Nov 16, 2023 8:34 am

Hello jonathan.joaquim,

Thanks for your inquiry.
I sincerely apologize for the inconvenience caused by the unresolved issue SPIREPDF-3419. Our development team is currently working diligently to investigate and resolve this issue.
To further investigate the problem you encountered with the failed conversion of HTML to PDF files, we kindly request the following information from you. Your cooperation in providing these details will greatly assist us in resolving the issue. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.
1) Your input HTML file.
2) Your complete test code.
3) Your test environment, such as OS info (E.g. Windows 10, 64-bit) and region setting (E.g. China, Chinese).
4) Your application type, such as Console app (. Net Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF