Quantcast

corrupt PDF generated

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

corrupt PDF generated

bravegag2
corrupt PDF generated

Hello,

I use the code below to dynamically create the form-like section of a Letter. The form is pre-populated with default data that should be editable by the user right before printing. The row span is computed automatically according to the actual default data e.g. a row may span 5 rows if the length of the content value is large.

I'm prototyping this in Windows XP with the most up to date version of Adobe 8 products. The rendering of the generated PDF looks perfectly fine in Acrobat but not in Reader. In Adobe Reader the fields display disproportionately large font sizes. The same corrupted output happens when printing.

Any ideas what's wrong?

Thanks in advance,
Best regards,
Giovanni

private static final Rectangle LETTER_SIZE = PageSize.A4;
private static final Comparator<String> STRING_LENGTH_COMPARATOR = new Comparator<String>() {
    public int compare(String value1, String value2) {
        return value1.length() - value2.length();
    }          
};

public static void main(String[] args) throws Exception {
    Document document = new Document(LETTER_SIZE);
    document.newPage();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("letter.pdf"));
    document.open();
   
    // ...
    appendContent(writer);
    // ...

    document.close();
}

private static void appendContent(PdfWriter writer) throws Exception {
    final float TABLE_WIDTH = 500f;
    final float TABLE_X_OFFSET = 70f;
    final float TABLE_Y_OFFSET = 450f;
    final int WIDTH_PER_CHAR = 4;
    final int WIDTH_THRESHOLD = 350;
    final float ZERO_BORDER_WIDTH = 0.f;
    final float ROW_HEIGHT = 20.f;
    final float MULTI_ROW_HEIGHT = 16.f;
               
    // field values keyed by placeholder ID that defines e.g. order
    Map<String, String> values = new HashMap<String, String>();    
    values.put("ph0013", "XXXXX XXXXX");
    values.put("ph0006", "Kontokorrent in GBP Nr. XXXX-XXXXXX-XX Salärkonto");
    values.put("ph0007", "IBAN-Nr. XXXX XXXX XXXX XXXX XXXX X");
    values.put("ph0008", "Derzeit 1.000% im Jahr abzüglich 35% Verrechnungssteuer");
    values.put("ph0009", "4835");
    values.put("ph0010", "CRESCHZZ80A");
    values.put("ph0011", "Porti und Spesen werden direkt dem Konto belastet");
    values.put("ph0012", "vierteljährlich");
    values.put("ph0005", "Ohne Ihren Gegenbericht gilt für dieses Konto die " +
        "gleiche Verfügungsberechtigung wie für alle bestehenden Konten.");
    values.put("ph0014", "Im übrigen gelten die 'Allgemeinen Geschäftsbedingungen' " +
        "unserer Bank.'");

    // field names keyed by placeholder ID that defines e.g. order
    Map<String, String> names = new HashMap<String, String>();     
    names.put("ph0013", "Kunde");
    names.put("ph0006", "Kontoart");
    names.put("ph0007", "");
    names.put("ph0008", "Zinsvergütung");
    names.put("ph0009", "Clearingnummer");
    names.put("ph0010", "Swiftadresse");
    names.put("ph0011", "Porti/ Spesen");
    names.put("ph0012", "Kontoabschluss");
    names.put("ph0005", "Verfügungsberechtigung");
    names.put("ph0014", "Übrige Bestimmungen");        

    // define row order
    List<String> rowOrder = new ArrayList<String>(names.keySet());       
    Collections.sort(rowOrder);
       
    // automatically calculate max column width       
    int leftColumnMaxLength = Collections.max(names.values(), STRING_LENGTH_COMPARATOR).length();
    int leftColumnWidth = leftColumnMaxLength * WIDTH_PER_CHAR;
    if (leftColumnWidth > WIDTH_THRESHOLD) {
        leftColumnWidth = WIDTH_THRESHOLD;
    }       
       
    int rightColumnMaxLength = Collections.max(values.values(), STRING_LENGTH_COMPARATOR).length();
    int rightColumnWidth = rightColumnMaxLength * WIDTH_PER_CHAR;
    if (rightColumnWidth > WIDTH_THRESHOLD) {
        rightColumnWidth = WIDTH_THRESHOLD;
    }

    float[] columnWidths = new float[] { leftColumnWidth, rightColumnWidth};
    PdfPTable table = new PdfPTable(columnWidths);
    int zeroRows = 0;
    table.setHeaderRows(zeroRows);
    table.setFooterRows(zeroRows);
    table.setTotalWidth(TABLE_WIDTH);
    table.setLockedWidth(true) ;
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    for (String rowKey : rowOrder) {
        String name = names.get(rowKey);
        String value = values.get(rowKey);

        int nameLength = name.length();
        int valueLength = value.length();
                       
        // calculate row span
        int rowSpan = Math.max(nameLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD,
            valueLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD) + 1;
       
        Rectangle rectangle = new Rectangle(0,0,10,10);
        rectangle.setBorder(0);
        TextField field = new TextField(writer, rectangle, value);
        field.setText(value);
        field.setFont(CREDIT_SUISSE_TYPE_LIGHT.getBaseFont());
        field.setOptions(TextField.MULTILINE | TextField.DO_NOT_SCROLL);
        field.setAlignment(Element.ALIGN_LEFT);
               
        // in case the number of rows required is only one
        if (rowSpan == 1) {                    
            PdfPCell leftColumn = new PdfPCell(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(ROW_HEIGHT);

            PdfPCell rightColumn = new PdfPCell();
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        } else {
            // use nested tables
            int oneColumn = 1;
            PdfPTable leftNested = new PdfPTable(oneColumn);
            leftNested.setHorizontalAlignment(Element.ALIGN_LEFT);
                               
            PdfPCell leftColumn = new PdfPCell(leftNested);
            leftColumn.setPhrase(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorderWidth(ZERO_BORDER_WIDTH);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);
                       
            PdfPTable rightNested = new PdfPTable(oneColumn);
            rightNested.setHorizontalAlignment(Element.ALIGN_LEFT);

            PdfPCell rightColumn = new PdfPCell(rightNested);
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        }
    }       
       
    PdfContentByte content = writer.getDirectContent();
    table.writeSelectedRows(0, -1, TABLE_X_OFFSET, TABLE_Y_OFFSET, content);       
}


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

Leonard Rosenthol-3
corrupt PDF generated

Can you post a sample PDF that demonstrates the problem?

 

From: Azùa Giovanni (KSXD 32) [mailto:[hidden email]]
Sent: Monday, March 29, 2010 8:55 AM
To: Post all your questions about iText here
Subject: [iText-questions] corrupt PDF generated

 

Hello,

I use the code below to dynamically create the form-like section of a Letter. The form is pre-populated with default data that should be editable by the user right before printing. The row span is computed automatically according to the actual default data e.g. a row may span 5 rows if the length of the content value is large.

I'm prototyping this in Windows XP with the most up to date version of Adobe 8 products. The rendering of the generated PDF looks perfectly fine in Acrobat but not in Reader. In Adobe Reader the fields display disproportionately large font sizes. The same corrupted output happens when printing.

Any ideas what's wrong?

Thanks in advance,
Best regards,
Giovanni

private static final Rectangle LETTER_SIZE = PageSize.A4;
private static final Comparator<String> STRING_LENGTH_COMPARATOR = new Comparator<String>() {
    public int compare(String value1, String value2) {
        return value1.length() - value2.length();
    }          
};

public static void main(String[] args) throws Exception {
    Document document = new Document(LETTER_SIZE);
    document.newPage();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("letter.pdf"));
    document.open();
   
    // ...
    appendContent(writer);
    // ...

    document.close();
}

