如何将文本框值导出为pdf格式...?
问题描述:
如何导出,文本框值和图像以导出pdf格式...
请帮助PLZ ...你能发送一些示例代码..plz
How to export, textbox values and images to export pdf form...
kindly help plz...can you send some sample code..plz
答
要使用PDF,您可以使用iText或其.NET端口,iTextSharp:
http://en.wikipedia.org/wiki/IText [ ^ ],
http://itextpdf.com/ [ ^ ],
http://sourceforge.net/projects/itextsharp/ [ ^ ]。
包括对Java iText网站的引用,因为大多数文档都在那里。如果您了解C#,那么理解基于Java的API文档并不困难。-SA
To work with PDF, you can use iText, or its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].
In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.—SA
>
从这里下载pdfsharp的dll http://pdfsharp.codeplex.com/releases/view/37054
Download the dll of pdfsharp from here http://pdfsharp.codeplex.com/releases/view/37054
try
{
string textBoxText; // your Text Box text
System.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
}