E
E
Evgeny Glebov2020-05-21 18:19:52
JavaScript
Evgeny Glebov, 2020-05-21 18:19:52

How to generate documentation from large html document?

There is a service for creating block diagrams:
- server (asp.net) stores and returns information about containers with blocks;
- the client (browser: html, js, svg) receives information from the server and renders it all into text, blocks and tables.

Rendering one container with blocks, text and tables is not a problem. It is also not a problem to print all this in PDF.

But now there is a task to generate documentation for the entire project .

The browser was able to get all the information from the server, even was able to draw it all. But he doesn't have the strength to print to PDF. Or rather, not enough memory. How can you do it?

How can you generate great documentation if the renderer is written in html/js/svg?

Alternatively, can the renderer be pushed into an electron and run the documentation generator on the server? Maybe that's enough memory? Or are there any other libraries that can turn an html page into an offline document?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Glebov, 2020-05-26
@GLeBaTi

I decided that now I do not draw everything at once. I do this:
0) let pdf = new jsPDF ('p', 'pt', 'letter');
1) Draw 1 block in DIV (html + svg)
2) Convert it to image using html2canvas
3) Add image to PDF: pdf.addPage, pdf.addImage
4) Clear this DIV and repeat work with next block
At the end I call pdf .save
The speed is so-so, but there are no more problems with lack of memory.

R
rPman, 2020-05-22
@rPman

I will not advise a ready-made solution, but I can give a very simple direction.
Write a primitive webbrowser(c#)/chromium/webkit application - i.e. in any programming language, you connect a library to display a web page (they are everywhere, Microsoft's .net on Internet Explorer, on mono there will be something based on firefox, on java I did on webkit), and everything is so simple that the project is a couple of mouse movements in the form builder or a primitive example from the 10-line documentation.
Then, add the simplest code that will open your page and take a screenshot of the control on onload, scroll and scroll again until the document ends. From the collected screenshots, you can assemble a pdf with the simplest imagemagic command.
As a bonus, you can, by changing the size of the control (and it can go beyond the boundaries of the visible part of the window) to any, for example, in this way, a long time ago I made an application that screened Google maps 8k at 8k resolution, opening the right place in the window of the appropriate size (RAM at the same time, it took a lot to create png / tiff / jpeg).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question