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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:21:51+00:00 2026-05-24T03:21:51+00:00

Many people who generate PDFs need to bind them. A good binding requires that

  • 0

Many people who generate PDFs need to bind them. A good binding requires that every other page support an alternate margin size on its left and right sides. I know JasperReports did not support this in its 3.x series. Is this supported in the 4.x series?

  • 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-24T03:21:51+00:00Added an answer on May 24, 2026 at 3:21 am

    You can accomplish marginMirroring as mentioned by Dave, by subclassing JRPdfExporter, overriding the method, exportReportToStream. Unfortunately, you will need to copy the source for this method into your override. In your override, you will modify the page loop, like so:

    for(int pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++)
    {
        int margin = marginLeft;
        if (pageIndex % 2 == 1) margin = marginRight;
    
        parameters.put(JRExporterParameter.OFFSET_X, margin);
        setOffset();
        ...
    

    The constructor for my subclass takes in the margins:

    public MirroringJRPdfExporter(int left, int right, int top, int bottom) {
        this.marginLeft = left;
        this.marginRight = right;
        this.marginTop = top;
        this.marginBottom = bottom;
    }    
    

    I took in top and bottom too, just in case I needed to mirror that for page flipping.

    Another unfortunate note, exportReportToStream uses a helper, JRPdfExporterTagHelper, and calls 2 methods, init and setPdfWriter, which are protected, so your subclass will not compile unless you subclass the helper too and expose those methods to your subclass. I did this:

    public class JRPdfExporterTagHelper extends
            net.sf.jasperreports.engine.export.JRPdfExporterTagHelper {
    
        protected JRPdfExporterTagHelper(JRPdfExporter exporter) {
            super(exporter);
        }
    
        public void setPdfWriter2(PdfWriter pdfWriter) {
            setPdfWriter(pdfWriter);
        }
    
        public void init2(PdfContentByte pdfContentByte) {
            init(pdfContentByte);
        }
    } 
    

    Then, I call it like this:

    MirroringJRPdfExporter exporter = new MirroringJRPdfExporter(72, 36, 44, 31);
    
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, output);
    exporter.exportReport();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know many people who use computers every day, who do not know how
Many people ask me why, and I don`t have a good answer for them.
I think there are not many people who don't think that ASP.NET MVC is
Edit Since there were many downvotes and people who didn't understand what I'm asking
There are many how-to's for people who want to use Rails with Apache and
Many people string together find and sed, or perl, or any number of other
Many people are saying that Apple has restricted it for better performance. If so
Many people have argued about function size. They say that functions in general should
Almost everywhere I worked I met lots of people who didn't care that they
I have a collection(people) that has a many-to-many reference to another collection(dogs). Suspend your

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.