Last Page first

I am building a last page first function but it doesn’t seem to work as expected. It does indeed put the last page first but it doesn’t do a move but a copy. See code:

Public Sub PdfLastPageFirst(bytaPdfBytesIn As Byte(), ByRef bytaPdfBytesOut As Byte())

Using objDoc = New PDF.PDFDoc(bytaPdfBytesIn, bytaPdfBytesIn.Length)

Dim intPageCnt = objDoc.GetPageCount
objDoc.MovePages(1, objDoc, intPageCnt, intPageCnt, PDF.PDFDoc.InsertFlag.e_none)
bytaPdfBytesOut = objDoc.Save(Nothing)

End Using

End Sub

Sorry the API is not clear, but that function is for moving a Page from one document to another, which involves replicating data. You can see this because the function is called on an instance, but also takes a PDFDoc object as a parameter.

If you want to re-arrange pages in the same document use the following code.

Dim itr As PageIterator = objDoc.GetPageIterator(objDoc.GetPageCount()) Dim lastPage As Page = itr.Current() objDoc.PageRemove(itr) objDoc.PushPageFront(lastPage)