private static void appendContent(PdfWriter writer) throws Exception {
    final float TABLE_WIDTH = 500f;
    final float TABLE_X_OFFSET = 70f;
    final float TABLE_Y_OFFSET = 450f;
    final int WIDTH_PER_CHAR = 4;
    final int WIDTH_THRESHOLD = 350;
    final float ZERO_BORDER_WIDTH = 0.f;
    final float ROW_HEIGHT = 20.f;
    final float MULTI_ROW_HEIGHT = 16.f;
               
    // field values keyed by placeholder ID that defines e.g. order
    Map<String, String> values = new HashMap<String, String>();    
    values.put("ph0013", "XXXXX XXXXX");
    values.put("ph0006", "Kontokorrent in GBP Nr. XXXX-XXXXXX-XX Salärkonto");
    values.put("ph0007", "IBAN-Nr. XXXX XXXX XXXX XXXX XXXX X");
    values.put("ph0008", "Derzeit 1.000% im Jahr abzüglich 35% Verrechnungssteuer");
    values.put("ph0009", "4835");
    values.put("ph0010", "CRESCHZZ80A");
    values.put("ph0011", "Porti und Spesen werden direkt dem Konto belastet");
    values.put("ph0012", "vierteljährlich");
    values.put("ph0005", "Ohne Ihren Gegenbericht gilt für dieses Konto die " +
        "gleiche Verfügungsberechtigung wie für alle bestehenden Konten.");
    values.put("ph0014", "Im übrigen gelten die 'Allgemeinen Geschäftsbedingungen' " +
        "unserer Bank.'");

    // field names keyed by placeholder ID that defines e.g. order
    Map<String, String> names = new HashMap<String, String>();     
    names.put("ph0013", "Kunde");
    names.put("ph0006", "Kontoart");
    names.put("ph0007", "");
    names.put("ph0008", "Zinsvergütung");
    names.put("ph0009", "Clearingnummer");
    names.put("ph0010", "Swiftadresse");
    names.put("ph0011", "Porti/ Spesen");
    names.put("ph0012", "Kontoabschluss");
    names.put("ph0005", "Verfügungsberechtigung");
    names.put("ph0014", "Übrige Bestimmungen");        

    // define row order
    List<String> rowOrder = new ArrayList<String>(names.keySet());       
    Collections.sort(rowOrder);
       
    // automatically calculate max column width       
    int leftColumnMaxLength = Collections.max(names.values(), STRING_LENGTH_COMPARATOR).length();
    int leftColumnWidth = leftColumnMaxLength * WIDTH_PER_CHAR;
    if (leftColumnWidth > WIDTH_THRESHOLD) {
        leftColumnWidth = WIDTH_THRESHOLD;
    }       
       
    int rightColumnMaxLength = Collections.max(values.values(), STRING_LENGTH_COMPARATOR).length();
    int rightColumnWidth = rightColumnMaxLength * WIDTH_PER_CHAR;
    if (rightColumnWidth > WIDTH_THRESHOLD) {
        rightColumnWidth = WIDTH_THRESHOLD;
    }

    float[] columnWidths = new float[] { leftColumnWidth, rightColumnWidth};
    PdfPTable table = new PdfPTable(columnWidths);
    int zeroRows = 0;
    table.setHeaderRows(zeroRows);
    table.setFooterRows(zeroRows);
    table.setTotalWidth(TABLE_WIDTH);
    table.setLockedWidth(true) ;
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    for (String rowKey : rowOrder) {
        String name = names.get(rowKey);
        String value = values.get(rowKey);

        int nameLength = name.length();
        int valueLength = value.length();
                       
        // calculate row span
        int rowSpan = Math.max(nameLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD,
            valueLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD) + 1;
       
        Rectangle rectangle = new Rectangle(0,0,10,10);
        rectangle.setBorder(0);
        TextField field = new TextField(writer, rectangle, value);
        field.setText(value);
        field.setFont(CREDIT_SUISSE_TYPE_LIGHT.getBaseFont());
        field.setOptions(TextField.MULTILINE | TextField.DO_NOT_SCROLL);
        field.setAlignment(Element.ALIGN_LEFT);
               
        // in case the number of rows required is only one
        if (rowSpan == 1) {                    
            PdfPCell leftColumn = new PdfPCell(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(ROW_HEIGHT);

            PdfPCell rightColumn = new PdfPCell();
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        } else {
            // use nested tables
            int oneColumn = 1;
            PdfPTable leftNested = new PdfPTable(oneColumn);
            leftNested.setHorizontalAlignment(Element.ALIGN_LEFT);
                               
            PdfPCell leftColumn = new PdfPCell(leftNested);
            leftColumn.setPhrase(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorderWidth(ZERO_BORDER_WIDTH);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);
                       
            PdfPTable rightNested = new PdfPTable(oneColumn);
            rightNested.setHorizontalAlignment(Element.ALIGN_LEFT);

            PdfPCell rightColumn = new PdfPCell(rightNested);
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        }
    }       
       
    PdfContentByte content = writer.getDirectContent();
    table.writeSelectedRows(0, -1, TABLE_X_OFFSET, TABLE_Y_OFFSET, content);       
}


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

bravegag2
corrupt PDF generated
Hello Leonard,
 
Please find attached the sample file.
 
Best regards,
Giovanni


From: Leonard Rosenthol [mailto:[hidden email]]
Sent: Monday, March 29, 2010 3:00 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] corrupt PDF generated

