empira / PDFsharp-1.5

A .NET library for processing PDF
MIT License
1.28k stars 588 forks source link

Bug? PdfSharp.Pdf.IO.PdfReader.TestPdfFile(stream) #92

Closed wstaelens closed 1 year ago

wstaelens commented 5 years ago

When using PdfSharp.Pdf.IO.PdfReader.TestPdfFile(Stream)

This code will fail when you were working with the stream before and if the stream position is not manually set to 0.

Is this expected behavior that you need to manually set the stream.Position = 0; before using TestPdfFile(Stream) to ensure this code always correctly works, or is the position reset missing in the source code ( https://github.com/empira/PDFsharp/blob/master/src/PdfSharp/Pdf.IO/PdfReader.cs#L124 ) ?

I guess it is a bug, otherwise API documentation should be updated.

TH-Soft commented 5 years ago

I think the documentation should be updated. AFAIK not all streams allow setting the position. The PDFsharp could check if the stream supports setting the position and set it to 0 if supported - but that would make documentation even more complicated.