PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

MediaBox Way Off!
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1105
Page 1 of 1

Author:  chuckwagon [ Mon Mar 22, 2010 5:17 pm ]
Post subject:  MediaBox Way Off!

I've got a pdf (Not created by PDFsharp), whose page size is 8.5 by 11 (612 by 792) but the actual size of the page with hidden content is 612 by 11796. The MediaBox and CropBox is located at 11004, therefore the content between 11004 and 11796 is the actual viewable portion of my pdf page. My problem is when I try gfx.DrawString at (gfx.PageSize.Height - 250) it puts it in the unviewable portion, of course, since 792 - 250 = 542.
I know I could just determine the position of the MediaBox and offset the place where I DrawString but my problem lies deeper than just this.

A quick fix to my problem if it's possible is to move the content of the MediaBox to the top of the page so that everything starts at (0,0). Is this possible?

For those more interested in my deeper problem for curiousity:
In different code in my program, I use the Adobe Interop to get the JSObject to determine the mouse position on the page. At that location is where I do a DrawString. The mouse.y coordinate reports the 11004-11796 location but every pageBox in the JSObject reports the size as 612 by 792, even the MediaBox and CropBox.

Author:  chuckwagon [ Fri Mar 26, 2010 12:14 pm ]
Post subject:  Re: MediaBox Way Off!

Nevermind.

I found that instead of adding the Location.Y of the MediaBox I subtract Location.Y of the MediaBox. This draws the string at -10462. This doesn't make much sense to me, but it works.

For the deeper problem:
I find out the offset of the MediaBox for each page prior to calling the JSObject. I then add the offset to the mouse.y value to determine if the mouse location is within the page.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/