This is fairly easy to accomplish using the <?hard-pagebreak?>.
Protected
Sub
RadGrid1_ItemCreated(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
RadGrid1.ItemCreated
If
e.Item.ItemIndex
Mod
7 = 0
AndAlso
e.Item.ItemIndex > 1
AndAlso
TypeOf
e.Item
Is
GridDataItem
Then
e.Item.Attributes.Add(
"pageBreak"
,
"pageBreak"
)
End
If
End
Sub
Then using pdfExporting you replace pagebreak="pagebreak" with closing the table, the hard pagebreak, opening the new table. It's hard to get the tags correct because I could not find any documentation about how this xhtml is fabricated, however I was able to save the raw xhtml to file and review it to get the replace correct and fix errors.
Protected
Sub
RadGrid1_PdfExporting(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridPdfExportingArgs)
Handles
RadGrid1.PdfExporting
Dim
replacement
As
String
=
"</tbody></table><?hard-pagebreak?>"
& _
"<table >"
& _
"<colgroup>"
& _
"<col />"
& _
"<col />"
& _
"</colgroup>"
& _
"<thead>"
& _
"<tr>"
& _
"<th scope='col' > </th><th scope='col' >Print Column</th>"
& _
"</tr>"
& _
"</thead>"
& _
"<tbody>"
& _
"<tr "
e.RawHTML = e.RawHTML.Replace(
"<tr pageBreak="
"pageBreak"
""
, replacement)
Dim
FILE_NAME
As
String
=
"c:\inetpub\PDFServer\file.html"
If
System.IO.File.Exists(FILE_NAME) =
True
Then
Dim
objWriter
As
New
System.IO.StreamWriter(FILE_NAME)
objWriter.Write(e.RawHTML)
objWriter.Close()
End
If
End
Sub
This is a really great feature of radgrid as it makes fabricating these pdfs about as easy as writing html. I just wish there was more documentation on how to do this because it took me forever to find this information. I hope someone else can use these examples to speed up their development.