empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
492 stars 114 forks source link

Can't retrieve stream length error - in old version? #99

Closed dangdkhanh closed 4 months ago

dangdkhanh commented 6 months ago

Hi,

Using one = PdfReader.Open(filepath, PdfDocumentOpenMode.Import) one.Close() End Using

This code threw an exception with the attached pdf. Merge_1.1.pdf

I tried to build latest version but got an error. Is there any way to fix?

Windows11-24H2 I cannot build the project. thanks you!

image

StLange commented 6 months ago

Hi dangdkhanh,

you are right, PDFsharp crashes while opening your file. We will fix this.

The second issue has obviously to do with gitversion. Sometimes it simply crashes when it founds no tag. Try check ‘git tag’. Should lists tags. If not, set one as described in README.md.

I tried cloning the PDFsharp repo from github in a new directory, run ‘.\dev\download-assets.ps1’ und ‘dotnet build’. Compiles on my Windows 10 machine. Then run ‘.\PdfSharp.sln’ and compile with VS. No problems. We will check it with Windows 11.

StLange commented 6 months ago

The producer app of your PDF file creates the MetaData dictionary without a stream length. So technically the file is no valid PDF. However, Acrobat accepts this file and correct it when saved. We fixed this equally in PDFsharp. It is in the next preview. It did never work in a previous version of PDFsharp.

dangdkhanh commented 6 months ago

Great, Thanks you, Team!

StLange commented 4 months ago

Done in 6.1.0 Preview 3