I have been trying to centre text unsuccessfully for 2 days now so unfortunately i now need help from the pros.
I am using below example found in a youtube video to create a pdf file with text and image for a report app i am working on.
I can centre a image but no luck with cantering text horizontally in a pdf document.
I am thinking i may have to place text in a rectangle then possibly centre but not sure so thought i would ask here first.
ps, i am aware library is redundant but itext7 looks so confusing.
Any help or example much appreciated, thankyou
Code:Dim pdfDoc As New iTextSharp.text.Document Dim Sstring As String = DdirName Dim DirToSavePdfTo As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\weights" Dim DIR_String As String = DirToSavePdfTo & "\" & Sstring & "\" & Sstring & " Weight Report.pdf" Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(pdfDoc, New FileStream(DIR_String, FileMode.Create)) pdfDoc.Open() pdfDoc.Add(New iTextSharp.text.Paragraph("Some text")) pdfDoc.Add(New iTextSharp.text.Paragraph(" ")) 'date and time Dim t As Date = DateTime.Now.ToString() pdfDoc.Add(New iTextSharp.text.Paragraph(t)) pdfDoc.Add(New iTextSharp.text.Paragraph(" ")) Dim RreportName As String = "Vehicle rego " & TxtVehicleRego.Text & " Van rego " & TxtVanRego.Text & " Report.pdf" pdfDoc.Add(New iTextSharp.text.Paragraph(RreportName)) pdfDoc.Add(New iTextSharp.text.Paragraph(" "))




Reply With Quote