Can you post a sample PDF that demonstrates the problem?

 

From: Azùa Giovanni (KSXD 32) [mailto:[hidden email]]
Sent: Monday, March 29, 2010 8:55 AM
To: Post all your questions about iText here
Subject: [iText-questions] corrupt PDF generated

 

Hello,

I use the code below to dynamically create the form-like section of a Letter. The form is pre-populated with default data that should be editable by the user right before printing. The row span is computed automatically according to the actual default data e.g. a row may span 5 rows if the length of the content value is large.

I'm prototyping this in Windows XP with the most up to date version of Adobe 8 products. The rendering of the generated PDF looks perfectly fine in Acrobat but not in Reader. In Adobe Reader the fields display disproportionately large font sizes. The same corrupted output happens when printing.

Any ideas what's wrong?

Thanks in advance,
Best regards,
Giovanni

private static final Rectangle LETTER_SIZE = PageSize.A4;
private static final Comparator<String> STRING_LENGTH_COMPARATOR = new Comparator<String>() {
    public int compare(String value1, String value2) {
        return value1.length() - value2.length();
    }          
};

public static void main(String[] args) throws Exception {
    Document document = new Document(LETTER_SIZE);
    document.newPage();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("letter.pdf"));
    document.open();
   
    // ...
    appendContent(writer);
    // ...

    document.close();
}

