winform 把窗口上的全部信息生成PDF文件显示??

来源:百度知道 编辑:UC知道 时间:2024/06/16 19:36:05
很头痛,请大家给个思路
窗口上是一个病历添加信息

using System;
using System.IO;
using System.Text;
using System.Collections;

namespace PDFGenerator
{
//生成pdf的类
public class PDFGenerator
{
//初始化,定义pdf文件大小
static float pageWidth = 594.0f;
static float pageDepth = 828.0f;
static float pageMargin = 30.0f;
static float fontSize = 10.0f;
static float leadSize = 10.0f;
//在磁盘指定位置创建一个PDF文件
static StreamWriter pPDF=new StreamWriter("E:\\新建文件夹\\工作目录\\myPDF.pdf");
//在内存中创建文件缓冲区
static MemoryStream mPDF= new MemoryStream();
//将文本文件数据转换成pdf格式并写入文件缓冲区的函数
static void ConvertToByteAndAddtoStream(string strMsg)
{
Byte[] buffer=null;
buffer=ASCIIEncoding.ASCII.GetBytes(strMsg);
mPDF.Write(buffer,0,buffer.Length);
buffer=null;
}
//将数据长度格式信息格式化为外部参照格式
static string xRefFormatting(long xValue)
{
string strMsg =xValue.ToString();
int iLen=strMsg.Length;
if