Draw polygon using iText

hi...
i am working on projects that create some pdf files.. and am using iText to create the pdf files..
i am trying to draw a polygon(size-5) ..but i cant find anything in itext that help me
to create that polygon,,,,
so tell me some way or any tutorials ?
Thanks & Regards
fun_with_me

fun_with_me wrote:
>
Oh dear!
And we are still waiting for you to learn [How to Ask Questions the Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html] .
if you dont have the answer ..just leave it..
before suggesting others...
i think you need to check your manner first.If you had followed the link, you would have seen that the first rule under "When You Ask" is "Choose your forum carefully" and includes the following advice:
Be sensitive in choosing where you ask your question. You are likely to be ignored, or written off as a loser, if you:
post your question to a forum where it's off topic
The first step, therefore, is to find the right forum. Again, Google and other Web-searching methods are your friend. Use them to find the project webpage most closely associated with the hardware or software giving you difficulties. Usually it will have links to a FAQ (Frequently Asked Questions) list, and to project mailing lists and their archives. These mailing lists are the final places to go for help, if your own efforts (including reading those FAQs you found) do not find you a solution. The project page may also describe a bug-reporting procedure, or have a link to one; if so, follow it.Clearly you didn't read the link before writing it off as, um, whatever you wrote it off as. I'd recommend reading the manual before posting again.

