Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Mon Apr 04, 2016 8:44 pm
I'm trying to do some quick testing to see if I can use this software to replicate PDF pages and then place a banner page at the beginning of the PDF. I've got the replication working but can't seem to get the banner page to insert at the beginning. From an example I found, it looks like I should be able to insert a page at index 0 but that puts the page at the end of the PDF. Here's my code...
- Code: Select all
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim pageCollection As New List(Of PdfPageBase)
Dim pageBase As PdfPageBase
Dim bannerPage As PdfPageBase
Dim size As SizeF
Dim template As PdfTemplate
Dim pdfFile As String = "c:\temp\[email protected]"
Dim doc As New PdfDocument
doc.LoadFromFile(pdfFile)
For i = 0 To doc.Pages.Count - 1
pageCollection.Add(doc.Pages(i))
Next
' replicate all pages in PDF
For i = 0 To 2
For j = 0 To pageCollection.Count - 1
pageBase = doc.Pages(j)
size = pageBase.Size
template = pageBase.CreateTemplate
pageBase = doc.Pages.Add(size, New PdfMargins(0))
pageBase.Canvas.DrawTemplate(template, New PointF(0, 0))
Next
Next
' insert banner page
size = doc.Pages(0).Size
bannerPage = doc.Pages.Insert(0, size)
doc.SaveToFile("c:\temp\[email protected]")
End Sub
End Class
-

[email protected]
-
- Posts: 2
- Joined: Mon Apr 04, 2016 7:07 pm
Tue Apr 05, 2016 3:03 am
Hello,
Thanks for your feedback.
I tested your code with
Spire.PDF Pack(Hot Fix) Version:3.6.260. A blank banner page was added at the beginning of PDF. Please try the version.
Sincerely,
Caroline
E-iceblue support team
-


caroline.zhang
-
- Posts: 291
- Joined: Mon Mar 07, 2016 9:22 am
Tue Apr 05, 2016 1:49 pm
That did the trick - thanks!
-

[email protected]
-
- Posts: 2
- Joined: Mon Apr 04, 2016 7:07 pm
Wed Apr 06, 2016 1:18 am
Hi,
I am glad to hear it.
Welcome to write to us again for further problems.
Have a nice day.
Sincerely,
Caroline
E-iceblue support team
-


caroline.zhang
-
- Posts: 291
- Joined: Mon Mar 07, 2016 9:22 am