My Code Like this
My Code:
Dim PageTableData As New PdfPage
Dim settings As New WebKitConverterSettings()
settings.EnableJavaScript = True
settings.PdfPageSize = PdfPageSize.A4
settings.Orientation = PdfPageOrientation.Portrait
settings.EnableHyperLink = True
settings.WebKitPath = Server.MapPath("~/bin/QtBinaries")
'
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'
'Convert Table to PDF
Dim document As New PdfDocument
'
Dim MyFormat As New PdfStringFormat
MyFormat.TextDirection = PdfTextDirection.RightToLeft
MyFormat.Alignment = PdfTextAlignment.Center
'
Dim MyHeaderFont As PdfTrueTypeFont = New PdfTrueTypeFont(New System.Drawing.Font("Arial", 16, FontStyle.Bold), True)
Dim HeaderStyle As New PdfCellStyle
HeaderStyle.Font = MyHeaderFont
HeaderStyle.StringFormat = MyFormat
'
Dim MyFont As PdfTrueTypeFont = New PdfTrueTypeFont(New System.Drawing.Font("Arial", 14, FontStyle.Regular), True)
Dim Style As New PdfCellStyle
Style.Font = MyFont
Style.StringFormat = MyFormat
PageTableData = document.Pages.Add()
PageTableData.Section.PageSettings.Margins.All = 50
header = AddHeader(page, "قائمة الاخبار الملحقة بملف التحليل", "")
'Draw the header in the first page of PDF document
PageTableData.Graphics.DrawPdfTemplate(header, New PointF())
'
MyNewDataTable.Columns(0).Caption = "مصدر الخبر"
MyNewDataTable.Columns(1).Caption = "تاريخ النشر"
MyNewDataTable.Columns(2).Caption = "عنوان الخبر"
'
Dim tableMain As New PdfLightTable()
tableMain.ColumnProportionalSizing = True
tableMain.DataSource = MyNewDataTable
tableMain.Style.ShowHeader = True
tableMain.Style.HeaderStyle = HeaderStyle
tableMain.Style.DefaultStyle = Style
'
tableMain.Columns(2).Width = 75
AddHandler tableMain.BeginRowLayout, AddressOf table_BeginRowLayout
AddHandler tableMain.BeginCellLayout, AddressOf table_BeginCellLayout
tableMain.Draw(PageTableData, New PointF(1, 70))
'
Private Sub table_BeginCellLayout(ByVal sender As Object, ByVal args As BeginCellLayoutEventArgs)
If args.RowIndex >= 0 AndAlso args.CellIndex = 3 Then
Dim textLink As New PdfTextWebLink
textLink.Text = args.RowIndex
textLink.Url = args.RowIndex
Dim MyPoint As New PointF
MyPoint.X = args.Bounds.X + 5
MyPoint.Y = args.Bounds.Y + 3
textLink.DrawTextWebLink(PageTableData, MyPoint) ---> Error (Object reference not set to an instance of an object.) -- Can any one help plz
End If
End Sub
The sample I got the idea from:
https://www.syncfusion.com/kb/11169/how-to-insert-hyperlink-in-table-of-a-pdf-document
Thanks for your help
|
Private Sub table_BeginCellLayout(ByVal sender As Object, ByVal args As BeginCellLayoutEventArgs)
If args.RowIndex = 1 AndAlso args.CellIndex = 1 Then
Dim textLink As New PdfTextWebLink
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F)
textLink.Font = font
textLink.Text = args.RowIndex
textLink.Url = args.RowIndex
Dim MyPoint As New PointF
MyPoint.X = args.Bounds.X + 5
MyPoint.Y = args.Bounds.Y + 3
textLink.DrawTextWebLink(PageTableData, MyPoint)
End If
End Sub |
Hi, Sir, I try this and solve my problem thanks for your time
============================================
now I have a big issue and need your help with
the file included is the result for the code
Dim MyPoint As New PointF
MyPoint.X = args.Bounds.Location.X + 60
MyPoint.Y = args.Bounds.Location.Y
'
textLink.DrawTextWebLink(PageTableData, MyPoint)
the Y from args.Bounds.Location.Y list
100
213.7184
295.2315
344.5394
377.7447
427.0526
460.2578
525.6683
558.8736
608.1815
641.3867
30
63.20525
96.41051
145.7184
195.0263
244.3341
293.642
326.8473
360.0526
393.2578
490.8736
540.1815
605.592
638.7972
30
60
109.3079
158.6158
207.9236
241.1289
290.4368
339.7447
389.0526
422.2578
487.6683
536.9762
586.2841
651.6946
30
60
109.3079
158.6158
and not see the other pages in PDF can you please tell me how to handle this
Attachment: الملف_التحليلي_معالي_المستشار_تركي_آل_الشيخ_16_أغسطس_2021_ab3b264c.zip
|
Private Sub table_BeginPageLayout(sender As Object, ByVal args As BeginPageLayoutEventArgs)
PageTableData = args.Page
End Sub |
Thanks this is really helpful for me
Hi Sir
Can I put a PNG image or icon instead of text in
textLink.Text= (Image location or image in Base64)
image in Base64 I try this and not worked for me
|
Private Sub table_BeginCellLayout(ByVal sender As Object, ByVal args As BeginCellLayoutEventArgs)
If args.CellIndex = 3 Then
If args.Value <> "ID4" Then
Dim image As New PdfBitmap("E://Logo.png")
'Draw the image
PageTableData.Graphics.DrawImage(image, args.Bounds)
Dim rect As New RectangleF(args.Bounds.X, args.Bounds.Y, args.Bounds.Width, args.Bounds.Height)
Dim url2 As PdfUriAnnotation = New PdfUriAnnotation(rect)
'Add the link
url2.Uri = "E://Logo.png"
'Border
url2.Border = New PdfAnnotationBorder(0, 0, 0)
'Add the color
url2.Color = New PdfColor(Color.White)
'Add the annotation
PageTableData.Annotations.Add(url2)
End If
End If
End Sub |