logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
paleise  
#1 Posted : Friday, October 20, 2017 3:33:48 AM(UTC)
paleise

Rank: Advanced Member

Groups: Registered
Joined: 10/13/2017(UTC)
Posts: 52
Germany
Location: Freiburg

Thanks: 3 times
Hi,
when I try to delete the last page of a pdf, I get the error, that the index is out of range:

PdfDocument fullDocument = PdfDocument.Load(pdfFile);
int lastPage = fullDocument.Pages.Count - 1
fullDocument.Pages.DeleteAt(lastPage);

fullDocument.Pages.Count - 2 or fullDocument.Pages.Count - 3 works fine

How can I delete the last page?

Thanks for your time!

Regards Peter
Paul Rayman  
#2 Posted : Saturday, October 21, 2017 5:35:23 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,123

Thanks: 8 times
Was thanked: 131 time(s) in 128 post(s)
paleise  
#3 Posted : Monday, October 23, 2017 2:09:33 AM(UTC)
paleise

Rank: Advanced Member

Groups: Registered
Joined: 10/13/2017(UTC)
Posts: 52
Germany
Location: Freiburg

Thanks: 3 times
Hi,
many thanks for the resolution, great job.

Peter
Ilgk48  
#4 Posted : Saturday, February 1, 2025 11:46:32 PM(UTC)
Ilgk48

Rank: Newbie

Groups: Registered
Joined: 2/1/2025(UTC)
Posts: 1
Italy
Location: Gorizia

Hallo,
I'm just a new user and yesterday I have installed version 4.96.2704 with Nuget Manager in Visual Studio 2022.

Quote:
"when I try to delete the last page of a pdf, I get the error, that the index is out of range:"
/Quote

My three lines of code:
Dim Index as Integer
Index = PdfToolStripPages2.PdfViewer.CurrentIndex
IssuePdfViewer2.Document.Pages.DeleteAt(Index)

Well: I'm getting the above quoted error if Index equals the Index of the last page!
Not fixed 7 years ago?

Paolo.
Paul Rayman  
#5 Posted : Wednesday, February 5, 2025 4:46:58 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,123

Thanks: 8 times
Was thanked: 131 time(s) in 128 post(s)
Looks like it's back!

Will be fixed in the next release.
Thanks!
Users browsing this topic
Similar Topics
Delete Last Page in pdfViewer (Bug Report & Technical Support)
by paleise 10/2/2025 9:08:10 AM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.