itextsharp

Sign multiple pdf with itextsharp and token prompts for pin every time

馋奶兔 提交于 2019-12-03 22:17:18
Hi I am trying to prevent multiple pin prompts for every pdf that needs to be signed. I am using code from this example : Pin is required when this part of code get process : MakeSignature.SignDetached(appearance, pks, chain, crlList, ocspClient, tsaClient, estimatedSize, subfilter); Is there any way to memorize token pin and sing rest of pdfs without prompting for pin? Finally I found solution, this code does the trick : ... RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)pk.PrivateKey; CspParameters cspp = new CspParameters(); cspp.KeyContainerName = rsa.CspKeyContainerInfo

how to implement smallcaps in itextsharp

自闭症网瘾萝莉.ら 提交于 2019-12-03 21:32:13
In one PDf i got small caps text the font size is 0.0. i have extracted font using:------ iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(curBaseline[Vector.I1], curBaseline[Vector.I2], topRight[Vector.I1], topRight[Vector.I2]); Single curFontSize = rect.Height; int this code curfontsize i got 0.0. but i was able to extract font family.but not able to extract fontsize. so the text was not displaying.can anyone provide solution for this . Is there anyother method.? thankyou I just tried to reproduce your rec.Height == 0.0 issue in iTextSharp.text.Rectangle rect = new iTextSharp

How to extract highlighed text from PDF using iTextSharp?

风流意气都作罢 提交于 2019-12-03 20:45:51
As per folowing post: iTextSharp PDF Reading highlighed text (highlight annotations) using C# this code: for (int i = pageFrom; i <= pageTo; i++) { PdfDictionary page = reader.GetPageN(i); PdfArray annots = page.GetAsArray(iTextSharp.text.pdf.PdfName.ANNOTS); if (annots!=null) foreach (PdfObject annot in annots.ArrayList) { PdfDictionary annotation = (PdfDictionary)PdfReader.GetPdfObject(annot); PdfString contents = annotation.GetAsString(PdfName.CONTENTS); // now use the String value of contents } } } is working to extract PDF annotations. But why the same following code is not working for

Centering an pdfimportedpage in iTextSharp

你离开我真会死。 提交于 2019-12-03 20:29:21
I am appending PDFs together using the function below via iTextSharp. Its working fine. The only problem is that PDFs that are larger than the set size of the document (A4), ends up being scaled and placed at the bottom left corner of the document. I would like to centre it. Can anyone point me in the right direction to achieving this? Cheers. private void appendPDF(appendDoc doc) { PdfContentByte pdfContentByte = pdfWriter.DirectContent; PdfReader pdfReader = null; if (doc.MemoryStream != null && doc.MemoryStream.CanRead) { pdfReader = new PdfReader(doc.MemoryStream); } else if (File.Exists

How do I Combine/Merge PDFs with Fillable Form Fields using iTextSharp?

血红的双手。 提交于 2019-12-03 18:10:45
问题 Using iTextSharp , how can I merge multiple PDFs into one PDF without losing the Form Fields and their properties in each individual PDF? (I would prefer an example using streams from a database but file system is ok as well) I found this code that works but it flattens out my PDFs so I can't use it. UPDATE @Mark Storer - This is the code I am using now based on your feedback (see below) but it gives me a corrupt document after the save. I tested each of the code parts separately and it seems

table width not set in iTextSharp when converting html to PDF

帅比萌擦擦* 提交于 2019-12-03 17:09:07
I am trying to convert an html to pdf but the problem i face is that the html table tags width is not getting set correctly.. This is my html <table cellpadding='4' cellspacing='4' border='0' width='100%' style='width:100%'> <tr style='background-color:#000000'> <td colspan='2' align='center' valign='middle' width='100%'> <font face='Calibri' size='6' color='#FFFFFF'>Retail Natural Gas Deal Sheet</font> </td> </tr> <tr> <td colspan='2' width='100%'> </td> </tr> <tr> <td width='90%' style='width:90%'> <table cellpadding='0' cellspacing='0' border='0' width='100%'> <tr> <td width='42%'> <font

How to insert files into folders of an existing PDF portfolio with folders using iTextsharp

青春壹個敷衍的年華 提交于 2019-12-03 16:58:55
Using the answers in How to merge PDFs into a PDF Portfolio? , I've been able to create an PDF portfolio using iTextSharp. However, using Adobe Acrobat I'm able to create folders, and I'm able to put files in those folders. How do I create folders and how do I put files in those folders in a PDF portfolio using iTextSharp? I've tried using a pdf inspector program to see the differences between a portfolio with and without folders, but I haven't been able to see any. I guess I'm looking in the wrong places EDIT For this specific use case of mine it is actually possible to create the PDF

How can I convert a BouncyCastle X509Certificate to an X509Certificate2?

谁说我不能喝 提交于 2019-12-03 16:57:05
Is there any way to convert a Org.BouncyCastle.X509.X509Certificate to System.Security.Cryptography.X509Certificates.X509Certificate2 ? The inverse operation is easy, combining Org.BouncyCastle.X509.X509CertificateParser with System.Security.Cryptography.X509Certificates.X509Certificate2.Export() . Easy!! using B = Org.BouncyCastle.X509; //Bouncy certificates using W = System.Security.Cryptography.X509Certificates; W.X509Certificate2 certificate = new W.X509Certificate2(); certificate.Import(pdfCertificate.GetEncoded()); And now I can validate certificate chain in the server: W.X509Chain ch =

iTextSharp Efficient Batch Pdf Generation From a 1 Page Template

梦想的初衷 提交于 2019-12-03 16:25:59
I am generating a multiple page PDF using ITextSharp, each page having the sames template. The problem is that the PDF grows in Phisical Size by the size of the template. I HAVE to use ACROFIELDS . How can I reduce the final file size ? Here is a code snippet of the pdf handler: public void ProcessRequest(HttpContext context) { Context = context; Response = context.Response; Request = context.Request; try { LoadDataInternal(); } catch (System.Threading.ThreadAbortException) { // no-op } catch (Exception ex) { Logger.LogError(ex); Response.Write("Error"); Response.End(); } Response.BufferOutput

Bad performance convert tif to pdf using ITextSharp

丶灬走出姿态 提交于 2019-12-03 14:56:09
Summary: How can I reduce the amount of time it takes to convert tifs to pdfs using itextsharp ? Background: I'm converting some fairly large tif's to pdf using C# and itextsharp , and I am getting extremely bad performance. The tif files are approximately 50kb a piece, and some documents have up to 150 seperate tif files (each representing a page). For one 132 page document (~6500 kb) it took about 13 minutes to convert. During the conversion, the single CPU server it was running on was running at 100%, leading me to believe the process was CPU bound. The output pdf file was 3.5 MB. I'm ok