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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:24:13+00:00 2026-05-13T08:24:13+00:00

Drawing circles on PostScript is easy, and I’m surprised that PDF apparently doesn’t carry

  • 0

Drawing circles on PostScript is easy, and I’m surprised that PDF apparently doesn’t carry over those same primitives. There are plenty of commercial libraries that will do it, but shouldn’t it be simpler than that?

There are also some tricks using Bézier curves, but you don’t get a perfect circle and you have to draw them in connecting segments. I don’t need a perfect circle as long as it look close to perfect.

I’m doing this as an addition to the PDF-EasyPDF Perl module, but the language isn’t the part I need help with.

  • 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-13T08:24:14+00:00Added an answer on May 13, 2026 at 8:24 am

    That’s always going to be the case. PDF doesn’t have circles in the primitives, only beziers. The PDF imaging model was built from the PostScript imaging model, which itself only provides circles using the arc/arcto primitives, which themselves are implemented in terms of beziers.

    Oddly enough, I had call to do this exact task in some test code I’m working on that generates PDF’s. Here’s how I did it:

        private void DrawEllipse(PdfGraphics g, double xrad, double yrad)
        {
            const double magic = 0.551784;
            double xmagic = xrad * magic;
            double ymagic = yrad * magic;
            g.MoveTo(-xrad, 0);
            g.CurveTo(-xrad, ymagic, -xmagic, yrad, 0, yrad);
            g.CurveTo(xmagic, yrad, xrad, ymagic, xrad, 0);
            g.CurveTo(xrad, -ymagic, xmagic, -yrad, 0, -yrad);
            g.CurveTo(-xmagic, -yrad, -xrad, -ymagic, -xrad, 0);
        }
    
        private void DrawCircle(PdfGraphics g, double radius)
        {
            DrawEllipse(g, radius, radius);
        }
    

    Assume that PdfGraphics is a class that spews out PDF commands, so g.MoveTo(x, y) will turn into “x y m” in the content stream. I took my math and my magic number from Don Lancaster’s fabulous explanation (PDF, naturally). This assumes that the circle or ellipse will be drawn at the origin. To move it somewhere else, do a translation transform first or modify the code to subtract add in the desired origin. This code gives a worst case error of roughly 1/1250 (about .08 %) and average of 1/2500 (about .04%).

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

Sidebar

Related Questions

What's a good algorithm for drawing anti-aliased circles? (Filled and not filled.)
System.Drawing.Color objects apparently won't serialize with XmlSerializer. What is the best way to xml
I'm doing custom drawing in datagridview cells and I have items that can vertically
I have a problem drawing something quickly in .NET. I don't think that any
I'm using System.Drawing.Color, is there anything in Visual Studio that can display the color
Drawing a parallelgram is nicely supported with Graphics.DrawImage: Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height);
Windows Forms: For System.Drawing there is a way to get the font height. Font
I'm working on drawing an SVG grid using Javascript. I've managed to get the
Is there a System.Drawing.Image.FromHbitmap equivalent in WPF? Also, is it possible to dispose the
I know the following libraries for drawing charts in an SWT/Eclipse RCP application: Eclipse

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.