private static void appendContent(PdfWriter writer) throws Exception {
    final float TABLE_WIDTH = 500f;
    final float TABLE_X_OFFSET = 70f;
    final float TABLE_Y_OFFSET = 450f;
    final int WIDTH_PER_CHAR = 4;
    final int WIDTH_THRESHOLD = 350;
    final float ZERO_BORDER_WIDTH = 0.f;
    final float ROW_HEIGHT = 20.f;
    final float MULTI_ROW_HEIGHT = 16.f;
               
    // field values keyed by placeholder ID that defines e.g. order
    Map<String, String> values = new HashMap<String, String>();    
    values.put("ph0013", "XXXXX XXXXX");
    values.put("ph0006", "Kontokorrent in GBP Nr. XXXX-XXXXXX-XX Salärkonto");
    values.put("ph0007", "IBAN-Nr. XXXX XXXX XXXX XXXX XXXX X");
    values.put("ph0008", "Derzeit 1.000% im Jahr abzüglich 35% Verrechnungssteuer");
    values.put("ph0009", "4835");
    values.put("ph0010", "CRESCHZZ80A");
    values.put("ph0011", "Porti und Spesen werden direkt dem Konto belastet");
    values.put("ph0012", "vierteljährlich");
    values.put("ph0005", "Ohne Ihren Gegenbericht gilt für dieses Konto die " +
        "gleiche Verfügungsberechtigung wie für alle bestehenden Konten.");
    values.put("ph0014", "Im übrigen gelten die 'Allgemeinen Geschäftsbedingungen' " +
        "unserer Bank.'");

    // field names keyed by placeholder ID that defines e.g. order
    Map<String, String> names = new HashMap<String, String>();     
    names.put("ph0013", "Kunde");
    names.put("ph0006", "Kontoart");
    names.put("ph0007", "");
    names.put("ph0008", "Zinsvergütung");
    names.put("ph0009", "Clearingnummer");
    names.put("ph0010", "Swiftadresse");
    names.put("ph0011", "Porti/ Spesen");
    names.put("ph0012", "Kontoabschluss");
    names.put("ph0005", "Verfügungsberechtigung");
    names.put("ph0014", "Übrige Bestimmungen");        

    // define row order
    List<String> rowOrder = new ArrayList<String>(names.keySet());       
    Collections.sort(rowOrder);
       
    // automatically calculate max column width       
    int leftColumnMaxLength = Collections.max(names.values(), STRING_LENGTH_COMPARATOR).length();
    int leftColumnWidth = leftColumnMaxLength * WIDTH_PER_CHAR;
    if (leftColumnWidth > WIDTH_THRESHOLD) {
        leftColumnWidth = WIDTH_THRESHOLD;
    }       
       
    int rightColumnMaxLength = Collections.max(values.values(), STRING_LENGTH_COMPARATOR).length();
    int rightColumnWidth = rightColumnMaxLength * WIDTH_PER_CHAR;
    if (rightColumnWidth > WIDTH_THRESHOLD) {
        rightColumnWidth = WIDTH_THRESHOLD;
    }

    float[] columnWidths = new float[] { leftColumnWidth, rightColumnWidth};
    PdfPTable table = new PdfPTable(columnWidths);
    int zeroRows = 0;
    table.setHeaderRows(zeroRows);
    table.setFooterRows(zeroRows);
    table.setTotalWidth(TABLE_WIDTH);
    table.setLockedWidth(true) ;
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    for (String rowKey : rowOrder) {
        String name = names.get(rowKey);
        String value = values.get(rowKey);

        int nameLength = name.length();
        int valueLength = value.length();
                       
        // calculate row span
        int rowSpan = Math.max(nameLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD,
            valueLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD) + 1;
       
        Rectangle rectangle = new Rectangle(0,0,10,10);
        rectangle.setBorder(0);
        TextField field = new TextField(writer, rectangle, value);
        field.setText(value);
        field.setFont(CREDIT_SUISSE_TYPE_LIGHT.getBaseFont());
        field.setOptions(TextField.MULTILINE | TextField.DO_NOT_SCROLL);
        field.setAlignment(Element.ALIGN_LEFT);
               
        // in case the number of rows required is only one
        if (rowSpan == 1) {                    
            PdfPCell leftColumn = new PdfPCell(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(ROW_HEIGHT);

            PdfPCell rightColumn = new PdfPCell();
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        } else {
            // use nested tables
            int oneColumn = 1;
            PdfPTable leftNested = new PdfPTable(oneColumn);
            leftNested.setHorizontalAlignment(Element.ALIGN_LEFT);
                               
            PdfPCell leftColumn = new PdfPCell(leftNested);
            leftColumn.setPhrase(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorderWidth(ZERO_BORDER_WIDTH);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);
                       
            PdfPTable rightNested = new PdfPTable(oneColumn);
            rightNested.setHorizontalAlignment(Element.ALIGN_LEFT);

            PdfPCell rightColumn = new PdfPCell(rightNested);
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        }
    }       
       
    PdfContentByte content = writer.getDirectContent();
    table.writeSelectedRows(0, -1, TABLE_X_OFFSET, TABLE_Y_OFFSET, content);       
}


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

letter.pdf (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

Leonard Rosenthol-3
corrupt PDF generated

The appearance for each of those fields is setting the font size to 4 point – so, of course, it is small!  I am seeing no difference in Acrobat 8 vs. Acrobat 9 or Reader. 

 

Are you regenerating the appearances yourself?  Perhaps you should – or at least mark the file as needing them.

 

Leonard

 

From: Azùa Giovanni (KSXD 32) [mailto:[hidden email]]
Sent: Monday, March 29, 2010 10:08 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] corrupt PDF generated

 

Hello Leonard,

 

Please find attached the sample file.

 

Best regards,

Giovanni

 


From: Leonard Rosenthol [mailto:[hidden email]]
Sent: Monday, March 29, 2010 3:00 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] corrupt PDF generated

