Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Mar 20, 2020 11:24 am

Here is my code

PdfDocument pdfdoc = new PdfDocument();
PdfNewPage pdfNewpage = new PdfNewPage();
PdfMargins margin = new PdfMargins();
margin.Top = 0;
margin.Left = 80;
margin.Right = 80;
margin.Bottom = 20;
pdfdoc.PageSettings.Margins = margin;
PdfPageBase page = pdfdoc.Pages.Add(PdfPageSize.A4);
float yaxis = 5;

PdfGrid grid = new PdfGrid();
grid.Columns.Add(1);

I just want to add this text in to grid
"If you have questions regarding your account or would like to be contacted by a representative,please call BENCOR Administrative Services www.google.com"

and also i just want to add pdf list in to grid cell

please help me.

ushanandhini_1297
 
Posts: 15
Joined: Mon Apr 20, 2015 11:34 am

Mon Mar 23, 2020 3:32 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
Please refer to the following code. If this is not what you want, please share your desired output for our reference, then we will do further investigation. Thanks in advance.
Code: Select all
            PdfDocument pdfdoc = new PdfDocument();
            //Add the first page
            PdfNewPage newPage = pdfdoc.Pages.Add() as PdfNewPage;
            PdfMargins margin = new PdfMargins();
            margin.Top = 0;
            margin.Left = 80;
            margin.Right = 80;
            margin.Bottom = 20;
            pdfdoc.PageSettings.Margins = margin;
            //...

            //Add the second page
            PdfPageBase page = pdfdoc.Pages.Add(PdfPageSize.A4);
            //Add grid
            PdfGrid grid = new PdfGrid();
            grid.Columns.Add(1);
            PdfGridRow row1 = grid.Rows.Add();
            //Add text to grid
            row1.Cells[0].Value = "If you have questions regarding your account or would like to be contacted by a representative,please call BENCOR Administrative Services www.google.com";
            grid.Draw(page, new PointF(0, 20));
            //Save
            pdfdoc.SaveToFile("result.pdf",FileFormat.PDF);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Mar 23, 2020 10:29 am

Hi

I am having more number of form fields with big content. In first page the text and form fields are displaying properly. But the remaining form fields are not continuing to the second page automatically. and How to set dynamic position xaxis and yaxis for the form fields?

ushanandhini_1297
 
Posts: 15
Joined: Mon Apr 20, 2015 11:34 am

Tue Mar 24, 2020 9:45 am

Hello,

Thanks for your feedback.
You mean you want to add text and form field to grid, then the output document will be automatically paginated based on the content of the grid? Sorry at present our Spire.PDF doesn't support placing the form fields inside the grid cell. But as for adding text to grid, you could refer to the following code to set up automatic pagination.
Code: Select all
            PdfDocument pdfdoc = new PdfDocument();
            PdfPageBase page = pdfdoc.Pages.Add(PdfPageSize.A4);
            PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
            format.Layout = PdfLayoutType.Paginate;
            format.Break = PdfLayoutBreakType.FitElement;

            //Add grid
            PdfGrid grid = new PdfGrid();
            grid.Columns.Add(1);
            for (int i = 0; i < 40; i++)
            {           
                PdfGridRow row = grid.Rows.Add();
                row.Cells[0].Value = "If you have questions regarding your account or would like to be contacted by a representative,please call BENCOR Administrative Services www.google.com";
            }       
            grid.Draw(page, new PointF(0, 20), format);
            //Save
            pdfdoc.SaveToFile("result.pdf", FileFormat.PDF);

Besides, I'm a little confused about "How to set dynamic position xaxis and yaxis for the form fields" you mentioned. Could you please provide more details about your requirement to help us further investigate it? Such as the complete code you are using and your desired output. You could send them to us(support@e-iceblue.com) via email. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
Last edited by rachel.lei on Wed Mar 25, 2020 3:30 am, edited 1 time in total.
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Mar 24, 2020 10:49 am

Hi

I have placed form fields in grid cell but it is not paginating to the next page. here is my code. Please help me on this.

if the gridrow reaches end of the page, fields are not automatically displaying in the next page. I can see only the content.
how to set the width and height dynamically?
if the page height is 700, if i am giving height as 800 then it is not displaying


PdfDocument pdfdoc = new PdfDocument();
PdfPageBase page = pdfdoc.Pages.Add(PdfPageSize.A4);
PdfTextBoxField textField = new PdfTextBoxField(page, "txt1");
textField.Bounds = new Rectangle(100,900, 300, 15);
textField.BorderStyle = PdfBorderStyle.Underline;
textField.BorderWidth = 0.25f;
form.Fields.Add(textField);
row.Cells[i].Value = textField;

ushanandhini_1297
 
Posts: 15
Joined: Mon Apr 20, 2015 11:34 am

Wed Mar 25, 2020 7:59 am

Hello,

Thanks for your response.
As I mentioned earlier, our Spire.PDF doesn't support placing the form fields inside the grid cell. The code "PdfTextBoxField textField = new PdfTextBoxField(page, "txt1");" you used is actually drawing the field directly on the PDF page, this field is part of the current page content , but not the content in the grid cell. So the page layout of grid wouldn't take effect on this field.

That is to say, if the Y coordinate of the field exceeds the height of the current page, the field will be drawn outside the visible area of the current page, hence the page doesn’t display it. Hope you can understand.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF