try{string textBoxText; // your Text Box textSystem.IO.TextReader readFile = new StreamReader("Text.txt");int yPoint = 0;PdfDocument pdf = new PdfDocument();pdf.Info.Title = "TXT to PDF";PdfPage pdfPage = pdf.AddPage();XGraphics graph = XGraphics.FromPdfPage(pdfPage);XFont font = new XFont("Verdana", 20, XFontStyle.Regular );while (true){ if (string.IsNullOrEmpty("textBoxText")) { graph.DrawString(line, font, XBrushes.Black, new XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft); yPoint = yPoint + 40; }}string pdfFileName = "MyPdfFile.pdf";pdf.Save(pdfFileName);readFile.Close();readFile = null;Process.Start(pdfFileName);}catch(Exception ex){ //Log exception} 这篇关于如何将文本框值导出为pdf格式...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-30 08:11