PDFiumSharp
PDFiumSharp copied to clipboard
Fixes for loading document from stream
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")) {