PDFiumSharp icon indicating copy to clipboard operation
PDFiumSharp copied to clipboard

Fixes for loading document from stream

Open avonwyss opened this issue 6 months ago • 2 comments

The PdfDocument constructor which accepts a stream and the FPDF_LoadDocument methods were confusing, since they did not use their "stream" and "count" parameters, but instead the low-level undocumented "fileRead".

I cleaned this up, and added a small improvement when using MemoryStream streams (direcly copy from buffer instead of reading from stream). Successfully tested the functionality with the Test.Console application:

using (var docStream = new MemoryStream()) {
    using (var srcStream = new FileStream("TestDoc.pdf", FileMode.Open))
        srcStream.CopyTo(docStream);
    docStream.Seek(0, SeekOrigin.Begin);
    using (var doc = new PdfDocument(docStream, 0, "password")) {

avonwyss avatar Jul 29 '25 00:07 avonwyss