On Dec 5, 9:44 pm, Boris Zbarsky <[EMAIL PROTECTED]> wrote:
> kk wrote:
> > We have a application that uses mozilla for converting HTML Pages to
> > PDF and other formats.http://gecko.dynalivery.com.
> > We do a Print Preview and get the Positions of the hyperlinks with
> > respect to the page origin. We use that information for adding
> > Bookmarks into the Output PDFs.
>
> But you don't need apresshellfor that... You can get that directly
> from the DOM using getBoundingClientRect(), no?
>
> -Boris
GetBoundingClientRect gives me offset of the link in the Browsers
content pane. What I want is the offset of the link when the Page is
paginated.
I am using the PrintPreview's PresShell to get the PrimaryFrame for
the links content and then add the offsets of all the parent frames
until I reach the "PageFrame". That gives me the offset of the link
with respect to the page it is on when paginated.
My code looked like following.
nsCOMPtr<nsIContent> anchCont(do_QueryInterface(node));
const char * type = NULL;
nsIFrame *cFrame = presShell->GetPrimaryFrameFor(anchCont);
nsPoint offset;
offset.x = offset.y = 0;
while(cFrame) {
cFrame->GetType()->GetUTF8String(&type);
//WriteLog("cFrame Type: %s",type);
if(strcmp(type, "PageFrame") == 0)
break;
offset += cFrame->GetPosition();
cFrame = cFrame->GetParent();
//WriteLog("Offsets are x: %d y: %d", offset.x, offset.y);
}
offset.x = (offset.x/20) - 25;
offset.y = (offset.y/20) - 25;
The above code worked for me upto mozilla 1.8.*
Starting mozilla 1.9 my offsets are way off in the Output PDF.
In mozilla 1.9 I changed the scale from 20 to APPUnitsPerCSSPixel
which is 60. My Offsets are still off.
I saw a mozilla wiki talking about changes for improving PrintPreview
in 1.9.(https://wiki.mozilla.org/Gecko:PrintPreview) Are those changes
done?
Is there another way of computing these offsets and converting APP
units to Device units?
-Kanth
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout