PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Non-negative number required - compressed object
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3567
Page 1 of 1

Author:  suresh.kau05 [ Fri Apr 07, 2017 12:06 pm ]
Post subject:  Non-negative number required - compressed object

Hi Team,

We are using PdfSharp 1.3 version, while processing the PDF file we are getting error "Non-negative number required".
So to check the issue we have downloaded the latest version 1.5 beta 3 and checking in debug mode.

I am getting this issue while reading the below code when it tries to read the indirect objects from the PDF file.
File Name: PdfReader.cs

PdfReference[] irefs = document._irefTable.AllReferences

PdfReference iref = irefs[idx];
if (iref.Value == null)

Getting the below error message:

Exception message: Non-negative number required.
Parameter name: value

Observation while debugging the source code, I found in the below section of

// 3rd: Create iRefs for all compressed objects.
PdfCrossReferenceStream.CrossReferenceStreamEntry item = xrefStream.Entries[idx2];

// Is type xref to compressed object?
if (item.Type == 2)
{
// Here it is adding the null value in the dictionary object named "objectStreams"
}

Please find below stack trace details:

at System.IO.FileStream.set_Position(Int64 value)
at PdfSharp.Pdf.IO.Lexer.set_Position(Int32 value) in ..\PDFsharp\src\PdfSharp\Pdf.IO\Lexer.cs:line 71
at PdfSharp.Pdf.IO.Parser.MoveToObject(PdfObjectID objectID) in ..\PDFsharp\src\PdfSharp\Pdf.IO\Parser.cs:line 80
at PdfSharp.Pdf.IO.Parser.ReadObject(PdfObject pdfObject, PdfObjectID objectID, Boolean includeReferences, Boolean fromObjecStream) in ..\PDFsharp\src\PdfSharp\Pdf.IO\Parser.cs:line 121
at PdfSharp.Pdf.IO.Parser.GetStreamLength(PdfDictionary dict) in ..\PDFsharp\src\PdfSharp\Pdf.IO\Parser.cs:line 333
at PdfSharp.Pdf.IO.Parser.ReadObject(PdfObject pdfObject, PdfObjectID objectID, Boolean includeReferences, Boolean fromObjecStream) in ..\PDFsharp\src\PdfSharp\Pdf.IO\Parser.cs:line 263
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider) in ..\PDFsharp\src\PdfSharp\Pdf.IO\PdfReader.cs:line 430

Please find attached file for More Information.

Please help to sort out the issue with the PDFsharp 1.5 beta version.

Thanks & Regards,
Suresh

Attachments:
File comment: Source File Name: Parser.cs
PdfObjectStream Error.png
PdfObjectStream Error.png [ 75.44 KiB | Viewed 16059 times ]

Author:  chameleon [ Wed May 17, 2023 6:05 am ]
Post subject:  Re: Non-negative number required - compressed object

same error happened on my api .net core 5 and this lib version 1.50.5147

Author:  TH-Soft [ Wed May 17, 2023 6:39 am ]
Post subject:  Re: Non-negative number required - compressed object

chameleon wrote:
same error happened on my api .net core 5 and this lib version 1.50.5147
If you are able to replicate the issue with the latest preview of PDFsharp 6.0.0, please use the Issue Submission Template to let us investigate it.
https://docs.pdfsharp.net/General/IssueReporting.html

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/