Can you post a sample PDF that demonstrates the problem?

 

From: Azùa Giovanni (KSXD 32) [mailto:[hidden email]]
Sent: Monday, March 29, 2010 8:55 AM
To: Post all your questions about iText here
Subject: [iText-questions] corrupt PDF generated

 

Hello,

I use the code below to dynamically create the form-like section of a Letter. The form is pre-populated with default data that should be editable by the user right before printing. The row span is computed automatically according to the actual default data e.g. a row may span 5 rows if the length of the content value is large.

I'm prototyping this in Windows XP with the most up to date version of Adobe 8 products. The rendering of the generated PDF looks perfectly fine in Acrobat but not in Reader. In Adobe Reader the fields display disproportionately large font sizes. The same corrupted output happens when printing.

Any ideas what's wrong?

Thanks in advance,
Best regards,
Giovanni

private static final Rectangle LETTER_SIZE = PageSize.A4;
private static final Comparator<String> STRING_LENGTH_COMPARATOR = new Comparator<String>() {
    public int compare(String value1, String value2) {
        return value1.length() - value2.length();
    }          
};

public static void main(String[] args) throws Exception {
    Document document = new Document(LETTER_SIZE);
    document.newPage();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("letter.pdf"));
    document.open();
   
    // ...
    appendContent(writer);
    // ...

    document.close();
}

