Closed Cersin closed 1 month ago
There are two ways to do that:
The second one is not needed if you can do your jobs using widgets only. But if you want to place many widgets on a page, it may degrade the page rendering speed and you may want to switch to the second one.
For the first one, there's no solid sample now but its parent is Stack and you can place Align or Positioned to place child widgets.
There's a sample for the second one that shows marker highlight. You should firstly check the pdfrx's example code.
There are two ways to do that:
- PdfViewerParams.pageOverlaysBuilder is to add several widgets on each page. You may need to place GestureDetector or such on each page.
- PdfViewerParams.pagePaintCallbacks is to draw on each page's canvas.
The second one is not needed if you can do your jobs using widgets only. But if you want to place many widgets on a page, it may degrade the page rendering speed and you may want to switch to the second one.
but how do i place a rectangle and get good coordinates from pdf to draw on it? i will appreciate any help, you are good guy :)
@espresso3389 oooh i got it, thanks!
@espresso3389 can you give me a hint how to get good pdf coordinates from overlay widget and draw it into pdf?
@Cersin
Here's what I have. The pageOverlaysBuilder
has a page
parameter with a width
and height
measured in physical points
(1/72 of an inch). It also has a pageRect
which represents the page's bounds relative to the PdfViewer
in logical pixels. This is all we need to convert between points and pixels.
To convert a pixel to a point horizontally, you could use:
final pixelToPointX = page.width / pageRect.width;
final myPixel = 200.0; // From a gesture detector perhaps
final myPoint = myPixel * pixelToPointX;
Vertical is the same process. To convert a point to a pixel just divide by pixelToPoint
.
Hi, its drawing on pdf file possible? I need something like selecting text to make a bookmark but I need to select an area, maybe some rectangle to mark some area of the pdf.
Maybe there is a way to achieve that?