I would like to copy some pages from original document tonew pdf Document.
my Source code is based on merge document example proveded Telerik documenttaion:
Public Function ExtractPagesToPDF(pdfDocument() As Byte, pages() As Integer) As Byte() Implements IPdfPageExtractor.ExtractPagesToPDF Dim ms = New MemoryStream() Using pdfWriter = New PdfStreamWriter(ms) pdfWriter.Settings.DocumentInfo.Author = "TMS" pdfWriter.Settings.WriteAnnotations = True Using pdfStream = New MemoryStream(pdfDocument) Dim document = New PdfFileSource(pdfStream) For Each index In pages If index >= document.Pages.Count Then Throw New ArgumentException($"Page index {index} > Document page count {document.Pages.Count}.") End If pdfWriter.WritePage(document.Pages(index)) Next ms.Position = 0 Return ms.ToArray() End Using End Using End Function
if I try open new document with with Telerik WPF RadPdfViewer my programm throws exception:
NotSupportedException: StartXRef keyword cannot be found.
Do I miss some settings?