C# 在C中使用PDFsharp wpf将txt文件转换为pdf#
我在将文件转换为pdf时遇到问题。我对C#(来自java)完全陌生,我正在尝试构建一个应用程序,首先将日志打印成文本文件,然后将其转换为PDF。如果你知道一个好的资源或例子,请在没有判断的情况下为我指出正确的方向。谢谢大家!C# 在C中使用PDFsharp wpf将txt文件转换为pdf#,c#,.net,pdf,txt,C#,.net,Pdf,Txt,我在将文件转换为pdf时遇到问题。我对C#(来自java)完全陌生,我正在尝试构建一个应用程序,首先将日志打印成文本文件,然后将其转换为PDF。如果你知道一个好的资源或例子,请在没有判断的情况下为我指出正确的方向。谢谢大家! createPDF(myFileString); void createPDF(string txtFile) { string line = null; System.IO.TextReader readFile = new StreamReader(my
createPDF(myFileString);
void createPDF(string txtFile)
{
string line = null;
System.IO.TextReader readFile = new StreamReader(myFileString);
int yPoint = 0;
PdfDocument pdf = new PdfDocument();
pdf.Info.Title = "TXT to PDF";
PdfPage pdfPage = pdf.AddPage();
XGraphics graph = XGraphics.FromPdfPage(pdfPage);
while (true)
{
line = readFile.ReadLine();
if (line == null)
{
break; // TODO: might not be correct. Was : Exit While
}
else
{
yPoint = yPoint + 40;
}
}
string pdfFilename = "txttopdf.pdf";
pdf.Save(pdfFilename);
readFile.Close();
readFile = null;
Process.Start(pdfFilename);
}
你看过Pdfsharp的网站吗,特别是他们的网站?它们的代码示例与您试图实现的非常相似,我认为这只是文档。我再看看。非常感谢。