I've got a customer who is trying to create a memorystream of a multipage document to send to another process as a PDF.
01 | var pdf = new MemoryStream(); |
02 |
03 | using (var lfSession = new Session()) |
04 | { |
05 | var lfRepository = new RepositoryRegistration( |
06 | LaserficheConfiguration.ServerName, |
07 | LaserficheConfiguration.RepositoryName); |
08 |
09 | |
10 | lfSession.LogIn(lfRepository); |
11 | |
12 |
13 | //Verify if id is a valid Entry. This is here because |
14 | //GetDocumentInfo throws an error when EntryID is not found rather than returning a null. |
15 | if (Entry.TryGetEntryInfo(id, lfSession) != null ) |
16 | { |
17 | var doc = Document.GetDocumentInfo(id, lfSession).GetLatestVersion(); |
18 | DocumentExporter docExp = new DocumentExporter(); |
19 | docExp.ExportPdf(doc, ((DocumentInfo)doc).AllPages, PdfExportOptions.None, pdf); |
20 | } |
21 | } |
22 |
23 | return File(pdf.ToArray(), "application/pdf" , $ "{id}.pdf" ); |
So from reading the SDK documentation, it looks like documentexporter.exporter does not support streaming multipage documents in the PDF format.
From the sdk for that method:
1 | Remarks |
2 |
3 | The Export method cannot export multi-page documents to byte arrays, so this method will fail if the specified format is PDF. |
So does anyone have any good solutions for this? Do we need to use third party tools like iTextSharp to create the pdf from a tiff stream? Or can you send multiple pages one at a time to the memory stream array and have them show up as a multipage PDF?