Pdf export is corupted

43 views Asked by At

I'm trying to export a pdf/dox document. I have the byte[] array and I tried these 2 variations that i found on the internet:

        var generalPath = "generalPath";
        // returns the pdf byte array
        var pdfData = invoiceProcessor.PreviewPdfInvoice(invoice.Id, company.Id, CrossCuttingConcerns.Enums.LanguageEnum.EN);

        System.IO.File.WriteAllBytes(generalPath + "\\wabPDF.pdf", pdfData.PdfContent);

        using (Stream file2 = System.IO.File.OpenWrite(generalPath + "\\wPDF.pdf"))
        {
            file2.Write(pdfData.PdfContent, 0, pdfData.PdfContent.Length);
        }

Neither of these work, and both of them are creating a corrupted PDF.

0

There are 0 answers