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 6365919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:21:18+00:00 2026-05-25T00:21:18+00:00

Can I add paragraphs with SharpPDF, without having to specify the exact coordinates? Can’t

  • 0

Can I add paragraphs with SharpPDF, without having to specify the exact coordinates? Can’t I just place paragraphs one under the other?

Please tell me if you used the library.

  • 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-25T00:21:19+00:00Added an answer on May 25, 2026 at 12:21 am

    It is not possible to just add paragraphs one after another without specifying coordinates, however I did write this sample which will move the paragraphs down the page and create a new page when necessary. In this want you could write out text, paragraphs, drawing, and always know the position of the “cursor.”

    const int WIDTH = 500;
    const int HEIGHT = 792;
    
    pdfDocument myDoc;
    pdfPage currentPage;
    
    private void button1_Click(object sender, EventArgs e)
    {
        int height = 0;
    
        myDoc = new pdfDocument("TUTORIAL", "ME");
        currentPage = myDoc.addPage(HEIGHT, WIDTH);
    
        string paragraph1 = "All the goats live in the land of the trees and the bushes, " 
            + " when a person lives in the land of the trees and the bushes they wonder about the sanity" 
            + " of it all. Whatever.";
    
        string paragraph2 =  "Redwood National and State Parks is located in northernmost coastal "
            + "California — about 325 miles north of San Francisco, Calif. Roughly 50 miles long, the parklands"
            + "stretch from near the Oregon border in the north to the Redwood Creek watershed southeast of"
            + "Orick, Calif. Five information centers are located along this north-south corrdior. Park "
            + "Headquarters is located in Crescent City, Calif. (95531) at 1111 Second Street.";
    
        int iYpos = HEIGHT;
    
        for (int ix = 0; ix < 10; ix++)
        {
            height = GetStringHeight(paragraph1, new Font("Helvetica", 12), WIDTH);
            iYpos = CheckHeight(height, iYpos);
            currentPage.addParagraph(paragraph1, 0, iYpos, sharpPDF.Enumerators.predefinedFont.csHelvetica, 12, WIDTH);
            iYpos -= height;
    
            height = GetStringHeight(paragraph2, new Font("Helvetica", 12), WIDTH);
            iYpos = CheckHeight(height, iYpos);
            currentPage.addParagraph(paragraph2, 0, iYpos, sharpPDF.Enumerators.predefinedFont.csHelvetica, 12, WIDTH);
            iYpos -= height;
        }
    
        string tmp = Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".pdf";
        myDoc.createPDF(tmp);
    }
    
    private int GetStringHeight(string text, Font font, int width)
    {
        Bitmap b = new Bitmap(WIDTH, HEIGHT);
        Graphics g = Graphics.FromImage((Image)b);
        SizeF size = g.MeasureString(text, font, (int)Math.Ceiling((float)width / 72F * g.DpiX));
        return (int)Math.Ceiling(size.Height)
    }
    
    private int CheckHeight(int height, int iYpos)
    {
        if (height > iYpos)
        {
            currentPage = myDoc.addPage(HEIGHT, WIDTH);
            iYpos = HEIGHT;
        }
        return iYpos;
    }
    

    The Y is backwards in this API, so 792 is the TOP and 0 is the BOTTOM. I use a Graphics object to measure the height of the string, since the Graphics is in pixels and the Pdf is in points I do an estimation to make them similar. I then subtract the height from my remaining Y value.

    In this example I keep adding paragraph1 and paragraph2 over and over, updating my Y position as I go along. When I get to the bottom of the page I create a new page and reset my Y position.

    This project hasn’t seen any updates for a number of years, but the source code is available, using something similar to what I’ve done you could make your own function that allows you to successively add paragraphs which will keep track of a CURSOR position of where it thinks something should go next.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wordpress has a filter that automatically add paragraphs to posts. I can remove this
Ruby can add methods to the Number class and other core types to get
I know one can add event listener for window.error. However when working with Iframes,
I can add and remove the last line in my dynamic form and calculate
I know I can add a icon to the Resources.resx file of a project
I know that I can add a HintPath to an external DLLs to help
Users on my site can add nodes of a custom type (let's call it
How i can add the multiple values from a datagrid to textbox in C#?
In my application user can add there reminder for the specific day and reminder
Can someone tell me of a way in which I can add a user

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.