0

I have a byte [], that I know it's a PDF, what I need to do now, it's to convert it to PDF format, so I can read it and check some lines inside of it?

How can I do this? I have access to DevExpress frameworks if its help.

Thanks

Gonçalo Bastos
  • 376
  • 3
  • 16
  • 3
    "to convert it to PDF format" - you said you know the `byte[]` contains the bytes of a PDF file, therefore it is already in the PDF file format. Are you asking how to write it to a file? Have you tried `File.WriteAllBytes`? – ProgrammingLlama Nov 16 '22 at 09:10
  • @ProgrammingLlama I need to make everything on client side, So yes I know that the `byte[]` it's already a PDF and I need to convert it from `byte[]` to an actual file and read some content inside of it. – Gonçalo Bastos Nov 16 '22 at 09:12
  • @ProgrammingLlama I don't want to create an actual document on a folder, I want everything in memory or something like that if it's possible – Gonçalo Bastos Nov 16 '22 at 09:18
  • 1
    Then you need a PDF library for .NET. I think all the kool kids are using iTextSharp, though I could be mistaken. – ProgrammingLlama Nov 16 '22 at 09:19

1 Answers1

1

I guess you're using PdfViewer control.

This control has a method LoadDocument and one of the overloads accepts stream a parameter. So you can create a MemoryStream from the array and load this stream into your PdfViewer.

var ms = new MemoryStream(mybytearray);
pdfViewer1.LoadDocument(ms);

UPDATE:

You should use PdfDocumentProcessor. This class has a method LoadDocument and one of the overloads accepts stream as a parameter. So you can create a MemoryStream from the array and load this stream into your PdfDocumentProcessor.

var ms = new MemoryStream(mybytearray);
pdfDocumentProcessor1.LoadDocument(ms);

Then you can access the content of the document. For example you can use GetText method.

Marko Juvančič
  • 5,792
  • 1
  • 25
  • 41