I have my procedure like this:
voidDrawSomthing(page,top){
..
page.Grafics.DrawXXXX(..)
..
}
This proc meant to work same way for first page or rest of pages.
But I realize that top in all DrawXXX methods is consider differently when the page is the first one or rest of pages.
For first page, the top 0 consider start after top page margin. but for second page is consider as bottom of header.
So in my procedure above, how I suppose to know for which top I should draw?
Also, for first place why DrawXXX to first page draw on the header Area. And why have diff behaviors between first page to second?
Hi Matanya,
We have attempted to reproduce the issue that was reported to us, but unfortunately, we were unable to replicate it. We suspect that you may have drawn the page graphics before setting the header template. As a result, the header template might not be considered when determining the page size. We have shared a sample for your reference and kindly request that you modify the sample to replicate the problem on our end or provide a code example that can replicate the issue. This will enable us to analyze the problem further and provide a prompt solution.
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/189398_Sample-525655010
Regards,
Jeyalakshmi T
Thanks a lot.
I just spend time to create a concentrated code to demonstrate my problem. and I realize something very close to your comment.
To reproduce this problem not need even draw before set header. Just access to page. Graphics like bellow code. It's make me crazy.
This is very weird. The page.GetClientSize() return correct bounds even DrawXXX function write on top of the page.
Take a look:
static PdfDocument pdfExmpl7()
{
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfPageTemplateElement header = new PdfPageTemplateElement(new RectangleF(0, 0, page.GetClientSize().Width, 67));
header.Graphics.DrawRectangle(PdfBrushes.Pink, header.Bounds);
PdfGraphics graphics = page.Graphics; // This cause the problem. The getter for Graphics init the client top
page.Section.Template.Top = header;
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
page.Graphics.DrawString("This is example text", font, PdfBrushes.Black, new PointF(0, 0));
return doc;
}
Hi Matanya,
In our current implementation, when initializing the page graphics, we calculate the client size of the page (including margins, headers, and footers) and then initialize the PDF page graphics. Once the page graphics are initialized, we cannot change the coordinates of the graphics. Therefore, we request that you add the headers and footers before initializing the PDF page graphics. This is our default behavior.
Regards,
Jeyalakshmi T