最新版FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用简解

简介:对于FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用,只需要2个文件:FreeTextBox.DLL和ftb.imagegallery.aspx

1。下载最新版FreeTextBox(版本3.1.6),解压
   FreeTextBox 3.1.6 (2007/10/17)
   博客园本地下载: http://www.cnblogs.com/Files/cleo/FTBv3-1-6.zip
   作者网站下载地址:http://freetextbox.com/download/
   详细版本有哪些改进和修改历史可以看这里:http://freetextbox.com/download/changelog.aspx

FreeTextBox 3.1.6 (2006/07/18)
    * BUG: Firefox postback problems (due to IE specific code)
    * CHANGE: createlink now requires text to be selected
    * BUG: FontSizesMenuList now functions correctly
    * BUG: IE users would see the tag path of the entire document
  
    * BUG: bug in FF vs. IE DOM handling of extra /n tag

   Free版本的收费版本的区别可以看这里:http://freetextbox.com/features/

2。打开ASP.Net2.0项目,添加引用。(如果添加过以前版本的FreeTextBox,先删除以前版本的引用)
2.1。拷贝ftb.imagegallery.aspx到你要使用FreeTextBox的目录(当然可以是其他,但是可能要设置路径)
3。将FreeTextBox添加到工具栏。(工具栏〉常规〉选择项〉浏览到DLL文件,添加)
4。可以将工具栏上的控件拖入到你的页面了
   
< FTB:FreeTextBox  ID ="Free1"    ImageGalleryPath ="~/ImageAdmin"    
        runat
="server"  Text ='<%#  Bind("Contents") % > '
        ButtonDownImage="True"
        ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertImageFromGallery,InsertRule|Cut,Copy,Paste;Undo,Redo,Print">
        
</ FTB:FreeTextBox >

4.1。修改ImageGalleryPath属性为你图片的放置目录。
5。Q&A
5.1。Q:怎么不能新建目录,上传文件等?
     A:修改ftb.imagegallery.aspx页面可以做到
          
< FTB:ImageGallery  id ="ImageGallery1"
            SupportFolder
="~/aspnet_client/FreeTextBox/"
            AllowImageDelete
="true"  AllowImageUpload ="true"
             AllowDirectoryCreate
="true"  AllowDirectoryDelete ="true"  runat ="Server"   />

        修改AllowImageDelete等属性
5.2。Q:怎么没有看到“从图片库插入图片”这个图标?
     A:修改<FTB:FreeTextBox />的ToolbarLayout属性,添加一个InsertImageFromGallery,上面代码的例子就是已经添加好的。
5.3。Q:按钮怎么是英文提示?
     A:<FTB:FreeTextBox />有个属性叫做Language,把默认的en-US改称zh-CN吧,就是中文简体了,听说这个版本带了25种语言呢。

新增博客园本地下载: http://www.cnblogs.com/Files/cleo/FTBv3-1-6.zip 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将 HTML FreeTextbox 和文本框转换成 PDF,可以使用 iText 这个开源的 Java PDF 库。 首先,需要将 HTML 字符串转换成 PDF 文档对象。iText 提供了 `HtmlConverter.convertToPdf()` 方法可以实现这个功能,示例如下: ```java // 假设 html 为包含 FreeTextbox 和文本框的 HTML 字符串 ByteArrayOutputStream pdf = new ByteArrayOutputStream(); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(pdf)); ConverterProperties props = new ConverterProperties(); HtmlConverter.convertToPdf(html, pdfDoc, props); ``` 这段代码将 HTML 字符串转换成 PDF 文档对象,并将结果输出到 `ByteArrayOutputStream` ,可以通过 `pdf.toByteArray()` 获取转换后的 PDF 字节数组。 接下来,需要将 PDF 文档对象的文本框和图片元素替换成 iText 的对应元素。iText 提供了 `PdfAcroForm` 类和 `Image` 类分别表示 PDF 的表单和图片,可以通过 `pdfDoc.getAcroForm()` 获取 PDF 文档的表单对象,然后使用 `PdfAcroForm.addField()` 方法添加文本框,使用 `Image.getInstance()` 方法添加图片,示例如下: ```java // 获取表单对象 PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); // 替换 FreeTextbox 的文本框 Elements textboxes = doc.select("div.FreeTextbox input[type=text]"); for (Element textbox : textboxes) { String name = textbox.attr("name"); float left = Float.parseFloat(textbox.attr("data-left")); float top = Float.parseFloat(textbox.attr("data-top")); float width = Float.parseFloat(textbox.attr("data-width")); float height = Float.parseFloat(textbox.attr("data-height")); PdfTextFormField field = PdfFormField.createText(pdfDoc, new Rectangle(left, top, width, height), name, ""); form.addField(field); } // 替换 FreeTextbox 的图片 Elements imgs = doc.select("div.FreeTextbox img"); for (Element img : imgs) { String src = img.attr("src"); float left = Float.parseFloat(img.attr("data-left")); float top = Float.parseFloat(img.attr("data-top")); float width = Float.parseFloat(img.attr("data-width")); float height = Float.parseFloat(img.attr("data-height")); Image image = Image.getInstance(new URL(src)); image.setAbsolutePosition(left, top); image.scaleToFit(width, height); pdfDoc.addNewPage().add(image); } ``` 这段代码,`doc.select("div.FreeTextbox input[type=text]")` 通过 CSS 选择器查找所有 `<div>` 元素 class 属性为 `FreeTextbox` 的子元素的输入框元素,然后遍历所有输入框元素,通过 `PdfFormField.createText()` 方法创建对应的 PDF 文本框,将其添加到 PDF 表单对象。 `doc.select("div.FreeTextbox img")` 通过 CSS 选择器查找所有 `<div>` 元素 class 属性为 `FreeTextbox` 的子元素的图片元素,然后遍历所有图片元素,通过 `Image.getInstance()` 方法创建对应的 iText 图片对象,并设置其位置和大小,将其添加到新建的 PDF 页面。 最后,需要关闭 PDF 文档对象并输出结果: ```java pdfDoc.close(); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=test.pdf"); response.setContentLength(pdf.size()); ServletOutputStream out = response.getOutputStream(); out.write(pdf.toByteArray()); out.flush(); ``` 这段代码,通过 `pdfDoc.close()` 方法关闭 PDF 文档对象,然后将 PDF 内容写入 HTTP 响应输出流,浏览器会自动下载名为 `test.pdf` 的 PDF 文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值