private static void appendContent(PdfWriter writer) throws Exception {
    final float TABLE_WIDTH = 500f;
    final float TABLE_X_OFFSET = 70f;
    final float TABLE_Y_OFFSET = 450f;
    final int WIDTH_PER_CHAR = 4;
    final int WIDTH_THRESHOLD = 350;
    final float ZERO_BORDER_WIDTH = 0.f;
    final float ROW_HEIGHT = 20.f;
    final float MULTI_ROW_HEIGHT = 16.f;
               
    // field values keyed by placeholder ID that defines e.g. order
    Map<String, String> values = new HashMap<String, String>();    
    values.put("ph0013", "XXXXX XXXXX");
    values.put("ph0006", "Kontokorrent in GBP Nr. XXXX-XXXXXX-XX Salärkonto");
    values.put("ph0007", "IBAN-Nr. XXXX XXXX XXXX XXXX XXXX X");
    values.put("ph0008", "Derzeit 1.000% im Jahr abzüglich 35% Verrechnungssteuer");
    values.put("ph0009", "4835");
    values.put("ph0010", "CRESCHZZ80A");
    values.put("ph0011", "Porti und Spesen werden direkt dem Konto belastet");
    values.put("ph0012", "vierteljährlich");
    values.put("ph0005", "Ohne Ihren Gegenbericht gilt für dieses Konto die " +
        "gleiche Verfügungsberechtigung wie für alle bestehenden Konten.");
    values.put("ph0014", "Im übrigen gelten die 'Allgemeinen Geschäftsbedingungen' " +
        "unserer Bank.'");

    // field names keyed by placeholder ID that defines e.g. order
    Map<String, String> names = new HashMap<String, String>();     
    names.put("ph0013", "Kunde");
    names.put("ph0006", "Kontoart");
    names.put("ph0007", "");
    names.put("ph0008", "Zinsvergütung");
    names.put("ph0009", "Clearingnummer");
    names.put("ph0010", "Swiftadresse");
    names.put("ph0011", "Porti/ Spesen");
    names.put("ph0012", "Kontoabschluss");
    names.put("ph0005", "Verfügungsberechtigung");
    names.put("ph0014", "Übrige Bestimmungen");        

    // define row order
    List<String> rowOrder = new ArrayList<String>(names.keySet());       
    Collections.sort(rowOrder);
       
    // automatically calculate max column width       
    int leftColumnMaxLength = Collections.max(names.values(), STRING_LENGTH_COMPARATOR).length();
    int leftColumnWidth = leftColumnMaxLength * WIDTH_PER_CHAR;
    if (leftColumnWidth > WIDTH_THRESHOLD) {
        leftColumnWidth = WIDTH_THRESHOLD;
    }       
       
    int rightColumnMaxLength = Collections.max(values.values(), STRING_LENGTH_COMPARATOR).length();
    int rightColumnWidth = rightColumnMaxLength * WIDTH_PER_CHAR;
    if (rightColumnWidth > WIDTH_THRESHOLD) {
        rightColumnWidth = WIDTH_THRESHOLD;
    }

    float[] columnWidths = new float[] { leftColumnWidth, rightColumnWidth};
    PdfPTable table = new PdfPTable(columnWidths);
    int zeroRows = 0;
    table.setHeaderRows(zeroRows);
    table.setFooterRows(zeroRows);
    table.setTotalWidth(TABLE_WIDTH);
    table.setLockedWidth(true) ;
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    for (String rowKey : rowOrder) {
        String name = names.get(rowKey);
        String value = values.get(rowKey);

        int nameLength = name.length();
        int valueLength = value.length();
                       
        // calculate row span
        int rowSpan = Math.max(nameLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD,
            valueLength * WIDTH_PER_CHAR / WIDTH_THRESHOLD) + 1;
       
        Rectangle rectangle = new Rectangle(0,0,10,10);
        rectangle.setBorder(0);
        TextField field = new TextField(writer, rectangle, value);
        field.setText(value);
        field.setFont(CREDIT_SUISSE_TYPE_LIGHT.getBaseFont());
        field.setOptions(TextField.MULTILINE | TextField.DO_NOT_SCROLL);
        field.setAlignment(Element.ALIGN_LEFT);
               
        // in case the number of rows required is only one
        if (rowSpan == 1) {                    
            PdfPCell leftColumn = new PdfPCell(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(ROW_HEIGHT);

            PdfPCell rightColumn = new PdfPCell();
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        } else {
            // use nested tables
            int oneColumn = 1;
            PdfPTable leftNested = new PdfPTable(oneColumn);
            leftNested.setHorizontalAlignment(Element.ALIGN_LEFT);
                               
            PdfPCell leftColumn = new PdfPCell(leftNested);
            leftColumn.setPhrase(new Paragraph(new Phrase(name, CREDIT_SUISSE_TYPE_LIGHT)));
            leftColumn.setVerticalAlignment(Element.ALIGN_TOP);
            leftColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            leftColumn.setBorderWidth(ZERO_BORDER_WIDTH);
            leftColumn.setBorder(PdfPCell.NO_BORDER);
            leftColumn.setPaddingBottom(8.f);
            leftColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);
                       
            PdfPTable rightNested = new PdfPTable(oneColumn);
            rightNested.setHorizontalAlignment(Element.ALIGN_LEFT);

            PdfPCell rightColumn = new PdfPCell(rightNested);
            FieldPositioningEvents events = new FieldPositioningEvents(writer, field.getTextField());
            rightColumn.setCellEvent(events);
            rightColumn.setNoWrap(false);
            rightColumn.setVerticalAlignment(Element.ALIGN_TOP);
            rightColumn.setHorizontalAlignment(Element.ALIGN_LEFT);
            rightColumn.setBorder(PdfPCell.NO_BORDER);
            rightColumn.setPaddingBottom(8.f);
            rightColumn.setFixedHeight(rowSpan * MULTI_ROW_HEIGHT);

            table.addCell(leftColumn);
            table.addCell(rightColumn);
        }
    }       
       
    PdfContentByte content = writer.getDirectContent();
    table.writeSelectedRows(0, -1, TABLE_X_OFFSET, TABLE_Y_OFFSET, content);       
}


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