Similar Messages

  • Draw polygon in applet

    HI,
    I want to be able to draw polygon using java applet. I have code to draw poly in an applet but I am wondering if the java tool can draw directly on html image not on image inside of applet.
    Please help
    Ying

    You can generate a gif which is displayed inside a HTML screen.
    Note: HTML does not support polygon drawing so you cannot write HTML to draw a polygon. Unless you want a rectangle (use a table :)

  • How to construct checkbox in rtf document using iText?

    Hi fiends
    I am developing a rtf document usng iText api ,I am facing problem when i want to draw a check box in the document so is there any way using iText only to draw a checkbox in rtf document?Or iText doesn't allow construct checkbox?please suggest.An example will be appreciated.Thanks in advance.
    Regards soumyanil

    For your kind information this is a site that provides support for JAVA programming and JAVA Servlets related questions.
    You need some information regarding a third party API, so please dont hesitate to contact your vendor.
    The vendor URL: http://itextdocs.lowagie.com/
    The tutorial you need to learn before starting iText is http://itextdocs.lowagie.com/tutorial/
    All the best!

  • Using iText to generate a digital signature that can be signed in Adobe Reader

    I am able to create a digital signature in a pdf using iText.  Adobe Reader does not allow that digital signature to be signed.  Everything I have been reading suggests that I need to enabe Reader Usage Rights, but that requires using Adobe Pro.  I was hoping that I would only need Adobe Reader inorder to digitally sign the pdf, is that possible?

    Not without the required rights...

  • Arabic text in my web application using iText..

    Hey Guys,
    I'm using the iText library to produce PDF reports in my web application; platform (ADF 11g and Weblogic 10g). I'm having a problem with rendering arabic text on the page, is there a way to print arabic text outside of a PdfPTable ?? I need to print a simple text like the title of the report , the subtitle and so on... please guys I need an answer...
    Thanks in advance.
    AccadSoft

    gimbal2 wrote:
    sabre150 wrote:
    AccadSoft wrote:
    please guys I need an answer.To get answers about using iText I use "iText In Action, 2nd edition" by the prime author of iText - Bruno Lowagie.Classic way to make money - make the API free and sell the documentation. Also an honorable way to make money IMO.I was using iText before 2004 when the first edition of the book came out ( 4 years or so after the library was first introduced) and it was hard work. PDF is a very complex document format and just using the Javadoc does not really get you anywhere. There are many 'gotchas' in iText and most of the iText tutorials cover only the very basics and pretty much none of the 'gochas'. The book starts off with very simple examples that could be constructed from the Javadoc but then it does move on to the more complex issues. Worth every penny.

  • How to write special characters in PDF using iText

    How to write special characters encoded with UTF-8 in PDF using iText.
    Regards,
    Pandharinath.

    I don't know what your problem is but that's almost certainly the wrong question to ask about it. Java (including iText) uses only Unicode characters. (You may consider some of them to be "special" if you like but Unicode doesn't.) And when it does that, they aren't encoded in UTF-8 or any other encoding.
    So can you describe your problem? That question doesn't make sense.

  • How To Read RTF file in JAVA?  Using  iText?

    How To Read RTF file in JAVA?  Using  iText?.....
    import java.io.*;
    import com.lowagie.text.*;
    import com.lowagie.text.rtf.*;
    public class RTF3 {
    public static void main(String[] args) {
    // System.out.println("This example generate a RTF file name Sample.rtf");
    // Create Document object
    Document myDoc = new Document();
    try {
    // Create writer to listen document object
    // and directs RTF Stream to the file Sample.rtf
    RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
    // open the document object
    myDoc.open();
    // Create a paragraph
         Paragraph p = new Paragraph();
         p.add("Helloworld in Rtf file..amazing isn't");
         // Add the paragraph to document object
    myDoc.add(p);
    catch(Exception e) {
    System.out.println(e);
    //close the document
    myDoc.close();
    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
         at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
         at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
         at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
         at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
         at com.lowagie.text.Document.open(Unknown Source)
         at view.RTF3.main(RTF3.java:23)
    CAN you HELP me?

    import com.lowagie.text.Document;
    import com.lowagie.text.rtf.parser.RtfParser;
    import java.io.FileInputStream;
    String inputFile = "sample.rtf";
    Document document = new Document();
    document.open();
    RtfParser parser = new RtfParser(null);
    parser.convertRtfDocument(new FileInputStream(inputFile), document);

  • Creating PDF using ITEXT API's - error

    Hi,
    In my WebDynpro Application I want to generate a PDF (using ITEXT API's) out of the data retrieved from back end system .
    I used this source code.
    Document document = new Document(PageSize.A4);
    document.open();
    PdfPTable table = new PdfPTable(1);
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph("ONE"));
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("TWO"));      
    table.addCell(cell);
    document.add(table);
    document.close();
    byte[] b = new byte[100 * 1024];
    b =  document.toString().getBytes("UTF-8");
    IWDCachedWebResource pdfRes = WDWebResource.getPublicCachedWebResource(b, WDWebResourceType.PDF, WDScopeType.CLIENTSESSION_SCOPE,      wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),"FileNameHelloText"));
    I have used Window Manager to create a external window with the URL from pdfRes.getUrl() method.
    After execution i get a pop up window with out PDF document.
    Please let me know your thoughts & solutions to the above mentioned problem.
    Thanks
    Senthil

    Hello Folks,
                   Use the following snippet of the code to generate PDF using ITEXT API.
                                       Document document = new Document(PageSize.A4);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         PdfWriter.getInstance(document, bos);
         document.open();
                    PdfPTable table = new PdfPTable(1);
                    PdfPCell cell;
                    cell = new PdfPCell(new Paragraph("ONE"));
                    table.addCell(cell);
                    cell = new PdfPCell(new Paragraph("TWO"));      
                    table.addCell(cell);
                    document.add(table);
                    document.close();
                    byte [] byteContent = bos.toByteArray();
         IWDCachedWebResource cachedResource =
                             WDWebResource.getPublicCachedWebResource(
              byteContent,
              WDWebResourceType.PDF,
              WDScopeType.CLIENTSESSION_SCOPE,
              wdThis
                                          .wdGetAPI()
                                          .getComponent()
                                          .getDeployableObjectPart(),
              "TestPDF");
                  IWDWindow externalWindow =
            wdComponentAPI
                            .getWindowManager()
                            .createExternalWindow(cachedResource.getURL(),                         "PDF Window",true);
                  externalWindow.open();
    Thanks and Regards,
    Gopi

  • Creating PDF file in XI using iText

    Hi all,
    I am trying to create a PDF file in XI using itext. The PDF file is getting created in my target ftp server but I am not able to open the PDF. It is throwing the below error while opening.
    "Adobe Reader could not open the sample.pdf because it is either not a supported file or because the file has been damaged(for example,it was sent as an e mail attachment and wasn't correctly decoded)"
    I am using the below code in my udf
    String filename= "Sample.pdf";
    try
    Document document= new Document();
    PdfWriter pdfwriter=PdfWriter.getInstance(document,new FileOutputStream(filename));
    document.open();
    document.add(new Paragraph("Hi How are you?"));
    document.close();
    DynamicConfiguration conf = (DynamicConfiguration) container
           .getTransformationParameters()
           .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    conf.put(key,filename);
    catch(Exception e)
    return "";
    Kindly let me know if you have any information on this.
    With Regards
    jaisu.
    Edited by: jaisu118 on Feb 12, 2010 8:04 AM

    hi,
    I had used custom adapter module for creating the PDF file.
    you have to use java mapping if you want to create pdf without using adapter module.
    You need to import iText library available at http://itextpdf.com/.
    How to use external jar files ??
    External Jar files in UDF
    code may look like this:
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    //1. AbstractTransformation class is imported.
    // The associated jar file is: com.sap.xpi.ib.mapping.lib.jar
    import com.sap.aii.mapping.api.AbstractTransformation;
    import  com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import com.sap.aii.mapping.api.InputHeader;
    public class xyz extends AbstractTransformation {
    public void transform(TransformationInput inp, TransformationOutput out) throws StreamTransformationException {
         getTrace().addInfo("JAVA Mapping Called");
                         InputStream inData = inp.getInputPayload().getInputStream();
                        // pdf conversion code
                        out.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
    check http://help.sap.com/javadocs/pi/SP3/xpi/index.html for java mapping api.
    Thanks.

  • Adding a link in PDF using itext

    I am adding a link in PDF using itext and opening the link from the final created pdf using app.launchURL and app.getURL
    it works fine on windows XP but does nothing on MAC OSX /IOS

    Hi Lynn
    And here I was about to suggest you review the link below.
    Silly me.
    Click
    here to read the article
    Sincerely... Rick

  • Display Pdf report on Frame using iText library

    Hi,
    I am able to generate pdf reports using iText library. but i want to display these generated pdf into frame. can u please help for this.
    this is web based application. Through servlet i am generating the pdf report using iText library. I am waiting for your reply ....

    Does this PDF file absolutely need to be displayed within a JFrame? You say you are generating this document on the server side, so if this is a web application, what I might do is place the generated document on directory accessible through http, then on the client browser side open a pop-up browser window with a URL to the PDF document.
    Most browsers have a PDF viewer plugin of some kind.
    If this is a swing application then you can do the same thing but instead of redirecting the browser to the PDF file you can use iText to convert the PDF document to an RTF document and use an RTFEditorKit within a JEditorPane to display the same document in RTF format.

  • How read a pdf file and change TableCell height after reading it using itext api

    I have created a pdf form file using itext ( see class CreatingFormClass ) with itext PdfPTable and PdfPCell. It is done successfully .
    Now I  read this pdf file and filling this pdf file(see class FillingFormClass  ) and at this point i want to change  PdfPCell height () according to Items.
    It is possible or Not???
    My code is given below.
    Thanx in advance
    public class FillPdfFormMainClass {
    public static  String RESULT1 = "E:/BlankForm.pdf";
        public static  String RESULT2 = "E:/FilledForm.pdf";
        public static void main(String[] args) throws DocumentException, IOException {
            String empName="Rakesh Kumar Verma";
                    // This part is Dynamic. It can be 1 item Or can be 25 items
            String listOfItem="Item 1 \n Item 2 \n Item 3\n Item 4 \n Item 5 \n Item 6 \n Item 7 \n Item 8 \n Item 9";
            CreatingFormClass example = new CreatingFormClass(0);
            example.createPdf(RESULT1);
            FillingFormClass class1 = new FillingFormClass();
            class1.manipulatePdf(RESULT1, RESULT2,empName,listOfItem);
    public class CreatingFormClass implements PdfPCellEvent {
        protected int tf;
        public CreatingFormClass(int tf) {
            this.tf = tf;
        public void createPdf(String filename) throws DocumentException, IOException {
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream(filename));
            document.open();
            PdfPCell cell;
            PdfPTable table = new PdfPTable(2);
            table.setWidths(new int[]{1, 2});
            table.addCell("Name:");
            cell = new PdfPCell();
            cell.setCellEvent(new CreatingFormClass(1));
            table.addCell(cell);
            table.addCell("Item List:");
            cell = new PdfPCell();
            cell.setCellEvent(new CreatingFormClass(2));
            cell.setFixedHeight(60);
            table.addCell(cell);
            document.add(table);
            document.close();
        public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
            PdfWriter writer = canvases[0].getPdfWriter();
            TextField text = new TextField(writer, rectangle, String.format("text_%s", tf));
            text.setBackgroundColor(new GrayColor(0.95f));
            switch (tf) {
                case 1:
                    text.setText("Enter your name here...");
                    text.setFontSize(8);
                    text.setAlignment(Element.ALIGN_CENTER);
                    break;
                case 2:
                    text.setFontSize(8);
                    text.setText("Enter Your Address");
                    text.setOptions(TextField.MULTILINE);
                    break;
            try {
                PdfFormField field = text.getTextField();
                writer.addAnnotation(field);
            } catch (IOException ioe) {
                throw new ExceptionConverter(ioe);
            } catch (DocumentException de) {
                throw new ExceptionConverter(de);
    public class FillingFormClass {
        public void manipulatePdf(String src, String dest,String empName,String listOfItem) throws IOException, DocumentException {
            PdfReader reader = new PdfReader(src);
            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(String.format(dest, empName)));
            AcroFields form = stamper.getAcroFields();
            form.setField("text_1", empName);
            form.setField("text_2", listOfItem);
            stamper.close();
            reader.close();

    Hi,
    I am facing the same problem. Please help me out. I just want to read a PDF file as bytes from one location and write it as another pdf file in some other location with a diolog box prompting to open or save in the location where we want.
    I executed the following code:
    try{
    File report =new File(location);
    BufferedInputStream in=new BufferedInputStream(new FileInputStream(report));
    response.setContentType("application/x-download");
    response.setHeader("Content-Disposition", "attachment; filename=" + report.getName());
    OutputStream outs = response.getOutputStream();
    int readlen;
    byte buffer[] = new byte[ 256 ];
    while( (readlen = in.read( buffer )) != -1 )
    outs.write( buffer, 0, readlen );
    outs.flush();
    outs.close();
    in.close();
    response.setStatus(HttpServletResponse.SC_OK);
    } catch (FileNotFoundException fileNotFoundException) {
    PrintWriter out= response.getWriter();
    out.print("<center><Font color = 'RED'><b>"+PxDSLUtils.getApplicationProperty("label.error.CTM_E017")+"</b></Font></center>");
    Though it prompts with open, save dialog box when i try to open directly or when i save it some where locally and then open it i am getting the following message " File is repaired ot damaged.Operation failed." Any idea about what can be done??? Its very urgent.Please suggest.
    I am not convetin to string just reading and writng as bytes itself.
    Thanks in advance,
    Mani

  • Problem while generating PDF using iText

    Hi:
    I have generated PDF using iText, where i have written all code in sequential flow.
    <code>
    com.lowagie.text.Document document = new com.lowagie.text.Document(PageSize.A4, 55, 5, 20, 20);
    OutputStream outputstream = response.getOutputStream();
    PdfWriter.getInstance(document,outputstream);
    </code>
    And i have added all fields in the document.
    But my problem is how to display total pagecount on all pages e.g.1\20 (because i have generated PDF sequentially)
    Also i want to add watermark on all pages.
    So, can any body help me to solve this problem?
    Thank You,
    Balaji

    sabre150 wrote:
    Maybe http://itext-general.2136553.n4.nabble.com/
    Nice pron link in there :/

  • InvalidPDFHeaderSignature Exception while opening pdf using itext jar

    Hi,
    I am getting InvalidPDFHeader while opening pdf file using itext jar.
    How to overcome this?
    Thanks,
    Veera

    Please continue in your previous thread: Sample code to dynamically append bytes to pdf
    Mod: I'm locking up.

  • Adding text to PDF using iText instead of CFPDF

    Hi,
    I know this may seem a bit off topic being posted here but i'm asking this board since i'm a complete JAVA noob and i figure some of you CF folk might have had to do this before.
    Anyway, about my question...i'm already adding a watermark image to a pdf using iText (CF8) thanks to the help of fellow poster (=cfSearching=).  What i'm looking for is the best way to go about adding some text to this same pdf.  I need to add 4 lines of text (with specific font and size) and center it underneath the added image.   Does anyone have a site they could point me to as to how to add formatted text and how to get the width of that text so as to align it correctly?  I've search Google and looked at a lot of JAVA code but being a JAVA noob it's tough to figure out exactly which libs and methods can be used to do this. 
    Any help would be greatly appreciated!
    -Michael

    Hi again!
    Well, the merged image is an idea but i'd rather have it be actual text so that it is at least copy/paste-able if viewed on a computer.
    The four lines of text are dynamic (company name, broker name, phone number, email address) and limited to 40 characters.  Right now they are being added via CFPDF and DDX and use the following code in the DDX file to add it to the PDF.
    <PDF result="DestinationFile">
         <PDF source="SourceFile">
              <Watermark
              rotation="0"
              opacity="100%"
              horizontalAnchor="#horzAnchor#"
              horizontalOffset="#horzOffset#"
              verticalAnchor="#vertAnchor#"
              verticalOffset="#vertOffset#"
              alternation="OddPages"
              >
                   <StyledText text-align="center">
                        <p font="#font#" color="#color#" >#left(dCompany,maxlinechars)#</p>
                        <p font="#font#" color="#color#" >#left(dName,maxlinechars)#</p>
                        <p font="#font#" color="#color#" >#left(dPhone,maxlinechars)#</p>
                        <p font="#font#" color="#color#" >#left(dEmail,maxlinechars)#</p>
                   </StyledText>
              </Watermark>
         </PDF>
    </PDF>
    Then using the created pdf from above, i use a slightly modified version of the cfscript code ( that uses iText) you provided me previously to add a logo image just above this text.  The only changes i made to it were resizing of the image and adding where to place it.  Here is that code:
    <cfscript>                    
        fullPathToInputFile = "#tempdestfilepath#";
         writeoutput("<br>fullPathToInputFile=#fullPathToInputFile#");
        fullPathToWatermark = osFile("#request.logofilepath##qord.userlogo_file#",request.os);
         writeoutput("<br>fullPathToWatermark=#fullPathToWatermark#");
        fullPathToOutputFile =  "#destfilepath#";
         writeoutput("<br>fullPathToOutputFile=#fullPathToOutputFile#");
         ppi = 72; // points per inch
         watermark_x =  ceiling(#qord.pdftemplate_logo_x# * ppi);      // from bottom left corder of pdf
         watermark_y =  ceiling(#qord.pdftemplate_logo_y# * ppi);     // from bottom left corder of pdf
         fh = ceiling(0.75 * ppi);
         fw = ceiling(1.75 * ppi);
       if( not fileexists(fullPathToInputFile) )
                  savedErrorMessage = savedErrorMessage & "<li>Input file pdf for logo add does not exist<br>#fullPathToInputFile#</li>";
       else
                 try {
                 // create PdfReader instance to read in source pdf
                 pdfReader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(fullPathToInputFile);
                 totalPages = pdfReader.getNumberOfPages();
                 // create PdfStamper instance to create new watermarked file
                 outStream = createObject("java", "java.io.FileOutputStream").init(fullPathToOutputFile);
                 pdfStamper = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(pdfReader, outStream);
                 // Read in the watermark image
                 img = createObject("java", "com.lowagie.text.Image").getInstance(fullPathToWatermark);
                    w = img.scaledWidth();
                   h = img.scaledHeight();
                   //$is[0] = w
                   //$is[1] = h
                   if( w >= h )
                      orientation = 0;
                  else
                      orientation = 1;
                      fw = max_h;
                      fh = max_w;
                  if ( w > fw || h > fh )
                      if( ( w - fw ) >= ( h - fh ) )
                          iw = fw;
                          ih = ( fw / w ) * h;
                      else
                          ih = fh;
                          iw = ( ih / h ) * w;
                      t = 1;
                  else
                      iw = w;
                      ih = h;
                      t = 2;
                 // adding content to each page
                 i = 0;
                 //while (i LT totalPages) {
                     i = i + 1;
                     content = pdfStamper.getOverContent( javacast("int", i) );
                     img.setAbsolutePosition(javacast("float", watermark_x), javacast("float", watermark_y));
                        if(t==1)
                             img.scaleAbsoluteWidth( javacast("float", iw) );
                             img.scaleAbsoluteHeight( javacast("float", ih) );
                     content.addImage(img);
                     WriteOutput("Watermarked page "& i &"<br>");
                 //WriteOutput("Finished!");
                 catch (java.lang.Exception e) {
                 savedErrorMessage = savedErrorMessage & "<li>#e#</li>";
             // closing PdfStamper will generate the new PDF file
             if (IsDefined("pdfStamper")) {
                 pdfStamper.close();
             if (IsDefined("outStream")) {
                 outStream.close();
    </cfscript>
    The above code resized the image to a certain width/height if needed and adds it to the pdf. 
    I just figured they might be a way to tap into one of the java objects that would allow adding the text.  Ideally, adding the text and image to some sort of 'bounding box' that would allow centering of the image and text in relation to that bounding box.  Or if there is no way to add to a bounding box, a way to get the horizontal length of the longest line of text so i could calculate a common centerline for the image and text.
    I've attached the following pdf to show how the image and text would look together.  This example is not to scale but a similar image and text would be added to a separate pdf.
    Thanks for you help.

Maybe you are looking for

  • Firefox 5.0 and Flash plugin 10,3,181,34 (current) will not play NPR audio nor BBC audio/video. MAC OS 10.6.8 both NPR work with Safari v.

    tried re-installing firefox and the flash plugins. set all the setting in the applications preferences to prompt(no prompts received), tried disabling all the plugins expecting messages that plugin in missing or disabled(no message). No problems with

  • File to Mail - no mapping

    Hi Experts,      I have the following scenario to be done. I want to pick up a file from the FTP location and send it to a mail box as attachment. I went thro many blogs for configuring the sender FILE adapter & receiver MAIL adapter. My question is

  • Asynchronously writing and callback function

    hi everybody, i am working on an asynchronous write operation as described in 'Asynchronously Reading and Writing with the NI-DAQmx Visual C++ Class Library' in the Visual Studio .NET documentation. I've worked with asynchronous read functions and ca

  • Image missing in  Km document iview

    Hi all,          we are trying to create a km document iview by uploading a word document under Km Content and publishing it.giving the Path to document as /WebEditing_System/HTML/published/Articles/Corporate/Home/Communication%20Contacts/HR%20Share%

  • Will this be enough to get started?

    I'm considering one of the refurb MBPs with 1 gig of ram. I'm not a raw shooter. I use my d200 in the jpeg highest settings but I like the way aperture files and stores + some of the other features interest me. I will keep the harddrive fairly empty