How do I clip the imposed PDF page?

Q: How do I clip the imposed PDF page?

template.pdf - this is the PDF template file we insert embed.pdf into.
embed.pdf is actually split in half and printed on 2 pages. The 2
parts of
embed.pdf are then cropped and scaled so they fit within the txtAdImage
rectangle.

embed.pdf - See explanation for template.pdf

output.pdf - This is the result after interesting embed.pdf into
template.pdf

pdfprint.vb - This is the generic class we use to print PDF documents.
It
uses PDF.NET

ExportDAC.vb contains the code that actually combines template.pdf and
embded.pdf files. DisplayAd.vb is a helper class called by
ExportDAC.vb

We need to clip each imposed page in the target document.
---

A: Using PDFNet, you can add a clip path just before placing the form
XObject (imported from the source PDF document). Something along the
following lines:

' VB.NET code
writer.Begin(dacPageOne)
'----------------------------------------------------------
' Set a user defined clip path (this path will clip the imposed page)
Element element = builder.CreateRect(oDisplayAd.Left,
oDisplayAd.Bottom,
   oDisplayAd.Width, oDisplayAd.Height)
element.SetPathClip(True)
writer.WriteElement(element)
'----------------------------------------------------------
element = builder.CreateForm(adPageOne, pdfDacDoc)
element.GetGState().SetTransform(oDisplayAd.ScalingFactorWidth, 0, 0,
  oDisplayAd.ScalingFactorHeight, oDisplayAd.Left, oDisplayAd.Bottom)
writer.WritePlacedElement(element)
writer.End()

' Write page 2 of double page ads to DAC form
If isDoublePageAd Then
  adPageTwo = oDisplayAd.GetSecondPage()
   dacPageTwo = pdfDacDoc.PageFind(2).Current()

   writer.Begin(dacPageTwo)
   '----------------------------------------------------------
   ' Set a user defined clip path (this path will clip the imposed
page)
   element = builder.CreateRect(oDisplayAd.Left, oDisplayAd.Bottom,
      oDisplayAd.Width, oDisplayAd.Height)
   element.SetPathClip(True)
   writer.WriteElement(element)
   '----------------------------------------------------------
   element = builder.CreateForm(adPageTwo, pdfDacDoc)
   element.GetGState().SetTransform(oDisplayAd.ScalingFactorWidth, 0,
0, oDisplayAd.ScalingFactorHeight, oDisplayAd.Left, oDisplayAd.Bottom)
   writer.WritePlacedElement(element)
   writer.End
End If