在Windows窗体中使用XML阅读器生成PDF [英] Generating PDF with XML reader in windows forms

查看:130
本文介绍了在Windows窗体中使用XML阅读器生成PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows窗体应用程序中,我有一个文本框,我需要在其中输入正确的HTML标记,现在我需要将文本框中的数据加载到XML阅读器中,然后我需要递归处理每个元素。之后我必须生成一个PDF文件,其中包含例如如果我输入

,标签PDF应该包含表格格式和图像。我是一个非常新的编程可以帮助我做这个应用程序



我尝试过:



创建一个班级

命名空间PDF文件

{

公共类信息

{

私有字符串数据1 ;

公共字符串textBox1

{

get {return data1; }

设置{data1 = value;}

}

}

}







创建了另一个类如下



公共类SaveXml

{

public static void SaveData(object obj,string filename)

{

XmlSerializer sr = new XmlSerializer(obj.GetType());

TextWriter write = new StreamWriter(filename);

sr.Serialize(write,obj);

write.Close();

}

}



代码in form1.cs

private void textBox1_TextChanged(object sender,EventArgs e)

{



}



private void button1_Click(object sender,EventArgs e)

{

textBox1.SelectAll() ;

var a = textBox1.Focus();

信息信息=新信息();

info.textBox1 = textBox1.Text;

SaveXml.SaveData(info,data.xml);

}

解决方案

看看 PDF文件编写器C#类库 PDF文件编写器C#类库(版本1.19.1增强功能:文档链接) [ ^ ]

并且:从XML创建PDF文档从XML创建PDF文档 [ ^ ]

GitHub示例:生成PDF文档的示例 [ ^

In my windows Form application I have one text box in which i need to enter proper HTML tag and now I need to load data in text box into a XML reader then I need to process each element recursively.After this I have to generate a PDF file which contains for example like if i entered

, tags the PDF should contain a table format and an image.I am very new to programming can any help me to do this application

What I have tried:

Created A class
namespace PDFfile
{
public class Information
{
private string data1;
public string textBox1
{
get { return data1; }
set{data1=value;}
}
}
}



created another class like below

public class SaveXml
{
public static void SaveData(object obj, string filename)
{
XmlSerializer sr =new XmlSerializer(obj.GetType());
TextWriter write = new StreamWriter(filename);
sr.Serialize(write, obj);
write.Close();
}
}

code in form1.cs
private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
textBox1.SelectAll();
var a = textBox1.Focus();
Information info = new Information();
info.textBox1 = textBox1.Text;
SaveXml.SaveData(info, "data.xml");
}

解决方案

Take a look at "PDF File Writer C# Class Library" PDF File Writer C# Class Library (Version 1.19.1 Enhancement: Document links)[^]
And: "Creating PDF documents from XML": Creating PDF documents from XML[^]
Example on GitHub: Example of generating PDF documents[^]


这篇关于在Windows窗体中使用XML阅读器生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