itext7

How to create / set custom color of table cells and borders in iText 7?

余生长醉 提交于 2020-07-06 20:23:32
问题 I need to create a table which has custom colored cells and borders. There are a few constants defined in the Color class, but what I need a custom color. I need #a6cb0b as the background color for the header and border lines with color code #cccccc. How do I set them? Table table = new Table(new float[]{1,1,1}); Cell cell = new Cell(); cell.add(new Paragraph("TITLE")); cell.setBackgroundColor(Color.???); table.addCell(cell); ... ... 回答1: The best way to find out how to create colors, is to

How to create certificate object from public key in PEM format?

假装没事ソ 提交于 2020-06-29 05:46:12
问题 I want to use iText to embed signed hash and public in PDF. As per arguments to sign method in iText 7 I need to pass certificate chain, How can I create this certificate object directly from public key string? Update 1 Below is small c# code. You can see I am trying to get x509 certificate from public key. This certificate will be used to verify the signed data from corresponding private key. Also it will be used to embed this public certificate and signed hash into PDF for digital signature

Add revocation information to signature using iText7

梦想的初衷 提交于 2020-06-29 03:35:37
问题 I am producing Long Term signature. I am trying to add revocation information (Crls, OCSP Responses, Certificate Chain) to the signature as an unsigned attributes but the revocation information is not been embedded in the final signature. Following is the code snippet: Stream outputStream = new MemoryStream(); List<byte[]> ocspCollection = new List<byte[]>(); List<byte[]> crlCollection = new List<byte[]>(); List<byte[]> certsCollection = new List<byte[]>(); Stream readerStream = new

Add revocation information to signature using iText7

对着背影说爱祢 提交于 2020-06-29 03:34:07
问题 I am producing Long Term signature. I am trying to add revocation information (Crls, OCSP Responses, Certificate Chain) to the signature as an unsigned attributes but the revocation information is not been embedded in the final signature. Following is the code snippet: Stream outputStream = new MemoryStream(); List<byte[]> ocspCollection = new List<byte[]>(); List<byte[]> crlCollection = new List<byte[]>(); List<byte[]> certsCollection = new List<byte[]>(); Stream readerStream = new

How to add a “Page X of Y” footer in iText 7

为君一笑 提交于 2020-06-21 09:45:07
问题 I'm trying to figure out how to add a "Page X of Y" footer to each page in a PDF document, which I'm generating using iText 7 . Using an IEventHandler to generate the "Page X" part seems fairly straightforward - it's the "of Y" bit that I'm struggling with. I want to avoid generating the whole document twice in order to find out how many pages it has, as this would be a significant performance hit! I've found a solution for this in iText 5 here: PDF Page Numbering in Java & iText, but iText 7

How to print two parallel tables side by side in iText7, rendering them on one page at at a time and then adding new page

风格不统一 提交于 2020-05-17 03:00:55
问题 I want to add two parallel tables (tables contain content more than one page) side by side in iText7. Rendering should be done as: Render two tables on page 1, then add new page. Then render remaining part of tables on second page. If they still overflows add another page. Add remaining part of table on page 3 and so on. Here is the approach that is used in iText5 for this scenario. Main code: ColumnText[] columns = new ColumnText[2]; columns[0]=column1; columns[1]=column3; while (addColumns

How to split PDF document into small ones

99封情书 提交于 2020-05-16 04:11:18
问题 I need to split a document into several small documents. For example, if document has 7 pages I need to generate 7 pdfs. In iTextSharp i was using the following code, works pretty well. However, in iText 7 its not possible to do it in the same way. iTextSharp old code var reader = new PdfReader(src); for (int i = 1; i <= reader.NumberOfPages; i++) { var document = new Document(); var copy = new PdfCopy(document, new FileStream(result + i + ".pdf", FileMode.Create)); document.Open(); copy

How to split PDF document into small ones

隐身守侯 提交于 2020-05-16 04:10:38
问题 I need to split a document into several small documents. For example, if document has 7 pages I need to generate 7 pdfs. In iTextSharp i was using the following code, works pretty well. However, in iText 7 its not possible to do it in the same way. iTextSharp old code var reader = new PdfReader(src); for (int i = 1; i <= reader.NumberOfPages; i++) { var document = new Document(); var copy = new PdfCopy(document, new FileStream(result + i + ".pdf", FileMode.Create)); document.Open(); copy

How to scale text within a fixed rectangle with itext7?

喜你入骨 提交于 2020-05-13 18:16:09
问题 I'm trying to make a pdf document with itext7 in c# which should have fixed rectangles containing varying text that should scale within the boundaries of the (invisible) rectangles. I have tried to find if there's automatic scaling, but so far only found auto-scaling for formfields. Since the pdf will be used for plotting text, formfields are of no use. Code below is a snippet placing a 'box' with fixed dimensions, where all the text should be shown scaled (on one line) float fontSize = 22f;

How to scale text within a fixed rectangle with itext7?

巧了我就是萌 提交于 2020-05-13 18:14:00
问题 I'm trying to make a pdf document with itext7 in c# which should have fixed rectangles containing varying text that should scale within the boundaries of the (invisible) rectangles. I have tried to find if there's automatic scaling, but so far only found auto-scaling for formfields. Since the pdf will be used for plotting text, formfields are of no use. Code below is a snippet placing a 'box' with fixed dimensions, where all the text should be shown scaled (on one line) float fontSize = 22f;