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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:32:34+00:00 2026-06-05T10:32:34+00:00

I am talking about PdfSharp. Portrait orientation works well with margin or without margin.

  • 0

I am talking about PdfSharp. Portrait orientation works well with margin or without margin. But In case of landscape orientation, page truncate in right side once I set any margin using TrimMargins. I have tried same thing on sample code of pdfSharp and having same problem!!

Look pdf rendered well for following code

page = document.AddPage();
page.Size = PdfSharp.PageSize.A4;
page.Orientation = PageOrientation.Landscape;
gfx = XGraphics.FromPdfPage(page);
gfx.DrawString("A4 (landscape)", font,XBrushes.DarkRed, new XRect(0, 0, page.Width, page.Height),XStringFormats.Center);

But for following code pdf is not rendered well, truncate in right side

page = document.AddPage();
page.TrimMargins.Top = 5;
page.TrimMargins.Right = 5;
page.TrimMargins.Bottom = 5;
page.TrimMargins.Left = 5;
page.Size = PdfSharp.PageSize.A4;
page.Orientation = PageOrientation.Landscape;
gfx = XGraphics.FromPdfPage(page);
gfx.DrawString("A4 (landscape)", font,XBrushes.DarkRed, new XRect(0, 0, page.Width, page.Height),XStringFormats.Center);

Have any idea?
Thanks

  • 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-06-05T10:32:35+00:00Added an answer on June 5, 2026 at 10:32 am

    Yes, this is a bug of PdfSharp

    We can set the margins with orientation like bellow

    page = document.AddPage();
    //page.Size = PdfSharp.PageSize.A4;
    XSize size = PageSizeConverter.ToSize(PdfSharp.PageSize.A4);
    if(page.Orientation == PageOrientation.Landscape)
    {
       page.Width  = size.Height;
       page.Height = size.Width;
    }
    else
    {
       page.Width  = size.Width;
       page.Height = size.Height;
    }
    
    // default unit in points 1 inch = 72 points
    page.TrimMargins.Top = 5;
    page.TrimMargins.Right = 5;
    page.TrimMargins.Bottom = 5;
    page.TrimMargins.Left = 5;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Talking about javax.crypto.Cipher I was trying to encrypt data using Cipher.getInstance(RSA/None/NoPadding, BC) but I
I am talking about doing something like this: LOCK TABLE page WRITE; SELECT *
I am not talking about white space in the content, but the code itself.
I'm not talking about if user has visited the website before, but in general
Talking about Hybid Auth , I'm using Facebook to login the users, but I
I'm talking about something like GreaseMonkey but that would accept the script just as
I'm obviously not talking about a full solution, but just a good starting point
I'm not talking about tools that let one view a page in combinations of
I'm not talking about the kind you get in college, but rather implementing progress
I see many people talking about the term SUT, but do not understand why

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.