This is what I want:
List<SomeObject>
someObjects.Count == 2
someObjects.Count == 0
The code i'm using:
byte[] bytes = GetFileBytes(filePath);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(bytes);
PdfLoadedForm form = loadedDocument.Form;
PdfGrid grid = new PdfGrid();
List<SomeObject>
grid.DataSource = someObjects;
I have tried doing this but nothing is displayed.
PdfGridRow newRow = grid.Rows.Add();
I
have also tried setting the value of each cell in the row to a blank
string and setting the height, but the row is still not visible
newRow.Cells[0].Value = "";
newRow.Cells[1].Value = "";
newRow.Cells[2].Value = "";
newRow.Height = 20;
Hi MedDev,
Thank you for contacting Syncfusion support.
We have checked your query and created the sample to draw PdfGrid table with blank rows. We have attached the sample and output document for your reference. Please try the below sample on your end and let us know the result.
Sample: https://www.syncfusion.com/downloads/support/forum/168992/ze/PdfGridRowHeight909486515
Output: https://www.syncfusion.com/downloads/support/forum/168992/pd/Output89368692
Output document snapshot:
|
|
Please refer the below links for more information,
UG: https://help.syncfusion.com/file-formats/pdf/working-with-tables
Please let us know if you need any further assistance with this.
Regards,
Surya V
Thank you for your reply Surya V,
I discovered the issue I was having was actually in some code that I neglected to share.
I was reading in an existing pdf which has a form field, and using the graphics and bounds of that form field to draw the PdfGrid. Like so:
PdfLoadedTextBoxField formField = loadedDocument.Form.Fields["form_field_name"] as PdfLoadedTextBoxField;
grid.Draw(formField.Page.Graphics, formField.Bounds);
I changed the grid.Draw to this and it shows the empty rows that were not previously visible:
grid.Draw(formField.Page.Graphics, formField.Location.X, formField.Location.Y, formField.Size.Width);
I believe PdfGrid was eliminating the blank rows to save space because the formField.Size.Height value was so low. Is there a setting which can prevent that behavior?
Hi MedDev,
Thank you for the update.
On further analysis, we suspect that PdfGrid row visibility issue due to form field graphics. We could not able to draw the PdfGrid using form field graphics because form field have many chance to hide the PdfGrid structure. To avoid the visibility issue please use the valid graphics and bounds to draw PdfGrid. We request you to share the more details for using form field graphics to draw PdfGrid. So, that it will be helpful for us to analyze and assist you further on this.
Note: By default PdfGrid row height was calculated by their cell values. If we not set the row height and its cell values, it could be merge with previous row and output become invisible.
Regards,
Surya V
Surya V,
The form field is just being used as a placeholder for the location of the table. Here is an example of what I am doing:
Hi MedDev,
Thank you for the update.
We checked the provided sample on our end. PdfGrid row not properly visible if we use the given formfield bound. Because if we apply bounds(Its may form field bounds or other bounds) value to draw PdfGrid methd, It could draw PdfGrid within the bounds. To overcome this issue please use the sufficient bounds value for the PdfGrid.
For example, The provided sample contains form field bounds value is given below,
|
textBoxField.Bounds = new Syncfusion.Drawing.RectangleF(10, 10, 500, 20); grid.Draw(formField.Page.Graphics, formField.Bounds); |
If we draw with that bounds value, the output of PdfGrid structure was visible within the specific height(=20) value of that bounds. So we recommend to apply the form fields bounds value like below to avoid PdfGrid structure visibility issue,
|
grid.Draw(formField.Page.Graphics, formField.Location.X, formField.Location.Y, formField.Size.Width); |
Please let us know if you need any further assistance with this.
Regards,
Surya V