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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:33:17+00:00 2026-05-27T22:33:17+00:00

I am trying to generate pdf using Dompdf. I have the following script for

  • 0

I am trying to generate pdf using Dompdf. I have the following script for the design of my generated pdf.

<html>
<head>
<style>
@page { margin: 180px 50px; }
#header { position: fixed; left: 0px; top: -180px; right: 0px; height: 120px; background-color:  orange; text-align: center; }
#footer { position: fixed; left: 0px; bottom: -180px; right: 0px; height: 150px; background-color: lightblue; }
#footer .page:after { content: counter(page, upper-roman); }
</style>

<body>
      <div id=\"header\">

     <h1>Charlie Sheen</h1>
     </div>

      Hi, This is Charlie Sheen <br>

    <p> Winning </p>
   <p> Winning </p>
  <p> Winning </p>
   <p> Winning </p>
    <p> Winning </p>
     <p> Winning </p>
      <p> Winning </p>

   <div id=\"footer\">
 <p class=\"page\">Page </p>
 </div>
 <div id=\"content\">
 <p>the first page</p>
 <p style=\"page-break-before: always;\">the second page</p>
 </div>                  

 </body>
</html>

enter image description here

When I generate the PDF it looks like the image above. Now my problem is I want my content to start from a little upper than it starts from now. If you notice the image above there is a sentence “Hi, this is charlie Sheen”… I want this to start from a little upper. I have tried to add the following code inside the style but it doesn’t work:

#content { position: fixed; margin-top: 0px;}

Would you please kindly help me to get the content start from a little upper?

Thanks in Advance 🙂

  • 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-27T22:33:18+00:00Added an answer on May 27, 2026 at 10:33 pm

    You’re pushing the body in 180px from the top and bottom of the document with @page { margin: 180px 50px; }. However, the height of your header is only 120px. So there will naturally be 60px of space between your header and body content. You should either increase the size of your header or decrease the @page margins.

    <html>
    <head>
        <style>
            @page { margin: 120px 50px; }
            #header { position: fixed; left: 0px; top: -120px; right: 0px; height: 120px; background-color:  orange; text-align: center; }
            #footer { position: fixed; left: 0px; bottom: -120px; right: 0px; height: 150px; background-color: lightblue; }
            #footer .page:after { content: counter(page, upper-roman); }
        </style>
    
    <body>
        <div id="header">
            <h1>Charlie Sheen</h1>
        </div>
    
        <div id="footer">
            <p class="page">Page </p>
        </div>
    
        <div id="content">
            <p>Winning!</p>
            <p style="page-break-before: always;">Winning!</p>
        </div>
    </body>
    </html>
    

    (Your original code, cleaned up a bit.)

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

Sidebar

Related Questions

I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML
I'm trying to have table borders in my PDF using pisa to generate the
I'm trying to generate a PDF file using AJAX call in Rails3. The following
I am trying to generate pdf using automated bash shell script, that script after
I am trying to generate a PDF using HTML template. i am having trouble
I have small web app that generate PDF files as a report. I'm trying
I am using Websupergoo's ABCpdf for ASP.NET and I am trying to generate PDF's
G'day guys, trying to build a small invoicing system (that can generate PDF's using
We're trying to create a .NET aspx page that will have a PDF within
I am trying to generate a PDF using iTextSharp. It will consists of a

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.