Hi,
Recently we are trying to generate the PDF which content retrieved from back end table. It should display as below.
Title 1 - title content (Font different with the items)
this is the first item under this title, item content could be last in multiple lines (font Italic: datetime: Sep. 1st, 2012). other item content but fond is normal.
this is the second item under this title, item content could be last in multiple lines (font Italic: datetime: Sep. 1st, 2012). other item content but fond is normal.
this is the third item under this title, item content could be last in multiple lines (font Italic: datetime: Sep. 1st, 2012). other item content but fond is normal.
Title 2 - title content (Font different with the items)
this is the first item under this title, item content could be last in multiple lines (font Italic: datetime: Sep. 1st, 2012),other item content but fond is normal.
this is the second item under this title, item content could be last in multiple lines (font Italic: datetime: Sep. 1st, 2012). other item content but fond is normal.
this is the third item under this title, item content could be last in multiple lines (font Italic: datetime: Sep. 1st, 2012).other item content but fond is normal.
Actually I am already lost among the class, methods I should use, if you can please shed me a light.....My code snippet is as the following
Dim firstx As Integer = 10
Dim secondx As Integer = 10
Dim thirdx As Integer = 10
Dim commiteex As Integer = 10
Dim firsty As Integer = 0
Dim secondy As Integer = 0
Dim thirdy As Integer = 0
Dim commiteey As Integer = 0
doc = New Syncfusion.Pdf.PdfDocument()
doc.PageSettings.Margins.Top = 50.4F
doc.PageSettings.Margins.Bottom = 57.6F
doc.PageSettings.Margins.Left = 50.0F
doc.PageSettings.Margins.Right = 43.2F
doc.PageSettings.Orientation = PdfPageOrientation.Portrait
doc.PageSettings.Size = PageSize.Letter
page = doc.Pages.Add()
graphics = page.Graphics
font = New PdfStandardFont(PdfFontFamily.TimesRoman, fontSize)
format = New PdfStringFormat()
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
format.WordWrap = PdfWordWrapType.Word
layoutFormat = New PdfLayoutFormat()
layoutFormat.Break = PdfLayoutBreakType.FitPage
layoutFormat.Layout = PdfLayoutType.Paginate
element = New PdfTextElement()
element.Brush = New PdfSolidBrush(Color.Black)
element.StringFormat = format
element.Text = currentstr ' currentstr is got from back end table in a loop.
element.Font = New PdfStandardFont(PdfFontFamily.TimesRoman, 9)
element.Draw(page, New PointF(firstx, firsty), layoutFormat)
firstx += currentstr.Length
currentstr = " datetime string get from table"
element.Text = currentstr
element.Font = New PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Italic)
element.Draw(page, New PointF(firstx, firsty), layoutFormat)
firstx += currentstr.Length
1. As inside the paragraph line, some text font is different with others, so should I use PdfTextElement or just use the pdfgraphic.DrawString? Also if I use PdfTextElement object, the text won't wrap automatically and keep drawing to the same line and being truncated behind the page margin I set.
2. It seems in previous version, can use pdfDoc.Graphics.MeasureString to measure a string, but why I cannot use this method in 10.3, as I thought "firstx += currentstr.Length" is wrong, should using MeasureString to get the new location.
3. Is that possible to generate the whole text (include all paragraphs and append into one string, at the end of each item inside the paragraph added vbCrLf for separation), and draw once to multiple pages automatically? then maybe use some "replace" or "search" methods to find those datestring and change their font to be Italic?
If you can please give me some code snippet for the solution, that would be great.
Thanks
Jiewen