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 Feb 05, 2019 2:09 pm

Hi

I am wondering if you can help at all.

I get an error when printing a specific document. I tried the latest hotfix (Spire.PDF Pack(Hot Fix) Version:5.1.33) and it still occurs.

The error is:

mscorlib

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Stack Trace: at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at spr᡹.ᜀ(spr᝴ A_0, RectangleF A_1, String A_2)
at spr᡹.ᜀ(sprᝲ A_0)
at spr᡹.᜹()
at spr᡹.ᜋ(Boolean A_0)
at spr᡹.᜷()
at sprᝰ.ᜀ(PrintPageEventArgs A_0, PdfPageBase A_1, RectangleF A_2)
at sprᝰ.ᜂ(PrintPageEventArgs A_0)
at sprᝰ.ᜀ(Object A_0, PrintPageEventArgs A_1)
at System.Drawing.Printing.PrintDocument.OnPrintPage(PrintPageEventArgs e)
at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at sprᝰ.ᜄ()
at Spire.Pdf.PdfDocument.Print()
at DocumentManagementService.Utility.ActualPrint(clsPRDocumentInfo Documents, String SelectedPrinter) in D:\Source\OEA\Release6.0\Services\DocumentManagementService\DMSI\DMSI\Utilities\Utility.cs:line 152

The code which tries to print the document looks like this, where I simply have the Memory Stream go in via the Documents object, and works for many other documents :

public static bool ActualPrint(clsPRDocumentInfo Documents, String SelectedPrinter)
{
try
{
Spire.Pdf.PdfDocument spiredoc = new Spire.Pdf.PdfDocument();
spiredoc.LoadFromStream(Documents.DocMS);
spiredoc.PrintSettings.SelectSinglePageLayout(Spire.Pdf.Print.PdfSinglePageScalingMode.FitSize);
System.Windows.Forms.PrintDialog dialogPrint = new System.Windows.Forms.PrintDialog();

dialogPrint.AllowPrintToFile = true;
dialogPrint.AllowSomePages = true;
dialogPrint.PrinterSettings.MinimumPage = 1;
dialogPrint.PrinterSettings.MaximumPage = spiredoc.Pages.Count;
dialogPrint.PrinterSettings.FromPage = 1;
dialogPrint.PrinterSettings.ToPage = spiredoc.Pages.Count;
dialogPrint.UseEXDialog = false;

int From = 1;
int To = spiredoc.Pages.Count;

dialogPrint.PrinterSettings.DefaultPageSettings.Landscape = false;
spiredoc.PageSettings.Orientation = PdfPageOrientation.Portrait;
spiredoc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle0;

if ((SelectedPrinter != null))
dialogPrint.PrinterSettings.PrinterName = SelectedPrinter;

if ((SelectedPrinter == null))
{
if (dialogPrint.ShowDialog() == DialogResult.OK)
{
if (dialogPrint.PrinterSettings.FromPage > 0)
From = dialogPrint.PrinterSettings.FromPage;
if (dialogPrint.PrinterSettings.ToPage > 0)
To = dialogPrint.PrinterSettings.ToPage;
spiredoc.PrintSettings.SelectPageRange(From,To);
spiredoc.PrintSettings.PrinterName = dialogPrint.PrinterSettings.PrinterName;
SelectedPrinter = dialogPrint.PrinterSettings.PrinterName;
spiredoc.Print();
//System.Drawing.Printing.PrintDocument printDoc = spiredoc.PrintDocument;
//dialogPrint.Document = printDoc;
//printDoc.Print();
}
}
else
{
if (dialogPrint.PrinterSettings.FromPage > 0)
From = dialogPrint.PrinterSettings.FromPage;
if (dialogPrint.PrinterSettings.ToPage > 0)
To = dialogPrint.PrinterSettings.ToPage;
spiredoc.PrintSettings.SelectPageRange(From, To);
spiredoc.PrintSettings.PrinterName = SelectedPrinter;
spiredoc.Print();
//System.Drawing.Printing.PrintDocument printDoc = spiredoc.PrintSettings.PrintDocument;
//dialogPrint.Document = printDoc;
//printDoc.Print();
}
return true;
}
catch (Exception ex)
{
OlympusEventLog.WriteException("Utility PrintDocument method", ex);
return false;
}
}

The offending document is attached.

[email protected]
 
Posts: 3
Joined: Wed Jan 09, 2019 3:54 pm

Wed Feb 06, 2019 3:48 am

Hi,

Thanks for your inquiry.
I have reproduced your issue and logged it in our bug tracking system. We will let you know when the issue is fixed.
Sorry for the inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Feb 06, 2019 8:53 am

Thank you for the update.

[email protected]
 
Posts: 3
Joined: Wed Jan 09, 2019 3:54 pm

Thu Feb 28, 2019 10:15 am

Hi,

Glad to inform you the issue is solved in Spire.PDF Pack(Hot Fix) Version:5.2.15.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Mar 01, 2019 10:32 am

This appears to have fixed the problem.

Thank you.

[email protected]
 
Posts: 3
Joined: Wed Jan 09, 2019 3:54 pm

Mon Mar 04, 2019 2:07 am

Hi,

Thanks for your feedback.
If there is any question, just feel free to contact us.
Have a nice day!

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF

cron