飞碟没有应用内部 CSS

2023-12-14

我在 struts2 操作中使用以下代码,使用飞碟将 HTML 转换为 PDF: 它只是按原样打印样式代码,并不应用它。

static String readFile(String path, Charset encoding) 
          throws IOException 
        {
          byte[] encoded = Files.readAllBytes(Paths.get(path));
          return new String(encoded, encoding);
        }

public String execute() throws Exception
{
    String result="success";        
    try {
        String url = "C:\\Users\\Anoop\\Desktop\\files\\form1.html";
        System.setProperty("file.encoding", "UTF-8");
        String content = PDFGeneratorFromHTML.readFile(url,Charset.forName("UTF-8") );
        String k = "<html><body> This is my Project </body></html>";
        OutputStream file = new FileOutputStream(new File("D:\\Test2.pdf"));
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocumentFromString(content);
        renderer.layout();
        renderer.createPDF(file);
        file.close();
        inputStream = new FileInputStream(new File("D:\\Test2.pdf"));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

我的 HTML 和 css 文件是:

/*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<style type="text/css">
.text-right{text-align:right;}
.text-center{text-align:center;}
table{
	margin: 10px 0px;
	clear: both;
	border-top: none;
	border-bottom: none;
	text-align: left;
}
.border-left{border-left: solid 1px #e6e4df;}
/*table tr:nth-child(2n+1){background-color:#09C; color:#fff;}*/
table tr th{border:solid 1px #bfbfba; border-left:none; border-right:none; padding:15px 0 !important; background-color:#f5f5f2; color:#333;}
table tr td, table tr th{border-bottom:solid 1px #e6e4df; padding:5px; border-right:solid 1px #e6e4df;}
table tr td.total{background-color:#CCC;}
.header-uni-form{width:960px; height:auto; float:left; padding:20px 0;}
.header-uni-form .uni-form-logo{
	width:307px; height:auto; float:left; padding:20px 0;
}
.border-none{border:none !important;}
.w20{width:20%;}
.wi60{width:60%;}
.wi10{width:10%;}
.customer-info{width:940px; height:auto; float:left; margin:10px 0;}
.customer-info .customer-left{position: relative; width:620px; height:170px; float:left; border-radius:10px; -moz-border-radius:10px; -ms-border-radius:10px; -o-border-radius:10px; -webkit-border-radius:10px; border:1px solid #333;}
.customer-info .customer-left .bottom-border, .customer-info .customer-right .bottom-border{
	border-bottom: solid 1px #333 !important;
	text-align: left;
}
.customer-info .customer-left table, .customer-info .customer-right table, .customer-info .customer-right table tr td, .customer-info .customer-left table tr td, .customer-info .customer-right table tr td th, .customer-info .customer-left table tr td th{border:1px solid #fff; margin:10px;}
.customer-info .customer-left .name, .customer-info .customer-right .name{position:absolute; top:-17px; left:20px; color:#000; padding:5px 10px; background:#fff;}
.customer-info .customer-right{width:300px; height:170px; float:left; margin-left:15px; border-radius:10px; -moz-border-radius:10px; -ms-border-radius:10px; -o-border-radius:10px; -webkit-border-radius:10px; position: relative; border:1px solid #333;}
.header-uni-form .uni-form-heading{width:307px; height:auto; float:left; margin-left:15px;}
.header-uni-form .invoice-form-uni{width:307px; height:auto; float:left; margin-left:15px; padding:20px 0;}
</style>
<body>
<div style="width:960px; height:auto; margin:0 auto; clear:both;">
<div class="header-uni-form">
<div class="uni-form-logo text-center">Logo</div>
<div class="uni-form-heading"><strong>UNITELLER FINANCIAL SERVICES</strong>
218 Route 17 North<br />`enter code here`
Rochelle Park, N.J. 07662
</div>
<div class="invoice-form-uni text-center">Invoice No.:  IE 07 2014</div>
</div>
<div class="customer-info">

<div class="customer-left">
<span class="name">Customer</span>
<table width="98%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17%">Name</td>
    <td colspan="5" class="bottom-border">&nbsp;</td>
  </tr>
  <tr>
    <td>Address</td>
    <td colspan="5" class="bottom-border">&nbsp;</td>
  </tr>
  <tr>
    <td>City</td>
    <td width="30%" class="bottom-border">&nbsp;</td>
    <td width="14%">State </td>
    <td width="13%" class="bottom-border">&nbsp;</td>
    <td width="10%">Zip</td>
    <td width="16%" class="bottom-border">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="6" class="bottom-border">&nbsp;</td>
    </tr>
</table>

</div>
<div class="customer-right">
<table width="95%" border="1">
  <tr>
    <td width="27%">Date</td>
    <td width="73%" class="bottom-border">07/31/14</td>
  </tr>
    <tr>
    <td>&nbsp;</td>
    <td width="73%" class="bottom-border">&nbsp;</td>
  </tr>
    <tr>
    <td>Rep</td>
    <td width="73%" class="bottom-border">&nbsp;</td>
  </tr>
    <tr>
    <td>&nbsp;</td>
    <td width="73%" class="bottom-border">&nbsp;</td>
  </tr>
</table>

</div>
</div>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th width="7%" class="border-left">Qty</th>
    <th width="74%" class="text-center">Description</th>
    <th width="9%" class="text-center">Unit Price</th>
    <th width="10%" class="text-center">TOTAL</th>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td>
    <td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Deposit To Account</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Caja Popular Mexicana</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Caja Popular Mexicana Payment order over $6,000 MXP, Caja Popular Mexicana Payment order over $6,000 MXP</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Deposit To Account</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Deposit To Account</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left">4588</td>
    <td>Window Pick-up</td>
    <td class="text-right">$1.75</td><td class="text-right total">$48,56.00</td>
  </tr>
  <tr>
    <td class="border-left"><span class="border-none"></span></td>
    <td>&nbsp;</td>
    <td class="text-right">&nbsp;</td>
    <td class="text-right total">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" rowspan="5" class="border-none">&nbsp;</td>
    <td class="border-left">Sub Total</td>
    <td class="text-right total">$55.00</td>
  </tr>
  <tr>
    <td class="border-left">&nbsp;</td>
    <td class="text-right total">$0.00</td>
  </tr>
  <tr>
    <td class="border-left">&nbsp;</td>
    <td class="text-right total">$0.00</td>
  </tr>
  <tr>
    <td class="border-left">&nbsp;</td>
    <td class="text-right total">&nbsp;</td>
  </tr>
  <tr>
    <td class="border-left" style="text-align: right; font-weight: bold;">TOTAL</td>
    <td class="text-right total">$88,442.00</td>
  </tr>
</table>
</div>
</body>
</html> */

css 按原样打印,但未应用于 pdf 中。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

飞碟没有应用内部 CSS 的相关文章

  • php 在内容前插入十六进制字符数

    我正在将网站移动到新服务器 旧服务器有 php 5 3 2 新服务器有 php 5 5 9 Centos httpd Apache 2 2 26 我已经复制了文件 它工作正常 除了唯一奇怪的事情 一些奇怪的十六进制数字被插入到页面内容之前
  • CSS:仅背景不透明度,而不是内部文本[重复]

    这个问题在这里已经有答案了 我有这个注册表框 我真的很喜欢背景如何变得不透明 透明为 25 85 但后来我注意到文本和表单元素也变暗了一点 所以我想知道如何做到这一点只有边框和背景而不是盒子里面的东西 regForm z index 11
  • FPDF - 内嵌粗体文本

    我正在尝试从 PHP 创建 PDF 出于法律原因 我们需要将免责声明的一部分设为粗体 并且需要概述免责声明 我当前的代码使用 if isset POST optout POST optout yes pdf gt Ln 5 pdf gt S
  • Chrome 扩展程序未加载 EventListener

    我一直在创建一个 chrome 扩展 它将我的新标签页分成 2 个框架 这样我就可以尝试加载 2 个不同的 URL 现在我开始很简单 但我无法让它们按预期加载 这是代码 背景 html
  • 从 firebase 数据库获取最高分值

    在我的网站上有一些我从 firebase 获得的电影 电影的分数在0到100之间 我已经在我的网站上找到了所有电影 我还想按降序显示它们 例如评分最高的 5 部电影 我怎样才能实现这一点 感谢您的回答 const app initializ
  • 未使用 Font Family Open Sans

    我在用谷歌的 Open Sans 字体 http www google com fonts UsePlace use Collection Open Sans在我的应用程序中 我已经按照指示定义了样式表 然后我在主体选择器上使用它 body
  • 在 HTML TextArea 中设置(或读取)光标/插入符的值

    我正在尝试 但失败了 在 HTML 文本区域中实现拖放机制 使用 jQuery 或 Scriptaculous 我们都使用 拖放机制相对容易 因此我愿意接受使用这两者之一的答案 问题是 我似乎找不到读取或设置插入点的方法 我最终想要做的是确
  • 如何解决flash的zindex问题

    在网页中我需要显示div覆盖未使用的 Flash 横幅wmode transparent环境 怎么解决呢 根据我的记忆 你可以将 div 推入 也许使用Javascript 这样你就不会弄乱你的HTML iframe 是像 flash 一样
  • 占位符不适用于 Internet Explorer

    我的应用程序出现了小问题 Internet Explorer 11 上不存在占位符 我尝试了下面的 CSS 示例 但没有成功 ms input placeholder IE10 11 color ccc important font wei
  • 使用时间序列数据和scaleBand指定D3条形图上的刻度

    我尝试为具有时间序列数据的 d3 v4 条形图指定多个刻度和多个刻度标签 如下图所示 基于本教程 https bl ocks org zigahertz 1ee4965ff76514517bb7ce6af21e5d44我有一个处理时间序列数
  • 从提交的表单中转义字符串中的字符

    每次发布帖子时 我都会得到转义字符 gt gt gt 我有一个多步骤表单 它将数据从一种表单传输到另一种表单 我将这些值与准备好的语句一起保存在数据库中 数据库中的值当前看起来像Paul s House 用户应该可以在字符串中使用单引号和双
  • Django 未在 404 页面上应用应用程序中的 CSS 文件

    姜戈3 0 8 Python 3 7 x 我有一个包含一些应用程序的 Django 项目 我正在尝试为 400 403 404 500 错误制作一些 默认 错误页面 我已经这样做了 并显示了适当的模板 但没有任何样式或 JS 在 404 错
  • javascript获取网页中选定文本的段落

    突出显示文本后 我想获取所选文本所在的段落 var select window content document getSelection 请问有什么指点吗 这实际上很难做到 因为你必须考虑六种情况 所选内容不在一个段落内 简单 整个选择都
  • 将压缩的json数据存储在本地存储中

    我想将 JSON 数据存储在本地存储中 有时存储的数据可能超过 5MB 每个域的浏览器允许的最大阈值 无论如何 我可以压缩或压缩数据并将其存储在本地存储中吗 如果对大数据进行每个 JS 函数的压缩和解压 会增加多少延迟 我正在使用这个 js
  • 向 Twitter Bootstrap 添加新字体系列

    我怎样才能按照他们的方式将新的字体系列添加到 twitter bootstrap 中 他们使用一种叫做 woff 的东西 我正在尝试将 roboto 添加到 css 文件中 我怎样才能像他们那样做 woff 的事情呢 font face f
  • 透明、无边框文本输入

    如何删除周围的边框
  • 使 div 的大小与其内部图像的大小相同

    我有一个带有以下代码的div HTML div img src img logo png div CSS div imgContainer width 250px height 250px padding 13px 问题是用户可以编辑图像大
  • Struts2中的变量声明

    Struts2中如何声明变量并为该变量赋值 使用设置标签
  • Chrome 上的 contenteditable 中未显示编辑光标

    当您打开此页面时 请参阅现场演示 http jsfiddle net gs3p1a6r 3 show 与 Chrome span span CSS myspan border 0 outline 0 JS myspan focus the
  • CSS3 背景渐变未验证,有人可以告诉我为什么吗?里面的代码示例

    有人能告诉我为什么下面的 css 没有验证吗 我一直在尝试自己研究这个问题 但没有运气 我读过的所有文档都说这是在 css3 中进行渐变的正确原因 header color white font size 12px font family

随机推荐

  • 将 Rcpp 对象分配到 Rcpp 列表中会产生最后一个元素的重复项

    我正在尝试采取Rcpp CharacterMatrix并将每一行转换为它自己的元素Rcpp List 然而 我为此编写的函数有一个奇怪的行为 其中列表的每个条目对应于矩阵的最后一行 为什么会这样呢 这是一些与指针相关的概念吗 请解释 功能
  • 异常“PDOException”,消息“无法找到驱动程序”SQLSRV Laravel Artisan CLI

    我在 Windows Server 2008 上运行 php 5 5 我在应用程序中使用 Laravel 4 0 框架 我通过 PDO 连接到 SQL SRV 数据库 当通过 http 执行时没有问题 建立连接数据被调用和更新没有问题 但是
  • Firebase云功能“您的客户端无权从此服务器获取URL /200”

    我刚刚做了一个 firebase 云函数 exports deleteAfterSevenDays functions https onRequest req res gt 我部署了该函数并获得了一个函数 URL 当我从浏览器请求此网址时
  • 尝试在 Bluemix 上使用 FUSE 时出现问题

    我正在寻找一种方法来添加可访问 Bluemix 的远程文件系统 在这个post我被告知要使用 Cloud Foundry 最新版本支持的 cflinuxfs2 堆栈 我能够从我的 Java 应用程序执行挂载点的 mkdir 命令并执行 ss
  • Google Drive SDK - 上传图像、OCR、下载结果

    所以最终我尝试上传我想要 Google 进行 OCR 的图像 然后我希望能够将 OCR 结果传回我的 Android 应用程序 我的图像上传正常 我可以循环浏览我的谷歌驱动器中的所有文件 我看到有可用的导出链接 其中之一是 text pla
  • Angular ng-view/路由在 PhoneGap 中不起作用

    我在 PhoneGap 中使用 ngView 时遇到问题 一切似乎都加载得很好 我什至可以使用 ng controller 获得一个基本的控制器 但是当我尝试将路由与 ngView 一起使用时 没有任何反应 索引 html
  • 如何在java中接收yyyyMMddHHmm格式的输入?

    SimpleDateFormat sdf new SimpleDateFormat yyyyMMddHHmm java util Date parsedDate sdf parse 201212130900 java sql Timesta
  • “new Random(x)”总是生成相同的数字? [复制]

    这个问题在这里已经有答案了 我试图获得一个唯一的随机数 但每次运行代码时我总是得到相同的数字 我将先得到 14 然后得到 6 但我保存所有已用数字的列表似乎不起作用 手动添加 14 可以 但当我添加 randInt 时 它不起作用 cons
  • React onClick 和 PreventDefault() 链接刷新/重定向?

    我正在使用 React 渲染链接 render gt a upvote a 然后 上面我有 upvote 功能 upvote gt do stuff ajax 在链接之前 我在那个地方有跨度 但我需要切换到链接 这就是麻烦 每次我点击 up
  • 从 SignalR 中心发送异步邮件

    我需要发送一封电子邮件作为 SignalR 中心调用的结果 我不希望发送同步执行 因为我不想绑定 WebSocket 连接 但如果可能的话 如果有任何错误 我希望通知调用者 我想我可以在集线器中使用类似的东西 减去错误处理和我想要它做的所有
  • 获取运行 JVM 的 GC 设置 [重复]

    这个问题在这里已经有答案了 有没有办法获取正在运行的 JVM 的 GC 设置 我正在尝试查看运行 SerialGC ParallelGC ParallelOldGC ConcurrentMarkSweepGC 等的 GC 算法 JVM 为此
  • CMake 无法确定 C++ 的链接器语言

    我正在尝试使用 Visual Studio 2010 和 Cygwin 在 Windows 7 x64 上运行 cmake hello world 程序 但似乎都无法工作 我的目录结构如下 HelloWorld CMakeLists txt
  • Webpack怎么直接引入webpack.config.babel.js呢?

    我是一个相当大的 ReactJS 项目的新手 在顶层 它确实not有平常的webpack config js 但只有一个 webpack config babel js 这个确实被使用了 我可以在运行时验证 gt webpack 被调用 通
  • CSS 样式不适用于 ID

    我在用asp net C 对于我的项目 目前我有一个default aspx页面和母版页 default aspx页面有很多控件 并且对于每个控件我都定义了class and id 我面临的问题是当我申请时style使用特定的控件class
  • 具有 NFS 持久卷的 Kubernetes 有状态集

    我有一个kubernetes集群 我有一个简单的部署mongodb with NFS持久卷设置 它工作得很好 但是由于像数据库这样的资源stateful我想用Statefulset为了mongodb 但现在的问题是 当我查看文档时 stat
  • 添加误差线以在 R 中的绘图上显示标准差

    对于每个X value 我计算了平均值Y 值和标准差 sd 每个 Y 值 x 1 5 y c 1 1 1 5 2 9 3 8 5 2 sd c 0 1 0 3 0 2 0 2 0 4 plot x y 如何使用标准差向绘图的每个数据点添加误
  • 无法从 pod 容器内部访问 kubernetes api

    我已经创建了 hashcorpVault 部署并配置了 kubernetes auth Vault 容器从 pod 内部调用 kubernetes api 进行 k8s 身份验证 该调用失败并显示 500 错误代码 连接被拒绝 我正在使用
  • 在表中启用和禁用 td

    td td
  • 如何使用 MUnit 在 Mule Flow 中模拟 Java 组件

    我正在尝试使用 MUnit 对我的一个子流程进行单元测试 我需要模拟一个自定义 Java 组件 但我无法这样做 我的子流程如下
  • 飞碟没有应用内部 CSS

    我在 struts2 操作中使用以下代码 使用飞碟将 HTML 转换为 PDF 它只是按原样打印样式代码 并不应用它 static String readFile String path Charset encoding throws IO