Draw error: Index was outside the bounds of the array draw

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  Draw error: Index was outside the bounds of the array draw

DynamicPDF CoreSuite for .NET (v5) Forum

Hi cete support!

I am Pablo, from papyrum nexus (spain).

We are developing an scanning application. We are trying the application scanning more than 80 documents at once.

Then, we use the draw method and get the this error: "Index was outside the bounds of the array draw".
We are getting this error after having saved 60 documents aproximately.

This is our code:

  Try
                  ceteDocumentoPDF.Draw(Path.Combine(sRutaImagenes, sNombreImagen))
                Catch fallo As Exception
                       MensajeError(fallo.ToString)
                End Try

Its difficult to explain but, when we debug the application and stop in the catch line, if we return the point to de draw method and delete the pdf fisically, then the draw method works.

I hope you can understand my poor english.

Thanks in adavance,

Pablo L.G.





Posted by a ceTe Software moderator
Hello Pablo,

Are you merging existing PDF documents to make a single PDF and saving it to disk? Are you drawing each PDF (80 PDFs you have) to disk by doing some operation with the source PDF? The error you are getting is probably because of some input PDF document you are using. Can you please narrow it down to see which input PDF is causing this and please send over the PDF document and the code you are using to our Support Team so that they can look into it further?

Thanks,
ceTe Software Support Team.
Hello,

We are not merging existing PDF documents, we are scanning documents with a scanner. Then, we do this:

for each .... 'bucle to add pages to ceteDocument
     Dim arrayBytes As Byte()
     Dim ms As New MemoryStream

'this line save the document into the ms memorystream
    ltCodecs.Save(ImageList.Image, ms, RasterImageFormat.CcittGroup4, 1, 1, 1, 1, CodecsSavePageMode.Overwrite)
                   
    arrayBytes = ms.ToArray
    CType(ms, IDisposable).Dispose()

    Dim cetePagina As Page = ImageData.GetImage(arrayBytes).GetPage
    ceteDocumentoPDF.Pages.Add(cetePagina)
next

After this, we add XMP metadata and sign the document:

ceteDocumentoPDF.XmpMetadata = ceteMetadatosXmp
ceteDocumentoPDF.Sign(oConfiguracion.ConCertificadodig, oCerFirma, True)

And then we save the document:

Try                     ceteDocumentoPDF.Draw(Path.Combine(sRutaImagenes, sNombreImagen))
Catch ex As Exception

End Try



This is mostly our code. Its important to know that the error does not always occurs with the same document.

Thanks very much,

Pablo L.G.
Posted by a ceTe Software moderator
Hello Pablo,

The process you are doing should work fine and there is nothing wrong in doing this way. However there might be some image which is causing this. Can you please trace it out and see if any specific image is causing this and please send it over to our Support Team so that they can look into it further?

Thanks,
ceTe Software Support Team.
Hi,

I traced it out and there is not an specific image causing the error...
I realized that in the .net function where we save all the documents scanned, always fails in number 11:

For iContador as integer = 0 to scannedDocuments.count-1

'Our code to save documents (the same as I wrote in previous post)


next

It always fails when icontador = 11 but it is not always the same phisical document.

I have "solved" the problem, changing the function to save documents in intervals of 10 documents.

Thanks very much.

All times are US Eastern Standard time. The time now is 4:29 PM.