Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6376921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:48:19+00:00 2026-05-25T01:48:19+00:00

I want to create dynamic PDF document pages as per my record. Please help

  • 0

I want to create dynamic PDF document pages as per my record. Please help me.

I want to print 3 records per page.

string[] collection = {
    "vivek", "kashyap", "viral", "darshit", "arpit", "sameer", "vanraj"
};

PdfDocument pdfDoc = new PdfDocument();

int records = collection.Length;
int perpage = 3;
int pages = (int)Math.Ceiling((double)records / (double)perpage);


for (int p = 0; p < pages; p++)
{          
    PdfPage pdfPage = new PdfPage();
    pdfPage.Size = PageSize.Letter;
    pdfDoc.Pages.Add(pdfPage);
    XFont NormalFont = new XFont("Helvetica", 10, XFontStyle.Regular);

    using (var pdfGfx = XGraphics.FromPdfPage(pdfPage))
    {
        for (int i = 0,next = 100; i < collection.Length; i++)
        {
            pdfGfx.DrawString( "Name : " + collection[i].ToString()
                             , NormalFont, XBrushes.Black, 55, next
                             , XStringFormats.Default);
            next += 20;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:48:20+00:00Added an answer on May 25, 2026 at 1:48 am

    I assume the code as you have presented it is showing the same top entries? What you need to do is maintain the start of each 3 entries as you move from page to page. I have called this variable idx and updated your code below (note I haven’t actually compiled it except in my head).

    string[] collection = { "vivek", "kashyap", "viral", "darshit", "arpit", "sameer", "vanraj" };
    
    PdfDocument pdfDoc = new PdfDocument();
    
    int records = collection.Length;
    int perpage = 3;
    int pages = (int)Math.Ceiling((double)records / (double)perpage);
    
    int idx = 0;
    
    for (int p = 0; p < pages; p++)
    {
    
        PdfPage pdfPage = new PdfPage();
        pdfPage.Size = PageSize.Letter;
        pdfDoc.Pages.Add(pdfPage);
        XFont NormalFont = new XFont("Helvetica", 10, XFontStyle.Regular);
        using (var pdfGfx = XGraphics.FromPdfPage(pdfPage))
        {
            for (int i = 0,next = 100; i < perpage; i++)
            {
                if ((idx + i) >= records.length) break;
                pdfGfx.DrawString("Name : " + collection[idx  + i].ToString(), NormalFont,
                    XBrushes.Black, 55, next, XStringFormats.Default);
    
                next += 20;
            }
        }
    
        idx += perpage;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Dynamic aspx Page in current solution through code-behind..forexample i
I want to create dynamic content based on this. I know it's somewhere, as
I want to create dynamic tabPages in TabControl. In each tabPage I create dataGridView
this table i want to create job_id dynamic Jobs Title text Job Description text
I want to create PayPal button with dynamic price (depending from the item) and
I want to be able to create links looking like buttons with dynamic text
I want to create dynamic java classes, I use a template to generate the
I want to create dynamic XML hieararchy but still couldn't be successful about it.I
I want to create a dynamic Accordion, My usecase is like, On every click
I want to create a dynamic object in Python and then add attributes to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.