itextsharp

How to create a rounded corner table using iText\\iTextSharp? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-01 11:13:52
This question already has an answer here: How do I round the corners of an iTextSharp table border? 1 answer I have to create a table having rounded corners, something like it: Can I do it with iTextSharp? This is done using cell events. See the Calendar example from my book ( Java / C# ). Make sure that you don't add any "automated" borders to the cell, but draw the borders yourself in a cell event: table.DefaultCell.Border = PdfPCell.NO_BORDER; table.DefaultCell.CellEvent = new RoundedBorder(); The RoundedBorder class would then look like this: class RoundedBorder : IPdfPCellEvent { public

Reading PDF Bookmarks in VB.NET using iTextSharp

隐身守侯 提交于 2019-12-01 11:00:01
I am making a tool that scans PDF files and searches for text in PDF bookmarks and body text. I am using Visual Studio 2008 with VB.NET with iTextSharp. How do I load bookmarks' list from an existing PDF file? It depends on what you understand when you say "bookmarks". You want the outlines (the entries that are visible in the bookmarks panel): The CreateOnlineTree examples shows you how to use the SimpleBookmark class to create an XML file containing the complete outline tree (in PDF jargon, bookmarks are called outlines). Java: PdfReader reader = new PdfReader(src); List<HashMap<String,

itextsharp: splitted pages size equals file size

蹲街弑〆低调 提交于 2019-12-01 10:56:42
Here is how I split large pdf (144 mb) public int SplitAndSave(string inputPath, string outputPath) { FileInfo file = new FileInfo(inputPath); string name = file.Name.Substring(0, file.Name.LastIndexOf(".")); using (PdfReader reader = new PdfReader(inputPath)) { for (int pagenumber = 1; pagenumber <= reader.NumberOfPages; pagenumber++) { string filename = pagenumber.ToString() + ".pdf"; Document document = new Document(); PdfCopy copy = new PdfCopy(document, new FileStream(outputPath + "\\" + filename, FileMode.Create)); document.Open(); copy.AddPage(copy.GetImportedPage(reader, pagenumber));

Remove hyperlinks from a PDF document (iTextSharp)

安稳与你 提交于 2019-12-01 10:54:05
问题 I'm trying to leverage iTextSharp (very new to the product) to remove hyperlinks from a PDF document. Does anyone know if this is possible? I've been digging through the API and haven't found an obvious way to do this. My problem is that I'm doing maintenance on a system that has PDFs empbedded in an iframe and the links within the PDF are causing users to end up browsing the site within the iframe rather than in a new window or tab so I'm looking for a way to kill the links in the PDF at

Extract paths and shapes with iTextSharp

不羁岁月 提交于 2019-12-01 10:52:26
iTextSharp supports creation of shapes and paths with PdfContentByte class, there you can set colors and paint curves and basic elements ... is there a mechanism which does the other way? I am able to get content by calling PdfReader.GetPageContent(...) but I didn't find a "parser" to read those operations, apply them to graphics context and for example paint it on a panel. Example: 1 1 1 RG 1 1 1 rg 0.12 0 0 0.12 16 31 cm q 480 421 m 4318 421 l 4318 5459 l 480 5459 l 480 421 l W n 0.074509806931 0.074509806931 0.074509806931 RG 0.074509806931 0.074509806931 0.074509806931 rg /OC /oc1 BDC ....

How to Check PDF is Reader enabled or not using C#?

让人想犯罪 __ 提交于 2019-12-01 10:44:50
My only requirement is to find a selected pdf in a folder is Reader enabled or not, more specifically if usage rights are defined in a way that allows people to add annotations (e.g. comments). I am doing this in windows application. If I click a button, an event is triggered searching a folder for PDF files. This event needs to check whether or not the PDFs in the folder are Reader enabled for comments. If they are, I need to remove the comment usage rights or revert the PDF back to its original version. My code can only find PDF files in the folder. I don`t know how to check if the selected

get original content of a pdf signed with itextsharp

纵饮孤独 提交于 2019-12-01 10:08:20
问题 I'm trying to get the original document of a signed PDF in order to compare it's hash with an stored doc. This is really easy when the document has several signatures, with acrobat reader you can go the previous revision of the document save it and that's it. Surprisingly this does not work with the first signature, where there is no straight forward way to get the original data. As it is not possible to do it with the reader I have tried programatically with iTextSharp. However although I

Create an Image or PdfTemplate from a PDF file

让人想犯罪 __ 提交于 2019-12-01 09:45:36
问题 While using the itextsharp library for pdf generation, I came across this method:- iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(itextsharp.text.pdf.PdfTemplate); Where, we can get Image instance from a PdfTemplate. But, I don't know how to create a PdfTemplate and there is no constructor taking a pdf file name or stream. Why I want this is: I want to create an Image from a PDF file and then isert this image into another pdf file. Anybody knows how to create PdfTemplate object

iTextSharp generate PDF and show it on the browser directly

主宰稳场 提交于 2019-12-01 09:27:43
How to open the PDF file after created using iTextSharp on ASP.Net? I don't want to save it on the server, but directly when the new PDF is generated, it shows on the browser . Is it possible to do that? Here is the example for what I mean: Click here . But on this example, the file directly downloaded. How can I do that? Dim doc1 = New Document() 'use a variable to let my code fit across the page... Dim path As String = Server.MapPath("PDFs") PdfWriter.GetInstance(doc1, New FileStream(path & "/Doc1.pdf", FileMode.Create)) doc1.Open() doc1.Add(New Paragraph("My first PDF")) doc1.Close() The

itextsharp add text over a circle image in a table cell

空扰寡人 提交于 2019-12-01 08:49:46
问题 I need to have a table with multiple columns where I have different coloured circles in different cells with a number in the middle of the circle. Similar to the mockup below but with everything centralized and equal. I have tried the following: PdfContentByte canvas = writer.DirectContent; PdfTemplate template = canvas.CreateTemplate(40, 40); template.SetLineWidth(1f); template.Circle(15f, 15f, 15); template.Stroke(); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(template);