I'm attempting to take two different PDFs. Both are text based and both are full 8.5x11 landscaped. My task is to take 'overlay' and overlay it on the 'print' document. View attachment for example files. When I do that I get only a single page and nothing is overlaid.
How do I correct this issue?
- Code: Select all
Imports System.Drawing
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Namespace pdf_graphic_overlay
Class Program
Private Shared Sub Main(args As String())
'load two documents
Dim doc1 As New Spire.Pdf.PdfDocument()
doc1.LoadFromFile("C:\temp\print.pdf")
Dim doc2 As New Spire.Pdf.PdfDocument()
doc2.LoadFromFile("C:\temp\overlay.pdf")
'Create page template
Dim template As PdfTemplate = doc1.Pages(0).CreateTemplate()
'set PDF overlay effect and set transparency mode
For Each page As Spire.Pdf.PdfPageBase In doc2.Pages
'set transparency
page.Canvas.SetTransparency(0.25F, 0.25F, PdfBlendMode.Overlay)
'add the first page of doc1 to every page of doc2
page.Canvas.DrawTemplate(template, PointF.Empty)
Next
'Save pdf file.
doc2.SaveToFile("C:\temp\Overlay.pdf")
doc1.Close()
doc2.Close()
'Launching the Pdf file.
System.Diagnostics.Process.Start("C:\temp\Overlay.pdf")
End Sub
End Class
End Namespace