Search Results

Search found 75 results on 3 pages for 'itext'.

Page 1/3 | 1 2 3  | Next Page >

  • seam iText integration libraries

    - by Joshua
    seam iText integration seems to use older version of iText jars, would it be possible to use the latest iText 5.0.2 specific jars as part of the maven dependencies. Has anyone done this before? http://repository.jboss.org/maven2/org/jboss/seam/jboss-seam-pdf/2.2.0.GA/jboss-seam-pdf-2.2.0.GA.pom http://repository.jboss.org/maven2/com/lowagie/itext/2.1.2/itext-2.1.2.pom The following dependency uses 2.1.2 version of iText, not sure how to make it use the latest version 5.0.2 of iText. <dependency> <groupId>org.jboss.seam</groupId> <artifactId>jboss-seam-pdf</artifactId> <version>${jboss-seam.version}</version> <exclusions> <exclusion> <groupId>org.jboss.seam</groupId> <artifactId>jboss-seam</artifactId> </exclusion> <exclusion> <groupId>org.jboss.seam</groupId> <artifactId>jboss-seam-ui</artifactId> </exclusion> </exclusions> </dependency>

    Read the article

  • Co-ordinates of a element in a pdf file using iText

    - by Arun P Johny
    Hi all, I'm creating a pdf file using BIRT reporting library. Later I need to digitally sign these files. I'm using iText to digitally sign the document. The issue I'm facing is, I need to place the signature in different places in different reports. I already have the code to digitally sign the document, now I'm always placing the signature at the bottom of last page in every report. Eventually I need each report to say where I need to place the signature. Then I've to read the location using iText and then place the signature at that location. Is this possible to achieve using BIRT and iText Thanks

    Read the article

  • How to change line thickness in iText?

    - by drasto
    I'm drawing images to pdf using Java framework iText. I need to draw lines of specified width. There is a method setLineWidth(float width) in class PdfContentByte that should change it. However no matter what value I pass as its parameter the lines drawn are always extra thin. There is following line in javadoc of setLineWidth: The line width specifies the thickness of the line used to stroke a path and is measured in user space units. I don't know what is "space unit". Everything else in iText seems to be measured in point(around 1/72 inch). I cant find any reference to what are those "space units" and how to change them. code: to.setLineWidth(thickness); to.moveTo(x, y); to.lineTo(x + 100, y + 100); Variable to contains instance of PdfContentByte.

    Read the article

  • Merging two templates in iText

    - by Shaggy Frog
    Let's say I have two PDF templates created with Adobe Acrobat, which are both single-page, 8.5x11 documents. The first template (A.pdf) has content for the top half of the page. The second template (B.pdf) has content for the bottom half of the page. (It just so happens the content in both templates does not "overlap" each other.) I would like to use iText to take these two templates and create a single, "merged" template from it (C.pdf) that is only a single page (with A.pdf's content on the top half and B.pdf's content on the bottom half). (I do not want to "merge" these two files into a 2-page document. I need the final product to be a single page.) I will be running iText in a servlet environment (Tomcat 6) but I don't think that makes a difference to the answer. Is this possible?

    Read the article

  • How to change line thickness in iText? (iText is Java pdf framework)

    - by drasto
    I'm drawing images to pdf using Java framework iText. I need to draw lines of specified width. There is a method setLineWidth(float width) in class PdfContentByte that should change it. However no matter what value I pass as its parameter the lines drawn are always extra thin. There is following line in javadoc of setLineWidth: The line width specifies the thickness of the line used to stroke a path and is measured in user space units. I don't know what is "space unit". Everything else in iText seems to be measured in point(around 1/72 inch). I cant find any reference to what are those "space units" and how to change them. code: to.setLineWidth(thickness); to.moveTo(x, y); to.lineTo(x + 100, y + 100);

    Read the article

  • Extract page from PDF using iText and clojure

    - by KobbyPemson
    I am trying to extract a single page from a pdf with clojure by translating the splitPDF method I found here http://viralpatel.net/blogs/itext-tutorial-merge-split-pdf-files-using-itext-jar/ I keep getting this error IOException Stream Closed java.io.FileOutputStream.writeBytes (:-2) This prevents me from opening the document while the repl is still open. Once I close the repl I'm able to access the document. Why do I get the error? How do I fix it ? How can I make it more clojurey? (import '(com.itextpdf.text Document) '(com.itextpdf.text.pdf PdfReader PdfWriter PdfContentByte PdfImportedPage BaseFont) '(java.io File FileInputStream FileOutputStream InputStream OutputStream)) (defn extract-page [src dest pagenum] (with-open [ d (Document.) os (FileOutputStream. dest)] (let [ srcpdf (->> src FileInputStream. PdfReader.) destpdf (PdfWriter/getInstance d os)] (doto d (.open ) (.newPage )) (.addTemplate (.getDirectContent destpdf) (.getImportedPage destpdf srcpdf pagenum) 0 0))))

    Read the article

  • Is this a correct iText design?

    - by Lucas
    I´m making some pdf reports to be used on a web app. I wonder if the way I´m taking to make the designs is appropriated. This would be a screenshot of the way I´m doing the things. As you can see, I´m using tables to position everything in the document. I think this is a pretty much similar design to HTML. But I want to know is there is a better way to get the same result I got. This is the document without cell borders: I could post the code if necessary. By the way, why should I spend long hours programming these kind of stuff with iText tool when I could do things faster and maybe better looking with iReport? I like iText, it´s just a question. Sorry for my english and thanks!

    Read the article

  • iText - Modifying PDFWriter# Verticle Alignment manually

    - by simon622
    Ive hit upon a problem using iText (java), despite hours of looking thru the docs.. Most of the code I use goes via the Document# API which tracks (via the PDFWriter instance) the current Y position. HOWEVER, we need to use the PdfContentByte part of the API to insert some Java2d into the document, but in doing so this appears to bypass the logic which tracks verticle writes. So next time I use the Document API, it overwrites the contents of the manually inserted things. I want to mimick the behaviour of the Document# API by manually moving the cursor on N number of units (N being the height of the element inserted by the PDFContentByte API), such that when I then use the Document object again, bingo, its cursor is in the correct location. I can see that a method to obtain the cursor exists; PdfWriter#getVerticalPosition(boolean); But not one to set it?! Any ideas anyone? Thanks.

    Read the article

  • iText PdfPTables, document.add with writeSelectedRows

    - by J2SE31
    I am currently modifying an existing system that generates reports with iText and java. The report template is as follows: Header1(PdfPTable) Header2(PdfPTable) Body(PdfPTable) I am currently using the writeSelectedRows to display Header1 and Header2, but document.add is used to display the Body. The problem is that the system is setup to write the headers AFTER the body has already been displayed on the screen, so I am displaying my headers on top of my body content. My question is how do I add my body table (using document.add) and have it display about halfway down the page (or any predetermined vertical position)? This way I would have sufficient room to display my headers above the body table. Note: I believe the body table is using document.add to facilitate automatic paging if the body content is too large.

    Read the article

  • Move to next page if Table can not adjust in current page using iText

    - by Saurabh
    I am generating a PDF report using iText. The report is having four parts as - Project Info1 (A PDF Table of variable height) Project Info2 (A PDF Table of variable height) Requestor Info (A PDF Table of Fixed height) Location Info (A PDF Table of Fixed height) The top two information are of variable height and they can acquire certain pages. The other two are of fixed size which comes at last. I want to move the last (one or both) boxes to the next page if there is no space available to fit those boxes in current page. If space for one box is available then place one to the current page and move other box to the next table. Is there way to decide this?

    Read the article

  • itext - pdf to html

    - by Cristian Boariu
    Hi guys, I have spent about 20 hours of coding to produce invoices using iText in c#. Now, i want to use the same code to transform some of the tables to html. Do you know if i can do this? For instance i have this: PdfPTable table = new PdfPTable(3); table.DefaultCell.Border = 0; table.DefaultCell.Padding = 3; table.WidthPercentage = 100; int[] widths = { 100, 200, 100}; table.SetWidths(widths); List listOfCompanyData = (List)getCompanyData(); List listOfCumparatorDreaptaData = (List)getCumparatorDreaptaData(proformaInvoice.getCumparatorDreapta()); table.AddCell((Phrase)listOfCompanyData.Items[0]); table.AddCell(""); table.AddCell((Phrase)listOfCumparatorDreaptaData.Items[0]); and i want to transform this table into html... Is it possible?

    Read the article

  • [iText] Inserting Image onCloseDocument

    - by David
    I'm trying to insert an image in the footer of my document using iText's onCloseDocument event. I have the following code: public void onCloseDocument(PdfWriter writer, Document document) { PdfContentByte pdfByte = writer.getDirectContent(); try { // logo is a non-null global variable Image theImage = new Jpeg(logo); pdfByte.addImage(theImage, 400.0f, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f); } catch (Exception e) { e.printStackTrace(); } } The code throws no exceptions, but it also fails to insert the image. This identical code is used onOpenDocument to insert the same logo. The only difference between the two methods are the coordinates in pdfByte.addImage. However, I've tried quite a few different coordinations in onCloseDocument and none of them appear anywhere in my document. Is there any troubleshooting technique for detecting content which is displayed off-page in a PDF? If not, can anyone see the problem with my onCloseDocument method? Edit: As a followup, it seems that onDocumentClose puts its content on page document.length() + 1 (according to its API). However, I don't know how to change the page number back to document.length() and place my logo on the last page.

    Read the article

  • iText PDFReader Extremely Slow To Open

    - by Wbmstrmjb
    I have some code that combines a few pages of acro forms (with acrofields in tact) and then at the end writes some JS to the entire document. It is the PdfReader in the function adding the JS that is taking extremely long to instantiate (about 12 seconds for a 1MB file). Here is the code (pretty simple): public static byte[] AddJavascript(byte[] document, string js) { PdfReader reader = new PdfReader(new RandomAccessFileOrArray(document), null); MemoryStream msOutput = new MemoryStream(); PdfStamper stamper = new PdfStamper(reader, msOutput); PdfWriter writer = stamper.Writer; writer.AddJavaScript(js); stamper.Close(); reader.Close(); byte[] withJS = msOutput.GetBuffer(); return withJS; } I have benchmarked the above and the line that is slow is the first one. I have tried reading it from a file instead of memory and tried using a MemoryStream instead of the RandomAccessFileOrArray. Nothing makes it any faster. If I add JS to a single page document, it is very fast. So my thought is that the code that combines the pages is somehow making the PDF slow to read for the PdfReader. Here is the combine code: public static byte[] CombineFiles(List<byte[]> sourceFiles) { MemoryStream output = new MemoryStream(); PdfCopyFields copier = new PdfCopyFields(output); try { output.Position = 0; foreach (var fileBytes in sourceFiles) { PdfReader fileReader = new PdfReader(fileBytes); copier.AddDocument(fileReader); } } catch (Exception exception) { //throw } finally { copier.Close(); } byte[] concat = output.GetBuffer(); return concat; } I am using PdfCopyFields because I need to preserve the form fields and so cannot use the PdfCopy or PdfSmartCopy. This combine code is very fast (few ms) and produces working documents. The AddJS code above is called after it and the PdfReader open is the slow piece. Any ideas?

    Read the article

  • Removing PDF attachments via itext

    - by r00fus
    I'm trying to remove attachments from a number of my pdf files (I can extract via pdftk, so preserving them is not an issue). I coded the following based on an example found from a google search: import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.*; import com.lowagie.text.pdf.*; class pdfremoveattachment { public static void main(String[] args) throws IOException, DocumentException { if (args.length < 2) { System.out.println("Usage: java PDFremoveAttachments source.pdf target.pdf"); System.exit(1); } PdfReader sourcePDF = new PdfReader(args[0]); removeAttachments(sourcePDF); FileOutputStream targetFOS = new FileOutputStream(args[1]); PdfStamper targetPDF = new PdfStamper(sourcePDF,targetFOS); targetPDF.close(); } public static void removeAttachments(PdfReader reader) { PdfDictionary catalog = reader.getCatalog(); // System.out.println(catalog.getAsDict(PdfName.NAME)); // this would print "null" PdfDictionary names = (PdfDictionary)PdfReader.getPdfObject(catalog.get(PdfName.NAMES)); // System.out.println(names.toString()); //this returns NPE if( names != null) { PdfDictionary files = (PdfDictionary) PdfReader.getPdfObject(names.get(PdfName.FILEATTACHMENT)); if( files!= null ){ for( Object key : files.getKeys() ){ files.remove((PdfName)key); } files = (PdfDictionary) PdfReader.getPdfObject(names.get(PdfName.EMBEDDEDFILES)); } if( files!= null ){ for( Object key : files.getKeys() ){ files.remove((PdfName)key); } reader.removeUnusedObjects(); } } } } If anyone knows how I might be able to remove attachments, I'd greatly appreciate a reply.

    Read the article

  • Java iText Image position

    - by skowron-line
    I have: Image i = Image.getInstance("tabelka.png"); i.scalePercent(25, 25); for(int i=0; i<= 5; i++) { doc.add(i); content.moveTo(50, ??);////// <-------------- HOW TO CHECK THE Y POSITION content.showText("skowron-line"); } I want to set text on upper right corner of image. How do I do that? EIDT: After hours of thinkin i found dirty solution: Image img = Image.getInstance("tabelka.png"); img.scalePercent(25, 25); float start = x; for(int i =1; i<= 5; i++) { start = (x - (img.getHeight() * 0.25f) * i); } If U know better solution let me know.

    Read the article

  • How do I draw part of parabola using iText ? Or how do I create quadratic bezier curves from cubic b

    - by drasto
    I need to draw a shape whose boundaries are parts of parabola (that is quadratic bezier curves) using iText. I have found only method for drawing cubic bezier curves in PdfContentByte class. So how do I draw quadratic bezier curves using iText ? One way would be to use method for cubic bezier curves. Is it possible to draw quadratic bezier curves as a cubic bezier curves (with 2 control points). I gues it is but I cannot make up the formula. If somebody states the formula tu "translate" cubic bezier curves to quadratic that would solve the problem. Any other ways to draw quadratic bezier(parts of parabola) curves in iText (and filled shapes made of them) is also the solution. Thanks

    Read the article

  • Can I reset a forgotten owner password with iText?

    - by Tom Hubbard
    With iText I can use Java to open a pdf and write it. If the pdf has an owner password I can still open it but it can not be written. Clearly the content is readable, it seems like at that point you could simply write the document to a new file. iText doesn't allow this, it throws a bad password exception. Is there a way around this?

    Read the article

  • What is the best way to create PDF reports with iText and zip them together?

    - by Suresh S
    I have to create a pdf report using apache itext api and report should be zipped .For example there is a report to be generated for people staying in a location of a state. for each state there are many locations, for each location , details of eachh people under the location should be saved as pdf (for each people) finally all the pdf for a location should be zipped ,this way finally all zip files for all locations should be zipped and placed under the zip file for states . my question is how best we can develop code in java. i want a skeleton framework to do the above functionality . i thought of using recursion method.also let me know from experienced users of zip api, will there be any error during creation of many zip files.

    Read the article

  • IText Lines Per Page?

    - by exit174
    I have used IText(Sharp) to make PDFs from raster images but have never used IText to build text based PDF's. In this new scenario, I have N words of ASCII text that I need to add as text pages to a new PDF. Each page should be 8.5 x 11, .5 margins, using some monospaced font. Is IText(Sharp) smart enough to automatically apply line and page breaks where necessary or do I need to do this manually? Are their any good IText tutorials for this scenario? thanks! scottm

    Read the article

  • IText can't keep rows together, second row spans multiple pages but won't stick with first row.

    - by J2SE31
    I am having trouble keeping my first and second rows of my main PDFPTable together using IText. My first row consists of a PDFPTable with some basic search criteria. My second row consists of a PdfPTable that contains all of the tabulated results. Everytime the tabulated results becomes too big and spans multiple pages, it is kicked to the second page automatically rather than showing up directly below the search criteria and then paging to the next page. How can I avoid this problem? I have tried using setSplitRows(false), but I simply get a blank document (see commented lines 117 and 170). How can I keep my tabulated data (second row) up on the first page? An example of my code is shown below (you should be able to just copy/paste). public class TestHelper{ private TestEventHelper helper; public TestHelper(){ super(); helper = new TestEventHelper(); } public TestEventHelper getHelper() { return helper; } public void setHelper(TestEventHelper helper) { this.helper = helper; } public static void main(String[] args){ TestHelper test = new TestHelper(); TestEventHelper helper = test.getHelper(); FileOutputStream file = null; Document document = null; PdfWriter writer = null; try { file = new FileOutputStream(new File("C://Documents and Settings//All Users//Desktop//pdffile2.pdf")); document = new Document(PageSize.A4.rotate(), 36, 36, 36, 36); writer = PdfWriter.getInstance(document, file); // writer.setPageEvent(templateHelper); writer.setPdfVersion(PdfWriter.PDF_VERSION_1_7); writer.setUserunit(1f); document.open(); List<Element> pages = null; try { pages = helper.createTemplate(); } catch (Exception e) { e.printStackTrace(); } Iterator<Element> iterator = pages.iterator(); while (iterator.hasNext()) { Element element = iterator.next(); if (element instanceof Phrase) { document.newPage(); } else { document.add(element); } } } catch (Exception de) { de.printStackTrace(); // log.debug("Exception " + de + " " + de.getMessage()); } finally { if (document != null) { document.close(); } if (writer != null) { writer.close(); } } System.out.println("Done!"); } private class TestEventHelper extends PdfPageEventHelper{ // The PdfTemplate that contains the total number of pages. protected PdfTemplate total; protected BaseFont helv; private static final float SMALL_MARGIN = 20f; private static final float MARGIN = 36f; private final Font font = new Font(Font.HELVETICA, 12, Font.BOLD); private final Font font2 = new Font(Font.HELVETICA, 10, Font.BOLD); private final Font smallFont = new Font(Font.HELVETICA, 10, Font.NORMAL); private String[] datatableHeaderFields = new String[]{"Header1", "Header2", "Header3", "Header4", "Header5", "Header6", "Header7", "Header8", "Header9"}; public TestEventHelper(){ super(); } public List<Element> createTemplate() throws Exception { List<Element> elementList = new ArrayList<Element>(); float[] tableWidths = new float[]{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.25f, 1.25f, 1.25f, 1.25f}; // logger.debug("entering create reports template..."); PdfPTable splitTable = new PdfPTable(1); splitTable.setSplitRows(false); splitTable.setWidthPercentage(100f); PdfPTable pageTable = new PdfPTable(1); pageTable.setKeepTogether(true); pageTable.setWidthPercentage(100f); PdfPTable searchTable = generateSearchFields(); if(searchTable != null){ searchTable.setSpacingAfter(25f); } PdfPTable outlineTable = new PdfPTable(1); outlineTable.setKeepTogether(true); outlineTable.setWidthPercentage(100f); PdfPTable datatable = new PdfPTable(datatableHeaderFields.length); datatable.setKeepTogether(false); datatable.setWidths(tableWidths); generateDatatableHeader(datatable); for(int i = 0; i < 100; i++){ addCell(datatable, String.valueOf(i), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+1), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+2), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+3), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+4), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+5), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+6), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+7), 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, smallFont, true); addCell(datatable, String.valueOf(i+8), 1, Rectangle.NO_BORDER, Element.ALIGN_RIGHT, smallFont, true); } PdfPCell dataCell = new PdfPCell(datatable); dataCell.setBorder(Rectangle.BOX); outlineTable.addCell(dataCell); PdfPCell searchCell = new PdfPCell(searchTable); searchCell.setVerticalAlignment(Element.ALIGN_TOP); PdfPCell outlineCell = new PdfPCell(outlineTable); outlineCell.setVerticalAlignment(Element.ALIGN_TOP); addCell(pageTable, searchCell, 1, Rectangle.NO_BORDER, Element.ALIGN_LEFT, null, null); addCell(pageTable, outlineCell, 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, null, null); PdfPCell pageCell = new PdfPCell(pageTable); pageCell.setVerticalAlignment(Element.ALIGN_TOP); addCell(splitTable, pageCell, 1, Rectangle.NO_BORDER, Element.ALIGN_CENTER, null, null); elementList.add(pageTable); // elementList.add(splitTable); return elementList; } public void onOpenDocument(PdfWriter writer, Document document) { total = writer.getDirectContent().createTemplate(100, 100); total.setBoundingBox(new Rectangle(-20, -20, 100, 100)); try { helv = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); } catch (Exception e) { throw new ExceptionConverter(e); } } public void onEndPage(PdfWriter writer, Document document) { //TODO } public void onCloseDocument(PdfWriter writer, Document document) { total.beginText(); total.setFontAndSize(helv, 10); total.setTextMatrix(0, 0); total.showText(String.valueOf(writer.getPageNumber() - 1)); total.endText(); } private PdfPTable generateSearchFields(){ PdfPTable searchTable = new PdfPTable(2); for(int i = 0; i < 6; i++){ addCell(searchTable, "Search Key" +i, 1, Rectangle.NO_BORDER, Element.ALIGN_RIGHT, font2, MARGIN, true); addCell(searchTable, "Search Value +i", 1, Rectangle.NO_BORDER, Element.ALIGN_LEFT, smallFont, null, true); } return searchTable; } private void generateDatatableHeader(PdfPTable datatable) { if (datatableHeaderFields != null && datatableHeaderFields.length != 0) { for (int i = 0; i < datatableHeaderFields.length; i++) { addCell(datatable, datatableHeaderFields[i], 1, Rectangle.BOX, Element.ALIGN_CENTER, font2); } } } private PdfPCell addCell(PdfPTable table, String cellContent, int colspan, int cellBorder, int horizontalAlignment, Font font) { return addCell(table, cellContent, colspan, cellBorder, horizontalAlignment, font, null, null); } private PdfPCell addCell(PdfPTable table, String cellContent, int colspan, int cellBorder, int horizontalAlignment, Font font, Boolean noWrap) { return addCell(table, cellContent, colspan, cellBorder, horizontalAlignment, font, null, noWrap); } private PdfPCell addCell(PdfPTable table, String cellContent, Integer colspan, Integer cellBorder, Integer horizontalAlignment, Font font, Float paddingLeft, Boolean noWrap) { PdfPCell cell = new PdfPCell(new Phrase(cellContent, font)); return addCell(table, cell, colspan, cellBorder, horizontalAlignment, paddingLeft, noWrap); } private PdfPCell addCell(PdfPTable table, PdfPCell cell, int colspan, int cellBorder, int horizontalAlignment, Float paddingLeft, Boolean noWrap) { cell.setColspan(colspan); cell.setBorder(cellBorder); cell.setHorizontalAlignment(horizontalAlignment); if(paddingLeft != null){ cell.setPaddingLeft(paddingLeft); } if(noWrap != null){ cell.setNoWrap(noWrap); } table.addCell(cell); return cell; } } }

    Read the article

1 2 3  | Next Page >