在以下代码中,中文字体(包含的html文本)不会以pdf格式显示.我也尝试这种方法中的样式和字体.请帮忙解决这个问题.在此先感谢所有人.
public static bool GeneratedPDF(string strHTMLText, string filename, string action, string rpttype)
{
bool blnReturn = false;
string fontpath = HttpContext.Current.Server.MapPath("~/files/fonts/");
string filepath = HttpContext.Current.Server.MapPath("~/files/pdf/");
BaseFont customfont = BaseFont.CreateFont(fontpath + "simhei.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font font = new Font(customfont, 12);
//List<iTextSharp.text.IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new System.IO.StringReader(strHTMLText), null);
iTextSharp.text.Document document = new iTextSharp.text.Document();
if (rpttype.Trim().ToUpper() == "REPORT")
document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A2.Rotate());
else if (rpttype.Trim().ToUpper() == "GRID")
document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4.Rotate());
else
document = new iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER);
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(filepath + "\\" …Run Code Online (Sandbox Code Playgroud) 在itextsharp的5.4.2版中,我能够使用:( VB中的片段)
Dim pdfWriter As iTextSharp.text.pdf.PdfCopy
pdfwriter = New iTextSharp.text.pdf.PdfCopy(outputPDFDocument, New FileStream(destfname, FileMode.Create))
pdfWriter.CopyAcroForm(reader)
Run Code Online (Sandbox Code Playgroud)
将表单从一个文档复制到另一个文档.
在5.4.4 CopyAcroForm中不再存在于PdfCopy其他地方或其他任何地方 - 替代方案是什么?
我有一个登录帐户的API,然后通过CFHTTP请求搜索我想要出价的项目,如下所示.
Search.cfm:
<cfinclude template="logMeIn.cfm" />
<cfhttp url="https://utas.fut.ea.com/ut/game/fifa14/transfermarket?maxb=1800000&start=0&num=16&type=player&maskedDefId=158023" method="POST" result="Get">
<cfhttpparam type="header" name="Cache-Control" value="no-cache" />
<cfhttpparam type="header" name="Host" value="utas.fut.ea.com" />
<cfhttpparam type="header" name="Referer" value="http://cdn.easf.www.easports.com/soccer/static/flash/futFifaUltimateTeamPlugin/FifaUltimateTeam.swf" />
<cfhttpparam type="header" name="X-HTTP-Method-Override" value="GET" />
<cfhttpparam type="header" name="X-UT-PHISHING-TOKEN" value="#ListLast(Session.searchAccount40PhishingKey,'=')#" />
<cfhttpparam type="header" name="X-UT-SID" value="#Session.searchAccount40SessionKey#" />
</cfhttp>
Run Code Online (Sandbox Code Playgroud)
logMeIn.cfm:
<cfscript>
Variables.email = "XYZ@example.com";
Variables.password = "password";
Variables.secretAnswer = "secretAnswer";
Session.searchAccountGamertag = "WirierJupiter11";
Variables.doReload = 0;
Variables.deviceView = "device=not_mobile";
</cfscript>
<cfhttp url="http://www.easports.com/uk/fifa/football-club/ultimate-team" method="GET" result="stage1" redirect="false">
<cfhttpparam type="header" name="Accept" value="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" />
<cfhttpparam type="header" name="Accept-Encoding" value="gzip, deflate" />
<cfhttpparam type="header" name="Accept-Language" …Run Code Online (Sandbox Code Playgroud) 我有一个非常规则的HTML <table>,其中一个单元格跨越多行rowspan.在这个细胞内部,我有一个<div>我想占据整个细胞高度的细胞,但对于我的生活,我似乎无法弄明白.这个帖子似乎与提到这个Chrome bug有关,但也似乎很简单,也许我只是没有想清楚.
这是我的HTML的精简版:
<table>
<tr>
<td class="a" rowspan="2"><div>A</div></td>
<td class="b"><div>B</div></td>
</tr>
<tr>
<td class="c"><div>C</div></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
和CSS:
td
{
vertical-align: top;
}
td.a div
{
background-color: #f00;
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
还有一个JSFiddle.这就是我得到的以及我想要得到的东西:

真正奇怪的是,如果我使用Chrome的检查器来更改<div>to display: inline-block然后将其设置回display: block它,实际上看起来就像我想要的那样.
(不,从表中切换不是这个项目的选项,还有其他代码没有显示需要它.)
我正在创建 Spring MVC web 应用程序。我的图像在我的 MVC 应用程序的文件夹 webapp/resources/img/logo.png 中。如何将图像从该文件夹加载到 pdf。
我尝试使用此代码。但它的 trowing java.io.FileNotFoundException。
String imageUrl = "webapp/resources/img/logo.png"
logo = Image.getInstance(imageUrl);
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个应用程序,它将触发我在ASP.NET中构建的一系列Web报表.所以我有一个Web应用程序,其中页面存在,但我真的不想使用该网站查看页面,我想创建我可以提供给我的客户的PDF.
我正在尝试编写的应用程序是一个控制台应用程序,在c#中使用Visual Studio 2010编写并使用iTextSharp v5.5.2和.NET 4.5.它目前只是一个框架,因为我尚未完成"解雇PDF"部分.我正在从网上访问一个页面并试图将其保存为PDF,但我找不到任何有关我得到的编译错误的信息.我在应用程序中有以下Using指令:
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.xml;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using iTextSharp.text.io;
using iTextSharp.text.xml.simpleparser;
using iTextSharp.text.html.simpleparser;
namespace ConsoleApplication1
{
public partial class BuildReports : System.Web.UI.Page
{
static void Main(string[] args)
{
WebRequest wReq = WebRequest.Create("http://www.somesite.com/");
WebResponse wRsp = null;
try
{
wRsp = wReq.GetResponse();
}
catch (Exception e)
{
Console.WriteLine("{0} exception caught.", …Run Code Online (Sandbox Code Playgroud) itextsharp ×3
asp.net ×2
c# ×2
pdf ×2
cfhttp ×1
coldfusion ×1
css ×1
html ×1
html-table ×1
httprequest ×1
httpresponse ×1
itext ×1
spring ×1
spring-mvc ×1
web-services ×1
xmlworker ×1