I have a large file (140000 lines) and I have to parse through it and create a number of pdf from the text file. I am trying to add page numbering on the bottom of the page but I get an exception thrown. Here is relevant code, it must be in syntax or is it?
Dim MyDocument As Document = New Document()
Dim MyTextArea As TextArea = New TextArea(strFile, 0, 0, 500, 800)
Do
Dim MyPage As Page = New Page()
MyPage.Dimensions.BottomMargin = 60
MyPage.Dimensions.TopMargin = 20
MyPage.Dimensions.LeftMargin = 10
MyPage.Dimensions.RightMargin = 10
THIS LINE -->>> MyPage.Elements.Add(New PageNumberingLabel("%%PR%%%%SP%%of%%ST%%", 0, 680, 512, 12, Font.Helvetica, 12, TextAlign.Center))
MyPage.Elements.Add(MyTextArea)
MyDocument.Pages.Add(MyPage)
MyTextArea = MyTextArea.GetOverflowTextArea()
'MsgBox(MyTextArea.GetTextHeight().ToString)
Loop While Not (MyTextArea Is Nothing)
Using PageNumbering
Re: Using PageNumbering
Support · Apr 24, 2013Hello,
Applying the page numbering label using the document template should work. Here is the sample code.
Dim MyDocument As Document = New Document()
Dim documentTemplate As Template = New Template()
MyDocument.Template = documentTemplate
' Place a page numbering label in the document template
documentTemplate.Elements.Add(New PageNumberingLabel("%%PR%% %%SP%% of %%ST%%", 0, 680, 512, 12, Font.Helvetica, 12, TextAlign.Center))
Dim MyTextArea As TextArea = New TextArea(strFile, 0, 0, 500, 800)
Do
Dim MyPage As Page = New Page()
MyPage.Dimensions.BottomMargin = 60
MyPage.Dimensions.TopMargin = 20
MyPage.Dimensions.LeftMargin = 10
MyPage.Dimensions.RightMargin = 10
MyPage.Elements.Add(MyTextArea)
MyDocument.Pages.Add(MyPage)
MyTextArea = MyTextArea.GetOverflowTextArea()
Loop While Not (MyTextArea Is Nothing)
Thanks,
ceTe Software Support Team.
Re: Using PageNumbering
Forum member · Apr 25, 2013Blows up on
MyPage.Elements.Add(New PageNumberingLabel("%%PR%%%%SP%%of%%ST%%", 0, 480, 512, 12, Font.Helvetica, 12, TextAlign.Right))
If I text the line out the code runs fine. Email me and I will send you a screenshot of the error, I can't cut and past it
Dim MyDocument As Document = New Document()
Dim documentTemplate As Template = New Template()
MyDocument.Template = documentTemplate
' Place a page numbering label in the document template
documentTemplate.Elements.Add(New PageNumberingLabel("%%PR%% %%SP%% of %%ST%%", 0, 680, 512, 12, Font.Helvetica, 12, TextAlign.Center))
'MyDocument.Pages.Add(MyPage)
' Create a text area
Dim MyTextArea As TextArea = New TextArea(strFile, 0, 0, 500, 800)
'ReportWriter.ReportElements.PageNumberingLabel HUH, how do I do page numbering?
Do
Dim MyPage As Page = New Page()
MyPage.Dimensions.BottomMargin = 60
MyPage.Dimensions.TopMargin = 20
MyPage.Dimensions.LeftMargin = 10
MyPage.Dimensions.RightMargin = 10
' MyPage.Elements.Add(New PageNumberingLabel("%%PR%%%%SP%%of%%ST%%", 0, 480, 512, 12, Font.Helvetica, 12, TextAlign.Right))
MyPage.Elements.Add(MyTextArea)
MyDocument.Pages.Add(MyPage)
MyTextArea = MyTextArea.GetOverflowTextArea()
'MsgBox(MyTextArea.GetTextHeight().ToString)
Loop While Not (MyTextArea Is Nothing)
Re: Using PageNumbering
Support · Apr 25, 2013Hello,
Since you are not sectioning the document use "%%CP%% of %%TP%%" in the page numbering label instead of “%%PR%% %%SP%% of %%ST%%”. Also when applying the page numbering label to the document template, it is not necessary to add the page numbering label to each page. Please refer to the sample code below.
' Create a document.
Dim MyDocument As New Document()
'Adding page number to the whole document.
Dim MyTemplate As New Template()
Dim MyPageNumLabel As New ceTe.DynamicPDF.PageElements.PageNumberingLabel("%%CP%% of %%TP%%", 200, 680, 300, 40)
MyTemplate.Elements.Add(MyPageNumLabel)
'Setting template to the Document.
MyDocument.Template = MyTemplate
' Make a large text string.
Dim myText As String = "This is a test of the overflow text functionality."
myText += myText
myText += myText
myText += myText
myText += myText
myText += myText
' Adds pages until all text is displayed.
Dim MyTextArea As New TextArea(myText, 0, 0, 200, 200)
Do
Dim MyPage As New Page()
MyPage.Elements.Add(MyTextArea)
MyDocument.Pages.Add(MyPage)
MyTextArea = MyTextArea.GetOverflowTextArea()
Loop While MyTextArea IsNot Nothing
' Output the PDF.
MyDocument.Draw("output.pdf")
If you are still getting the exception, feel free to email all relevant info to [^a|mailto:support@cete.com|opennewwindow|support@cete.com^] so we can look into this further.
Thanks,
ceTe Software Support Team.