I have read "media box is always [0, 0, page width, page height]
"
but my PDF page's MediaBox is [0 383 599 1224]
.
So when I draw line like "gfx.drawLine(XPens.gold, 0,0, 100, 50);
",
it is rendered in the middle of the page.
When I draw line like "gfx.drawLine(XPens.gold, 0, -200, 100, 50);
", it's rendered at the top of the page.
I want to draw a line at the same position on all PDF pages.
If I use the following code, is it the right way?
gfx.drawline(Xpens.gold, (X - pdfpage.mediabox.x1),
(Y - pdfpage.mediabox.y1 ), width, height);
And can I get some reference of "PDF page sizes and mediabox"?
Additional Question
1) The exact action i want to do is to open the PDF (created other library) and add the rectangle to the specific position.
how can i get specific position in pages ?
2) about "The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or printed"
As far as i understand, i can not see outside the crop box region. when i opened the file using PDF reader
but when i open file using PDF reader(acrobat), the first page has a full sized image like this:
Image looks like it was drawn outside the crop box region, is it possible?
I learned something new about my problem and i think my problem goes through the process below
When i open PDF file with PDFSharp and get graphic context, it converts the coordinates system.
When i draw something PDF element at (0,0), it is drawn at the (0,0) point of the crop box area ( In following picture, element is green rectangle)
IF the area of the corp box is [0, 300, 600, 1200], elementis drawn at the (0,300) point of the page area. Because the crop box's (0.0) is equal to the pages'(0,300)
So when i save page, the new element will be 300 points below the top of the original page
Did i get it right?
If it is right, can i convert the coordinates of the four corners of the crop box to match the page coordinates
For example. if i want to drawn rectangle at the top of the page, draw it at (0, -300) instead of (0,0)