bravegag2
RE: [iText-questions] corrupt PDF generated

Hello Leonard,
 
Thank you for your help!
 
Please see the screenshots attached, that's what I see here. They appear huge and not small. I set the font size to 10 and not to 4. Please see below how I load and initialize the fonts.

 
Best regards,
Giovanni

private static Font CREDIT_SUISSE_TYPE_LIGHT;
private static Font CREDIT_SUISSE_TYPE_BOLD;
private static final Rectangle LETTER_SIZE = PageSize.A4;
private static final String LINE_BREAK = "\n";
private static final int FONT_SIZE = 10;
   
static {
    FontFactoryImp factory = new FontFactoryImp();
    boolean scanSubdirectories = true;
    factory.registerDirectory("c:/OS/Fonts/", scanSubdirectories);
    CREDIT_SUISSE_TYPE_LIGHT = factory.getFont("CreditSuisseType-Light", FONT_SIZE);
    CREDIT_SUISSE_TYPE_BOLD = factory.getFont("CreditSuisseType-Bold", FONT_SIZE);
}

<<acrobat.jpg>> <<reader.jpg>>
________________________________

From: Leonard Rosenthol [[hidden email]]
Sent: Monday, March 29, 2010 5:55 PM
To: 'Post all your questions about iText here'
Subject: Re: [iText-questions] corrupt PDF generated

The appearance for each of those fields is setting the font size to 4 point – so, of course, it is small!  I am seeing no difference in Acrobat 8 vs. Acrobat 9 or Reader. 

Are you regenerating the appearances yourself?  Perhaps you should – or at least mark the file as needing them.

Leonard


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

acrobat.jpg (67K) Download Attachment
reader.jpg (60K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

bravegag2
In reply to this post by bravegag2
RE: [iText-questions] corrupt PDF generated

Hello,
 
I just wanted to acknowledge that I have found the root of this issue and fixed it. However, I would not be able to tell for sure if this effect is intended. The actual dimensions for a TextField within a PdfPTable would be dictated by two methods 1) the PdfPTable column widths 2) the dimensions assigned to the Rectangle used to construct the field

 
For the records, the undesired stretching of the TextField text was caused by the initial default initialization of the Rectangle i.e.

Rectangle rectangle = new Rectangle(0, 0, 10, 10);
rectangle.setBorder(0);
TextField field = new TextField(writer, rectangle, value);
field.setText(value);
 
Changing the rectangle dimensions to fit the space needed for that column yields the desired result i.e.
                       
// calculate the field rectangle to have the precise dimensions for each value separately
// the width is set to match that of the PdfPTable column width
Rectangle rectangle = new Rectangle(0, 0, rightColumnWidth, rowSpan * ROW_HEIGHT);
rectangle.setBorder(0);
TextField field = new TextField(writer, rectangle, value);
field.setText(value);

Best regards,
Giovanni

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================

________________________________

From: Leonard Rosenthol [[hidden email]]
Sent: Monday, March 29, 2010 3:00 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] corrupt PDF generated


Can you post a sample PDF that demonstrates the problem?

 


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

hablutzel1
In reply to this post by Leonard Rosenthol-3
How can the appearances be regenerated or the file marked as needing appearances regeneration? Can this be done without "com.itextpdf.text.pdf.AcroFields#regenerateField"? Because as far as I can see, you need a "PdfStamper" to load an "AcroFields" instance, so this would create a new PDF incremental update if I'm not wrong.

Is there anyway to get appearances regenerated for fields inmediately after something like this:

Document document = new Document();
PdfWriter pdfWriter = PdfWriter.getInstance(document, os);
document.open();
...
TextField textField = new TextField(pdfWriter , new Rectangle(0,0),
                                    "field_name");
textField .setText("Default value not shown if appearances are not regenerated");
someCell.setCellEvent(new FieldPositioningEvents(pdfWriter, text.getTextField()));

Failing to regenerate appearances for the previous snippet would not display the "Default value not shown if appearances are not regenerated", because this widget appearance is bound to "new Rectangle(0,0)" inmediately after the "text.getTextField()" call.

PS: Currently working with itext 5.0.6
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

hablutzel1
Seems than the snippet have been filtered because (Maybe because the message was sent from Nabble), sending again:

How can the appearances be regenerated or the file marked as needing appearances regeneration? Can this be done without "com.itextpdf.text.pdf.AcroFields#regenerateField"? Because as far as I can see, you need a "PdfStamper" to load an "AcroFields" instance, so this would create a new PDF incremental update if I'm not wrong. 

Is there anyway to get appearances regenerated for fields inmediately after something like this: 

Document document = new Document();
PdfWriter pdfWriter = PdfWriter.getInstance(document, os);
document.open();
...
TextField textField = new TextField(pdfWriter , new Rectangle(0,0),"field_name");
textField .setText("Default value not shown if appearances are not regenerated");
someCell.setCellEvent(new FieldPositioningEvents(pdfWriter, text.getTextField()));

Failing to regenerate appearances for the previous snippet would not display the "Default value not shown if appearances are not regenerated", because this widget appearance is bound to "new Rectangle(0,0)" inmediately after the "text.getTextField()" call. 

PS: Currently working with itext 5.0.6


On Sat, Aug 16, 2014 at 7:02 AM, hablutzel1 <[hidden email]> wrote:
How can the appearances be regenerated or the file marked as needing
appearances regeneration? Can this be done without
"com.itextpdf.text.pdf.AcroFields#regenerateField"? Because as far as I can
see, you need a "PdfStamper" to load an "AcroFields" instance, so this would
create a new PDF incremental update if I'm not wrong.

Is there anyway to get appearances regenerated for fields inmediately after
something like this:



Failing to regenerate appearances for the previous snippet would not display
the "Default value not shown if appearances are not regenerated", because
this widget appearance is bound to "new Rectangle(0,0)" inmediately after
the "text.getTextField()" call.

PS: Currently working with itext 5.0.6



--
View this message in context: http://itext-general.2136553.n4.nabble.com/corrupt-PDF-generated-tp2172523p4660247.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php



--
Jaime Hablutzel -  RPC 994690880
Tildes omitidas intencionalmente

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

info-2
On 8/16/2014 2:08 PM, Jaime Hablutzel Egoavil wrote:
> Failing to regenerate appearances for the previous snippet would not
> display the "Default value not shown if appearances are not
> regenerated", because this widget appearance is bound to "new
> Rectangle(0,0)" inmediately after the "text.getTextField()" call.

I don't understand the question.

It seems as you are generating a PDF from scratch.
This PDF contains a form field that is to be rendered in a cell.
So far, so good.

But then you talk about regenerateField() which is a method that only
makes sense when working with an existing document.
Why would you need to regenerate a field when you create a document from
scratch? That doesn't make sense.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: corrupt PDF generated

hablutzel1
It seems as you are generating a PDF from scratch.
This PDF contains a form field that is to be rendered in a cell.

Yes, it is correct, I'm generating a PDF with a text field inside a cell from scratch, but the value set for the field (by using com.itextpdf.text.pdf.BaseField#setText(java.lang.String)) isn't displayed in the PDF without appearance regeneration as I mention at the end. 

Failing to regenerate appearances for the previous snippet would not display the "Default value not shown if appearances are not regenerated", because this widget appearance is bound to "new Rectangle(0,0)" inmediately after the "text.getTextField()" call. 

This is straightforward to reproduce by modifying http://svn.code.sf.net/p/itext/code/examples/src/in_action/chapter17/FoobarLearningAgreement.java around line 218 to something like this:

TextField letter = new TextField(writer, new Rectangle(0, 0),
"letter");
letter.setText("Default value not shown if appearances are not regenerated");
// letter.setOptions(TextField.FILE_SELECTION);
PdfFormField introduction = letter.getTextField();
// introduction
// .setAdditionalActions(
// PdfName.U,
// PdfAction
// .javaScript(
// "this.getField('letter').browseForFileToSubmit();this.getField('receiving_institution').setFocus();",
// writer));
cell.setCellEvent(new FieldPositioningEvents(writer, introduction));
table.addCell(cell);
document.add(table);

It is supposed that the default value "Default value not shown if appearances are not regenerated" should be displayed in the text field after just opening the PDF isn't it? In my case it is not displayed until the text field is focused. 

PS: I'm using Acrobat XI

On Sat, Aug 16, 2014 at 8:03 AM, iText mailing list <[hidden email]> wrote:
On 8/16/2014 2:08 PM, Jaime Hablutzel Egoavil wrote:
> Failing to regenerate appearances for the previous snippet would not
> display the "Default value not shown if appearances are not
> regenerated", because this widget appearance is bound to "new
> Rectangle(0,0)" inmediately after the "text.getTextField()" call.

I don't understand the question.

It seems as you are generating a PDF from scratch.
This PDF contains a form field that is to be rendered in a cell.
So far, so good.

But then you talk about regenerateField() which is a method that only
makes sense when working with an existing document.
Why would you need to regenerate a field when you create a document from
scratch? That doesn't make sense.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php



--
Jaime Hablutzel -  RPC 994690880
Tildes omitidas intencionalmente

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Loading...