Hi,

I have managed to write a small sample program that create a 'corrupt' pdf file. I have used iText-1.01 to write the pdf and are using full Acrobat 5.0.5 to edit the document fields.

The symptom of corruption is the error message:

    "An error occured during processing of an Annotiation or a
    hyperlink. A problem occured while reading the document (15)."

when I use the mouse to click on the first field. As a bonus weirdness it is possible to move focus to the first field if I initially press the tab key. In that case I notice that Acrobat consider the document modified despite that nothing has been entered in any of the fields.

Does anybody knows what the error number '(15)' means?

If I make small changes to the program, then I can edit the generated pdf. Such changes are:

    - removed the multiline option on the second field.
    or
    - Adding the fields in reversed order.
    or
    - moving the 5 fields to the 1. page.


regards, finn

Attachment: corr.pdf
Description: Adobe PDF document

import java.io.*;
import java.awt.Color;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class corr {
    public static void main(String[] args) throws Exception {
        Document pdfDoc = new Document();
        PdfWriter pdfWriter = PdfWriter.getInstance(pdfDoc,
                        new FileOutputStream("corr.pdf"));
        pdfDoc.open();

        pdfDoc.add(new Paragraph("hello"));
        pdfDoc.newPage();

        addField(pdfWriter, 231f, 659.812f, 519.682f, 679.812f, "B1.1", false);
        addField(pdfWriter, 231f, 610.162f, 519.682f, 658.162f, "B1.2", true);
        addField(pdfWriter, 231f, 588.512f, 375.682f, 608.512f, "B1.3", false);
        addField(pdfWriter, 231f, 566.862f, 375.682f, 586.862f, "B1.4", false);
        addField(pdfWriter, 231f, 545.212f, 375.682f, 565.212f, "B1.5", false);

        pdfDoc.close();
    }
    
    private static void addField(PdfWriter pdfWriter, 
                          float x, float y, float rx, float ry,
                          String name, boolean multi) throws Exception {
        TextField field = new TextField(pdfWriter, 
                                        new Rectangle(x, y, rx, ry), name);
        
        field.setBackgroundColor(Color.decode("#d2dadf"));
        field.setBorderColor(Color.decode("#000000"));
        field.setBorderWidth(1);
        field.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);

        BaseFont font = BaseFont.createFont("Helvetica",
                                            BaseFont.CP1252, false);
        field.setFont(font);
        field.setFontSize(12);
        if (multi)
            field.setOptions(field.MULTILINE);
        PdfFormField ff = field.getTextField();
        pdfWriter.addAnnotation(ff);
    }
}

Reply via email to