espresso3389/pdfrx

Rotate PDF page and pagePaintCallbacks

Opened this issue · 2 comments

I am using pdfrx to render a single page of a PDF at a time using layoutPages.

Is there any mechanism to allow the user to rotate the page they are viewing (with anything added to the page with pagePaintCallbacks also rotated)?

Ok so making slow progress on this one. So far Ive found a bit of a hack where we can wrap the CustomPaint inside the interactive viewer with a transformed container and it successfully renders the page rotated.

                          child: Container(
                            transformAlignment: Alignment.center,
                            transform: new Matrix4.identity()..rotateZ(90 * pi / 180),
                            child: CustomPaint(
                              foregroundPainter:
                                  _CustomPainter.fromFunction(_customPaint),
                              size: _layout!.documentSize,
                            ),
                          ),

The caveat being it seems to break some others things like globalToDocument as the local coordinates are now rotated.

I've been working on it and made some changes to lower level APIs (f24f6f4); every page method has rotationOverride parameter to override the page's default rotation.

My idea is that layoutPages should have array of rotationOverride entries corresponding to the pages. But I should consider more to keep the consitency with the existing behavior...

Anyway, it's not a small change and it takes relatively long...