textbrowser / dooble

Dooble is a scientific browser. Minimal, cute, unusually stable, and available almost everyware. Completed?
https://textbrowser.github.io/dooble/
Other
472 stars 38 forks source link

Save page to png functionality #106

Closed Ygarr closed 2 years ago

Ygarr commented 2 years ago

..Or to jpg

textbrowser commented 2 years ago

Sure. :)

textbrowser commented 2 years ago

How about printing it to a PDF? PDFs are everywhere.

Ygarr commented 2 years ago

I thought about it. But some nuances are obtained. (I just made a PDF of some site page and look at that with my experience)

With the work of the PDF, some specific tools are needed, which can suffer operations.

That texts are also not highlighted in the resulting PDF file. That is, you work with PDF, but you do not get it advantage. Data still looks like picture(Sometimes)

It does not always make sense in division on the pages of such a PDF-like picture. (Some pages can be partially empty or even broken)

If, for example, a lot of infographics/cheetsheets in your graphic form, then when turning, the image viewer sees only the first page from PDF. Android devices shots also in image format not in PDF so collecting collection of images

Also in PDF, the picture may turn out to be blurred.

Less frequently, the need to convert a picture in PDF than the opposite. And PDF viewers rarely have simply saving into the picture.

Saving in the picture solves redundant third-part software.

Thereis while sorting data - only first page on previews so cannot evaluate size. With picture — just resizing icon. And so on.

Sharing the web. Just test on some platform(gofile) It has no preview for PDF. And social networks.......

textbrowser commented 2 years ago

New feature will be "Export to PNG...", OK?

Ygarr commented 2 years ago

1.Briefly - yes. This option is pretty good too.

2.This problem may probably have a double bottom. For first phase enough such functionality as here https://sourceforge.net/p/cutycapt/code/HEAD/tree/CutyCapt/, https://github.com/hoehrmann/CutyCapt But some sites like fb.com have auto-loading pages.(Therefore, it is possible to deal with manually selected area for shot, and area goes beyond displayed by the browser — need to scroll while selecting)

textbrowser commented 2 years ago

I have not seen a program to capture the entire area of a device. I think I understand. Suppose you have a super long page which can't be seen unless you have a super monitor or you scroll. You'd like to capture the entire page and record it to a PNG, yes? It may be possible as long as the view's contents are not discarded once they leave the viewable area. For example, Android has a mechanism which releases resources once those resources are impossible to be seen on the device (including orientation); it's a little bonkers. There are times when it prematurely releases resources, however, it will locate those discarded resources if it needs them. Imagine having a list of images and you're at the very bottom or very top of the view area and you gently scroll. Android will detect these small increments and determine if those images are viewable. If not, recycled.

textbrowser commented 2 years ago

Here is a PNG for a sample chart. The export captures the chart as well as its current properties.

test

textbrowser commented 2 years ago

An exported chart will only include the graph. :)

textbrowser commented 2 years ago

QWebEngineView does not offer a scrolling option.

textbrowser commented 2 years ago

test.zip

Sample of https://en.wikipedia.org/wiki/Collatz_conjecture.

And one of https://en.wikipedia.org/wiki/3x_%2B_1_semigroup.

test

textbrowser commented 2 years ago

test

textbrowser commented 2 years ago

And here's an image of this page before this comment.

test.zip

textbrowser commented 2 years ago

Unfortunately Dooble has to scroll, render an image, and finally assemble the individual images into a single image. I do not have access into the entire page's contents. I'll look some more.

textbrowser commented 2 years ago

Another solution: create a separate WebView object and resize it to the size of the original page's contents size. Then load the current URL for this artificial WebView. After loading completes, render the WebView into an image. It works, but not for some pages. :(

QOpenGLFramebufferObject: Framebuffer incomplete attachment. QOpenGLFramebufferObject: Framebuffer incomplete attachment. QOpenGLFramebufferObject: Framebuffer incomplete attachment. QOpenGLFramebufferObject: Framebuffer incomplete attachment. QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.

textbrowser commented 2 years ago

In Qt 6.2, QOpenGLFramebufferObject terminates Dooble. Alright, I think the scrolling solution is best. Let me see if I can disable JS before the scrolling is initiated and then reenable it.

textbrowser commented 2 years ago

1.Briefly - yes. This option is pretty good too.

2.This problem may probably have a double bottom. For first phase enough such functionality as here https://sourceforge.net/p/cutycapt/code/HEAD/tree/CutyCapt/, https://github.com/hoehrmann/CutyCapt But some sites like fb.com have auto-loading pages.(Therefore, it is possible to deal with manually selected area for shot, and area goes beyond displayed by the browser — need to scroll while selecting)

The Cuty program is for WebKit.

textbrowser commented 2 years ago

I have not seen a program to capture the entire area of a device. I think I understand. Suppose you have a super long page which can't be seen unless you have a super monitor or you scroll. You'd like to capture the entire page and record it to a PNG, yes? It may be possible as long as the view's contents are not discarded once they leave the viewable area. For example, Android has a mechanism which releases resources once those resources are impossible to be seen on the device (including orientation); it's a little bonkers. There are times when it prematurely releases resources, however, it will locate those discarded resources if it needs them. Imagine having a list of images and you're at the very bottom or very top of the view area and you gently scroll. Android will detect these small increments and determine if those images are viewable. If not, recycled.

I just have. Firefox allows you to capture an entire page or an area of the page.

textbrowser commented 2 years ago

Initial draft completed.

https://github.com/textbrowser/dooble/commit/cfb04c79639fe817e78d1e3fec0d534febdbd655

I know it will not work for large pages because QPixmap (and QImage) limitations. Scroll-to-top has to be added as well as a progress dialog. Or something to inform the person that the automatic scrolling is because Dooble is rendering images of the page's sections.

textbrowser commented 2 years ago

https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp?h=dev

Line 492.

if (uint(w) >= 32768 || uint(h) >= 32768) { w = h = 0; is_null = true; return; }

Ygarr commented 2 years ago

...If page is too big

textbrowser commented 2 years ago

Yes. And I don't want to create multiple PNG files. A single collage.

textbrowser commented 2 years ago

Completed!

https://user-images.githubusercontent.com/10701156/146813644-d3654930-9cd4-4860-9fa1-5c2f9410cd2a.mp4

textbrowser commented 2 years ago

I tested it on an old Mac and it works there as well. Windows remains.