I am reading multiple pdf's in to a list of memorystreams. Once I have all the pdf's added to the list of memoryStream, this is my code to flatten and save to pdfFileName Does this vb code look correct or is there another way to flatten the pdfFileName?
Dim finalDoc As New PdfDocument
''Merge the PDFs stored in the Array into one PDF
Dim mStreamArray As MemoryStream() = pMemeoryStream.ToArray()
mStreamList.Clear() ''Empty the list of PDF's
PdfDocumentBase.Merge(finalDoc, mStreamArray)
finalDoc.Save(pdfFileName)
finalDoc.Close()
'' load existing document to flatten it again
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(pdfFileName)
For Each loadedPage As PdfLoadedPage In loadedDocument.Pages
For Each annotation As PdfLoadedAnnotation In loadedPage.Annotations
annotation.Flatten = True
Next
Next
'Dim loadedForm As PdfLoadedForm = loadedDocument.Form
loadedDocument.Form.Flatten = True
loadedDocument.Save(pdfFileName)
loadedDocument.Close(True)
loadedDocument.Dispose()