How to prevent page break in QTextDocument block or frame? - c++

Is it possible to prevent page break anywhere inside table in QTextDocument?
In my QTextDocument I have a plenty of larger images created from small image blocks. Adding large images seeems to be a waste of resources, so an obvious solution seems to be creating a table, putting small image in each cell.
The problem is that now these tables can have page breaks after each row. The only way to prevent it I know is to call setPageBreakPolicy() for each table/frame format, but this requires obligatory page break before each larger image. I would like to have these page breaks only if necessary (larger image does not fit).
Is it possible to do what I want?

For a QTextTable, you can prevent splitting it over multiple pages by setting the headerRowCount property of the QTextTableFormat equal to the number of rows in the table. This property sets the number of rows that are repeated when a page boundary is crossed, repeating the table header. If you set you entire table to be the header, the whole table is always placed on a single page.
One warning: do not do this with tables that potentially do not fit on a single page. Qt will mess things up in this case.
I hope Qt will add some extra flags to the pageBreakPolicy property in the future, so that we can create unbreakable tables/frames in a clean way.

Related

XSL:FO - Page break on two dynamic areas?

I'm using XSLFast and was wondering if the following is possible:
I have a page with static content and one area containing a table that outputs XML-data. The table is set to a specific height so that the page breaks when the height is reached and continues outputting one the next page.
Now,
I want to add another area containing such a table with the exact feature. Is that possible on one side?
I have never used XSLFast, but...
XSL 1.1 allows an fo:simple-page-master to have multiple fo:region-body. (See https://www.w3.org/TR/xsl/#fo_simple-page-master.) I do not know if XSLFast supports it, but with a formatter that supports multiple fo:region-body, you could put the red table and the blue table in separate fo:flow and direct them to the two different fo:region-body. The formatter would then make another page whenever either fo:region-body overflowed.

In django-tables2, make number of rows displayed depend on screen size?

When using django-tables2, use the paginate parameter to limit the number of rows displayed. For instance, if I have the table my_table, then in views.py I set it to display 10 rows as follows:
RequestConfig(request, paginate={'per_page':10}).configure(my_table)
My problem is that in my app I want the number of rows shown per page to depend on how big the user's screen is. For instance, 10 rows for mobile devices, but 25 rows for desktop screens. I am imagining doing in views.py what you can do with style sheets using the media rule (e.g., #media(max-height: 480px) {do something}).
Unfortunately, my (noob) understanding is that in Django, the view is relatively insulated from low-level parameters like screen size. However, I don't want to implement some scheme like sending information from the template to the view if there is already a simple solution baked into django-tables2 that I am just ignorant of.
Note I am using Bootstrap4 for my front end, if that makes any difference. The point is that I am already importing Javascript and jQuery into the project, at least at the template level.
Related general discussion
Interestingly, I haven't seen a lot of discussion of adapting table row count to media type, but there is obviously tons of more general discussion of responsive media-sensitive design:
Responsive design with media query : screen size?
https://developer.mozilla.org/en-US/docs/Web/CSS/#media
I have no straightforward or complete solution, but I'll share some thoughts:
When (initially) rendering the table, Django-tables2 has no way of knowing the screen size. One of these workarounds might satisfy your needs:
Render less rows
In your initial page view, if your screen size is small:
Hide some rows, then, adjust the offset and number of pages you request for the next pages using JavaScript. This will involve rewriting url parameters of the pagination links.
Reload the page with a smaller number for per_page added to the url.
Default to rendering a smaller number of rows, and allow the user to change the number of rows rendered with a dropdown, which is hidden for mobile users.
Optimize template for responsiveness
Optimize the template for different screen sizes rather than changing the number of rows. An example of how this could work can be found in the table displayed in webpack documentation. You might still want less rows for smaller screens with this technique though.
Client-side table-sorting
If the total number of rows is reasonable, sending everything to the client and deferring the pagination to something like datatables might work.

Keep a row together but break if necessary

I´m working on a project using XSL-FO to generate some PDF Files.
There are several tables with rating comparisons.
Some columns have short text and some have very long text.
Without the attribute keep-together.within-page or with keep-together.within-page='auto' the tables look very ugly because the columns break the text at the end of a page - no matter what.
So i decided to use keep-together.within-page='always' to achive a better look. If a row doesnt fit on a page, fop moves the row to a new page. beautiful.
Now the problem.
In some cases some texts are very long and the content is larger than one page. In this case i want the row to break onto 2 pages.
I was looking for something like keep-together.within-page='always if possible'
is it possible to achive this some how?
You are searching for:
keep-together.within-page='<number(1-9)>'
If you type in 'always' fop tries to fit it with any necessary method into one page. If you specify a number it is more like "I will try what I can, but if the text is to long, it will break anyways". The number you fill in, is more like a priority, in case you have many nested keep-togethers. That means that the value 1 will also do its job.

I have large file contents that I want to make searchable on AWS CloudSearch but the maximum document size is 1MB - how do I deal with this?

I could split the file contents up into separate search documents but then I would have to manually identify this in the results and only show one result to the user - otherwise it will look like there are 2 files that match their search when in fact there is only one.
Also the relevancy score would be incorrect. Any ideas?
So the response from AWS support was to split the files up into separate documents. In response to my concerns regarding relevancy scoring and multiple hits they said the following:
You do raise two very valid concerns here for your more challenging use case here. With regard to relevance, you face a very significant problem already in that is harder to establish a strong 'signal' and degrees of differentiation with large bodies of text. If the documents you have are much like reports or whitepapers, a potential workaround to this may be in indexing the first X number of characters (or the first identified paragraph) into a "thesis" field. This field could be weighted to better indicate what the document subject matter may be without manual review.
With regard to result duplication, this will require post-processing on your end if you wish to filter it. You can create a new field that can generate a unique "Parent" id that will be shared for each chunk of the whole document. The post-processing can check to see if this "Parent" id has already been return(the first result should be seen as most relevant), and if it has, filter the subsequent results. What is doubly useful in such a scenario, is that you include a refinement link into your results that could filter on all matches within that particular Parent id.

C1ReportDesigner subreport overflow to footer and not page breaking

I am working with C1ReportDesigner which I am new to it. I have a sub-reports embedded with main report. When a column in sub-report content is huge it doesn't page break, instead it overflows to footer. How to page break and continue in next page in C1ReportDesigner?
It seems that the KeepTogether property of the control within the subreport (having long text) is set to True. This property tends to keep the whole text together on a single page, hence ,at times, causing the overflowing of text over other sections.
Please make sure to set the KeepTogether property of Field (of Subreport) having long text is set to False.
Regards,
Mohita