itextsharp

iTextSharp PDF Merging and adding page number in one go

北战南征 提交于 2019-12-25 07:53:24
问题 I use this code to merge and add page number to the document: Using stream As FileStream = New FileStream(targetPDF, FileMode.Create) Dim myDoc As Document If (ExportOption.Orientation = Global.GenerateReport.GenerateReport.Orientation.Portrait) Then myDoc = New Document(New iTextSharp.text.Rectangle(PAGE_WIDTH, PAGE_HEIGHT), MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, MARGIN_BOTTOM) myDoc.SetPageSize(PageSize.A4) Else myDoc = New Document(New iTextSharp.text.Rectangle(PAGE_WIDTH, PAGE_HEIGHT),

PDFBox 0.7.3 convert pdf to text

╄→尐↘猪︶ㄣ 提交于 2019-12-25 07:18:20
问题 I want to convert pdf file to text file but some of pdf files do not work with pdfbox dll as the version of acrobat in newer than Acrobat 5.x Please tell me what i do? output.WriteLine("Begin Parsing....."); output.WriteLine(DateTime.Now.ToString()); PDDocument doc = PDDocument.load(path); PDFTextStripper stripper = new PDFTextStripper(); output.Write(stripper.getText(doc)); 回答1: Your first attempt should be to try with a current version of PDFBox. Your version 0.7.3 dates back to 2006!

Dynamic PDF Row Mockup

青春壹個敷衍的年華 提交于 2019-12-25 05:58:09
问题 I have a small problem and the answer is probably really obvious and simple, but I guess I have failed in searching the internet for an answer, so once again I came to you guys. I'm dynamically generating a PDF file in asp.net with c#, and right now I'm just making the base for it. One of the things it generates is a table in which a cart content should be revealed (yes I'm talking about an invoice) and I'm trying to give the table some mockup, but the mock up for the upper row will be

Find x,y position of last line in pdf file - itextsharp

半腔热情 提交于 2019-12-25 05:18:08
问题 I want to add an image to a pdf file. the position of the image should be just above the last line in a pdf file. How do I get the x,y position of the last line in the pdf or the x,y position of the end of the last text block. 回答1: Look for an object named TextMarginFinder and use it like is done in this Java example: ShowTextMargins public void addMarginRectangle(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfReaderContentParser

Export to PDF from Gridview with ITextSharp

做~自己de王妃 提交于 2019-12-25 04:36:33
问题 I use to generate a PDF file from a gridview using iTextSharp library. This is my simple GridView in aspx page: <asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="False" EmptyDataText="GV Empty." DataKeyNames="ID" CssClass="mGrid" Width="500" HorizontalAlign="Center"> <Columns> <asp:BoundField DataField="Day" HeaderText="Day" ReadOnly="true" HtmlEncode="false" ItemStyle-HorizontalAlign="Center" ItemStyle-CssClass="ddl_Class_new" DataFormatString="{0:dd/MM/yyyy}" /> <asp:BoundField

Extract font height and rotation from PDF files with iText/iTextSharp

旧街凉风 提交于 2019-12-25 04:30:16
问题 I created some code to extract text and font height from a PDF file using iTextSharp, but does not handle text rotation. How can that information be extracted/computed? Here is the code: // Create PDF reader var reader = new PdfReader("myfile.pdf"); for (var k = 1; k <= reader.NumberOfPages; ++k) { // Get page resources var page = reader.GetPageN(k); var pdfResources = page.GetAsDict(PdfName.RESOURCES); // Create custom render listener, processor, and process page! var listener = new

pdfstamper HTMLWorker itextSharp

回眸只為那壹抹淺笑 提交于 2019-12-25 04:19:43
问题 My application is MVC c#, I use itextSharp 5.3.4 to generate PDF using an existing template. I add text to the form fields (from sql database) using: pdfFormFields.SetField("Notes", cth.Notes.ToString()); The challenge I have is adding html contents, for example: text text <img alt="" height="133" src="/Content/UserFiles/635380078478327671/Images/test.png" width="179" /> I used before HTMLWorker to generate paragraphs using: public Paragraph CreateSimpleHtmlParagraph (String text) { string

iTextSharp extract each character and getRectangle

a 夏天 提交于 2019-12-25 03:38:27
问题 I would like to parse an entire PDF character by character and be able to get the ASCII value, font and the Rectangle of that character on that PDF document which I can later use to save as a bitmap. I tried using PdfTextExtractor.GetTextFromPage but that gives the entire text in the PDF as string. 回答1: The text extraction strategies bundled with iTextSharp (in particular the LocationTextExtractionStrategy used by default by the PdfTextExtractor.GetTextFromPage overload without strategy

How to restrict a content of string to less than 4MB and save that string in DB using C#

丶灬走出姿态 提交于 2019-12-25 03:35:22
问题 I'm working on a project where I need to get the Text data from pdf files and dump the whole text in a DB column. With the help of iTextsharp, I got the data and referred it String. But now I need to check whether the string exceeds the 4MB limit or not and if it is exceeding then accept the string data which is less than 4MB in size. This is my code: internal string ReadPdfFiles() { // variable to store file path string filePath = null; // open dialog box to select file OpenFileDialog file =

itextsharp scale image sent as a string

谁都会走 提交于 2019-12-25 03:32:54
问题 I send the following string string text = <img alt=\"\" src=\"http://localhost:6666/content/userfiles/admin/images/q4.png\" /><br/> to: public static Paragraph CreateSimpleHtmlParagraph (String text) { string fontpath = System.Web.HttpContext.Current.Server.MapPath("~/Content/"); BaseFont bf = BaseFont.CreateFont(fontpath + "ARIALUNI.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); var f = new Font(bf, 10, Font.NORMAL); var p = new Paragraph { Alignment = Element.ALIGN_LEFT, Font = f }; var