我试图让我的pdf文档从(0,0)开始,但是看起来文档对象有一个默认的上边距,我不能设置为0.有没有办法做到这一点?
我的代码如下所示
using (MemoryStream memoria = new MemoryStream())
{
Document pdf = new Document(new Rectangle(288, 144));
try
{
PdfWriter writer = PdfWriter.GetInstance(pdf, memoria);
pdf.Open();
pdf.SetMargins(0, 0, 0, 0);
PdfPTable tPrincipal = new PdfPTable(2);
tPrincipal .WidthPercentage = 100;
tPrincipal .DefaultCell.Border = 0;
tPrincipal .TotalWidth = 288f;
tPrincipal .LockedWidth = true;
Run Code Online (Sandbox Code Playgroud)
....
我无法将上边距设置为0.它只是不关心我的设置为(0,0,0,0)并留下上边距(约50f).
我使用itextSharp有抛光字符的问题.我想从html创建pdf.一切都很好,但缺少波兰人的性格.我使用较低的功能:
private void createPDF(string html)
{
//MemoryStream msOutput = new MemoryStream();
TextReader reader = new StringReader(html);// step 1: creation of a document-object
Document document = new Document(PageSize.A4, 30, 30, 30, 30);
// step 2:
// we create a writer that listens to the document
// and directs a XML-stream to a file
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Test.pdf", FileMode.Create));
// step 3: we create a worker parse the document
HTMLWorker worker = new HTMLWorker(document);
// step 4: we open document …Run Code Online (Sandbox Code Playgroud) 我试图将2个水晶报告合并为单个pdf文件,我正在使用Itextsharp v5.1.1.但它说文件无法打开.它可能已损坏.没有构建错误.但pdf格式不正确,无法打开.这是我选择完成此任务的顺序.
以下是订单中每个步骤的代码.
/// Get the Dataset from Stored Procedure for the CSSource Report
dsCS = CSData.GetUSSourceXML(ds_input);
/// Create the Report of type CSsource
rptCS = ReportFactory.GetReport(typeof(CSsource));
rptCS .SetDataSource(dsCS);
/// Set the Parameters to the CS report
rptCS .ParameterFields["Parameterid"].CurrentValues.Clear();
rptCS .SetParameterValue("Parameterid", PID);
//// Serialize the Object as PDF
msCS=(MemoryStream)rptCS .ExportToStream(ExportFormatType.PortableDocFormat);
Run Code Online (Sandbox Code Playgroud)
对于第2步
/// Get the Dataset from Stored Procedure for the Aden Report
dsAd = CSData.GetAdden(ds_input);
/// Create the Report of type Aden
rptAd = ReportFactory.GetReport(typeof(Aden));
rptAd.SetDataSource(dsAd …Run Code Online (Sandbox Code Playgroud) 我有一张桌子
PdfPTable tblSummary = new PdfPTable(1);
Run Code Online (Sandbox Code Playgroud)
它确实有2个嵌套在其中的表.如何使tblSummary整个表格显示(行不得中断到另一个页面),或者如果整个表格不适合当前页面,则将其移动到另一个页面.
我曾尝试SplitLate和SplitRows
我的代码是这样的
PdfPTable tblSummary = new PdfPTable(1);
PdfPCell csummarycell = new PdfPCell();
PdfPTable tblSummaryFirst = new PdfPTable(3);
.
.
csummarycell.AddElement(tblSummaryFirst);
.
.
tblSummary.AddCell(csummarycell);
tblSummary.SplitLate = true;
tblSummary.SplitRows = false;
Run Code Online (Sandbox Code Playgroud)
像这样我向tblSummary添加了一个表,而得到的表高度总是小于pagesize的表,所以可以确定表的内容不会超过页面高度.
任何建议都会有所帮助.
我是iTextSharp(和StackOverFlow)的新手.我正在尝试使用外部USB令牌在C#中签名PDF.我尝试使用我从互联网上挖掘的以下代码.
Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser();
//Get Sertifiacte
X509Certificate2 certClient = null;
X509Store st = new X509Store(StoreName.My, StoreLocation.CurrentUser);
st.Open(OpenFlags.MaxAllowed);
X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(st.Certificates, "Please choose certificate:", "", X509SelectionFlag.SingleSelection);
if (collection.Count > 0){
certClient = collection[0];
}
st.Close();
//Get Cert Chain
IList<Org.BouncyCastle.X509.X509Certificate> chain = new List<Org.BouncyCastle.X509.X509Certificate>();
X509Chain x509chain = new X509Chain();
x509chain.Build(certClient );
foreach (X509ChainElement x509ChainElement in x509chain.ChainElements){
chain.Add(DotNetUtilities.FromX509Certificate(x509ChainElement.Certificate));
}
PdfReader reader = new PdfReader(sourceDocument);
FileStream resStream = new FileStream(resultDocument, FileMode.Create, FileAccess.ReadWrite);
PdfStamper stamper = PdfStamper.CreateSignature(reader, resStream , '\0', null, true); …Run Code Online (Sandbox Code Playgroud) 我正在使用iTextSharp来更新A PDF的文件属性:
FileStream fs = File.Open(@"C:\Developer\C#Projects\BylawSearch\0001.pdf", FileMode.Open);
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, fs);
document.Open();
document.AddSubject("Blah");
document.AddTitle("Blah blah");
document.AddKeywords("Blah blah blah");
document.Close();
Run Code Online (Sandbox Code Playgroud)
我收到了"文件没有页面".来自iTextSharp的错误.任何帮助赞赏.
我正在使用iTextSharp在PDF文档中创建表.我需要在表格单元格中的几行显示一个在另一个下面,如下所示:
First line text
Second Line Text
Third Line Text
Fourth line text
Run Code Online (Sandbox Code Playgroud)
有时像这样额外的线:
First line text
Second Line Text
Third Line Text
Fourth line text
Run Code Online (Sandbox Code Playgroud)
我尝试了几种方法,使用Paragraphs,Chunks,Phrases,在线进行研究,但仍然无法得到这个结果.请帮忙.另外,如何使列动态调整宽度到内容?(不包装)谢谢
我使用iTextSharp 5.5.1以数字方式使用分离签名(从第三方机构获得)签署PDF文件.一切似乎都运行正常,文件有效,例如Adobe Reader报告没有问题,将签名显示为有效等.
问题是Java客户端显然存在这些文件的一些问题 - 文件既不能打开也不能解析.
这些文件在标题中有一个字节顺序标记,这似乎会导致该行为(\ x00EF\x00BB\x00BF).
我可以像这样识别BOM:
PdfReader reader = new PdfReader(path);
byte[] metadata = reader.Metadata;
// metadata[0], metadata[1], metadata[2] contain the BOM
Run Code Online (Sandbox Code Playgroud)
我如何可以删除的BOM(不失签名的有效性),或强制iTextSharp的图书馆不将这些字节附加到文件?
XmlWorker无法识别表格单元格上的border-bottom.
这是我的代码:
<table>
<tbody>
<tr>
<th style="width: 20%; height: 40px; vertical-align: top; border-bottom: 1px solid gray">Your name</th>
<td style="width: 80%; border-bottom: 1px solid gray"></td>
</tr>
<tr>
<th style="height: 40px; vertical-align: top; border-bottom: 1px solid gray">Your lastname</th>
<td style="border-bottom: 1px solid gray"></td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我正在使用这个官方工具进行测试:
http://demo.itextsupport.com/xmlworker/
(点击"html"按钮,在"字体大小"下面,然后粘贴代码)
我也在使用iTextSharp + MvcRazorToPdf(两个C#库)进行测试.
问题:
如何让边框底部工作?
编辑:
根据此兼容性摘要:http://demo.itextsupport.com/xmlworker/itextdoc/CSS-conformance-list.htm,css 属性border-bottom应该可以正常使用html元素td(cell)