Hi, my goal is to print PDF only with pages that contains specified DOM elements, in other words I want to remove(not print) PDF pages that don't have wanted elements. Lets say wanted DOM elements are known by some html class.
I know, this may be hard to do, but I started from reading the code. I can see that the interesting files are:
cef/libcef/browser/printing/*
components/printing/renderer/print_render_frame_helper.cc (print_web_view_helper.cc in my older 2017 branch)
So I have base overview how rendering PDF(making document preview) works in CEF/Chromium.
Well, setting which pages I want to render is easy, there is std::vector<int> with page numbers to print.
But I'm still thinking how to predict/compute pdf page number for DOMElement. Printing runs in custom layout: viewport, dpi/scale.
My current idea is: evalue javascript which test elements positions beetwen blink::WebLocalFrame->printBegin() and blink::WebLocalFrame->printEnd() calls.
As I guess printBegin() should change WebKit frame document layout for printing mode, if It is possible to succesfully evaluate javascript , getBoundingClientRect() should return to me positions in printing layout, am I right?
If javascript is not possible maybe I could iterate over all elements of blink::WebLocalFrame document and call native equivalent of getBoundingClientRect() to get elements current position.
Maybe someone else have simpler idea?