Hi,
I just about have everything the way I want it.
I have a table of contents in my document. I render my html to a pdfdocument. Then I find the location of my toc entries and the page number of where they are (toc_target) in the document.
I use this information to render the page number on the toc in the correct location.
You can see my sample program at:
http://pakatrak.ipower.com/2009_HRDirector/ConvertwithEO.aspxclick the 'Convert PolicyDemo htm file with EO' button
What I would like to add is a line from the toc entry to the page number.
What I am currently doing (I mostly took from the samples) is this:
Code: Visual Basic.NET
For K As Integer = 0 To TOC_ENTRIES_COUNT - 1
Dim TOCNumber As Acm.AcmText
Dim TOCpgNumRender As Acm.AcmRender
'create line and page number for TOC entry
'Create an AcmText representing the toc page number
TOCNumber = New Acm.AcmText(arrTOC(K, 3).ToString)
'Create an AcmRender to render the page number and line
'The arguments are:
' First argument: the target page
' Second argument: the "Y" position
' Third argument: The paper margins in left, top, right, bottom order
TOCpgNumRender = New Acm.AcmRender(doc.Pages(arrTOC(K, 2)), arrTOC(K, 1), _
New Acm.AcmPageLayout( _
New Acm.AcmPadding(7.5, 0, 1, 0)))
'Render the page number
TOCpgNumRender.Render(TOCNumber)
'now create the line between the toc entry and the page number
'Add a new page
Dim TOCpage As EO.Pdf.PdfPage = doc.Pages(arrTOC(K, 2))
'Create a new PdfPathContent
Dim content As New EO.Pdf.Contents.PdfPathContent()
'Create a new sub path and set the sub path's starting point
Dim subPath As New EO.Pdf.Drawing.PdfSubPath()
subPath.From = New EO.Pdf.Drawing.PdfPoint(arrTOC(K, 0) + 250, 640 - arrTOC(K, 1))
'Draw a line from the current position to the right edge
Dim line As New EO.Pdf.Drawing.PdfPathLineSegment(New EO.Pdf.Drawing.PdfPoint(500, 640 - arrTOC(K, 1)))
subPath.Segments.Add(line)
'Add the sub path into the path
content.Path.SubPaths.Add(subPath)
'Stroke the path
content.LineWidth = 1.0F
If K Mod 2 = 0 Then
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Red)
Else
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Black)
End If
content.Action = EO.Pdf.Contents.PdfPathPaintAction.Stroke
'Add the path into the page
TOCpage.Contents.Add(content)
Next
If you look at the sample this writes all the lines at the same x location and a very small y location. It would be best to be able to find the right end of the entry, start the line there and go to a specific spot at the right side of the document.
I can draw this line using html to pdf in the after or before render event. I just couldn't quite figure out how to do that.
What am I doing wrong?
Thanks!
Becky