0

I am getting a pdf through post request from frontend as an IFormFile form and I want to take that and pass it to pdfreader() in itext7 package. so far i could only pass with the path as string i dont have any path to specify.

Asvinth A
  • 3
  • 2
  • Does the `PDFReader` accept `MemoryStream`? If yes, then pass the data from the formfile. If no, you might have to first upload your server and use the file path. – bolkay May 21 '20 at 16:52

1 Answers1

1

Pdfreader accepts System.IO.MemoryStream, or any generic System.IO.Stream, as can be seen in the API documentation: https://api.itextpdf.com/iText7/dotnet/7.1.11/classi_text_1_1_kernel_1_1_pdf_1_1_pdf_reader.html

PdfReader (IRandomAccessSource byteSource, ReaderProperties properties)
Constructs a new PdfReader. More...

PdfReader (Stream @is, ReaderProperties properties)
Reads and parses a PDF document. More...

PdfReader (FileInfo file)
Reads and parses a PDF document. More...

PdfReader (Stream @is)
Reads and parses a PDF document. More...

PdfReader (String filename, ReaderProperties properties)
Reads and parses a PDF document. More...

PdfReader (String filename)
Reads and parses a PDF document. More...

So you can pass the data from the IFormFile form.

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
  • Van Gaasse The IFormFile I am converting it into a byte array for uploading it into cloud storage after that I'm converting the byte array to memory stream like this `Stream stream = new MemoryStream(dataArr);` its still showing error . – Asvinth A May 26 '20 at 14:23
  • Ask a new question and add reproducible code to your question. And a stacktrace. – Amedee Van Gasse Jun 10 '20 at 12:15