Hi,
I think the Document.DefaultPageSetup is not implemented properly for running it on a
concurrent application where more than one reports needs to be generated at the same time.
In this scenario if you have a report that takes say 2 minutes and in that period you run a seconde report with a different PageSetup, since currently you are changing the global page setup, it will make the change the page setup of the first report. We had this problem when we are using Landscape and Portrait orientation.
I think to fix it you have to make the DefaultPageSetup a private member and a copy of the
so in PageSetup i created a new method basically to create a new PageSetup object with the default settings:
Code:
public static PageSetup NewDefaultPageSetup()
{
PageSetup p = new PageSetup();
p.PageFormat = PageFormat.A4;
p.SectionStart = BreakType.BreakNextPage;
p.Orientation = Orientation.Portrait;
p.PageWidth = "21cm";
p.PageHeight = "29.7cm";
p.TopMargin = "2.5cm";
p.BottomMargin = "2cm";
p.LeftMargin = "2.5cm";
p.RightMargin = "2.5cm";
p.HeaderDistance = "1.25cm";
p.FooterDistance = "1.25cm";
p.OddAndEvenPagesHeaderFooter = false;
p.DifferentFirstPageHeaderFooter = false;
p.MirrorMargins = false;
p.HorizontalPageBreak = false;
return p;
}
Then in document i setup the default page setup with this method:
Code:
private PageSetup defaultPageSetup = PageSetup.NewDefaultPageSetup();
So now every document has its own private page setup
Also in VisitorBase code:
Code:
internal override void VisitSection(Section section)
{
Section prevSec = section.PreviousSection();
// Here the document defaultpagesetup is more relevant than the global PageSetup
PageSetup prevPageSetup = section.Document.DefaultPageSetup;
if (prevSec != null)
{
prevPageSetup = prevSec.pageSetup; ...
I am sure you can do better, it was just changes i made to make this work.
Thanks for the excellent library,
Sofoklis