易截截图软件、单文件、免安装、纯绿色、仅160KB

HTML转PDF(C# itextsharp)

一、 需求:将HTML转PDF打印。Web项目中总是有这样的需求,很是让人苦恼。
二、 分析:如何完成这个工作?
1、 需要解析HTML,然后利用itextsharp绘制pdf文档。解析HTML是一个很难完成的任务,各个浏览器对HTML的解析五花八门就知道这不好解决。这条路不好走,但也是可以完成的,通过webbrowser类可以解析HTML获取各对象的位置,然后绘制到pdf中。方法是可行,其中的复杂度不小。
2、 将HTML保存为图片,然后插入到pdf文档中,这里将介绍这种方法。随之而来的问题:如何将HTML保存为图片呢?
三、 解决办法:
1、 将HTML保存为图片:需要用到webbrower类,将指定的HTML载入webbrower,然后调用其DrawToBitmap方法获取图片。代码如下:
private System.Drawing.Bitmap bitmap;
    private string url;
    private int w = 760, h = 900;//A4纸张对应的分辨率大概就是760*900
    public void setBitmap()
    {
        using (WebBrowser wb = new WebBrowser())
        {
            wb.Width = w;
            wb.Height = h;
            wb.ScrollBarsEnabled = false;
            wb.Navigate(url);
            //确保页面被解析完全
            while (wb.ReadyState != WebBrowserReadyState.Complete)
            {
                System.Windows.Forms.Application.DoEvents();
            }
            bitmap = new System.Drawing.Bitmap(w, h);
            wb.DrawToBitmap(bitmap, new


相关文档:

coolite control add the html tag

I always consider the coolitm control only can use its control tag in its body.
But I found that it can use html tag ,this very good.
so I show the sample to other:
<ext:Window
ID="Window1"
runat="server"
Width="500"
Height="485"
......

asp.net C#网站项目 获取物理路径、虚拟路径的方法

-----------------------------.cs类文件中
当前项目的物理路径嘛:  
   
  strPath   =   this.Server.MapPath(Request.PhysicalApplicationPath);  
   
  你要说明什么“类文件”。任何PAGE、CONTROL代码也是在类 ......

JAVA清除html格式正则表达式


 public static String splitAndFilterString(String input, int length) {   
        if (input == null || input.trim().equals("")) {   
     &nb ......

html 表格特殊标题 (legend)

<html>
<head>
<mce:style type="text/css"><!--
td
{
width:50;
height:50;
text-align:center;
vertical-align: center;
}
table
{
vertical-align: bottom;
}
legend
{
text-align:center;
}
fieldset
{
width:300; ......

网站HTML静态化解决方案

package com.jb.y2t034.thefifth.web.servlet;  
import java.io.ByteArrayOutputStream;  
import java.io.FileOutputStream;  
import java.io.IOException;  
import java.io.OutputStreamWriter;  
import java.io.PrintWriter;  
import jav ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号