I am trying to generate a bill in PDF format.
In the given image as product are more that end table has gone to next page.
In that table there are 3 cells, one for left text with small font, other cell with middle text and next cell with that single line.
How can I prevent the table from breaking the page? Is there any property to get table to next page if a page break is going to occur?
I tried table.SplitLate=false, but it didn't work. Any other ideas?
Have you tried PdfPTable.setKeepTogether(boolean) ?
Related
I am currently struggling with finding a proper solution for following problem:
Imagine you have an MS Word (2019) document containing a table consisting of two columns 'A' and 'B'. Text in column B shall always be aligned vertically with the last text line of the text in column 'A'. OK, easy task if the row is on one page only: simply set vertical text alignment of 'B' to 'bottom' and you're done.
Now the BUT: If the the text in 'A' gets too long, Word shall break the cell across pages (hat's a mandatory requirement!). But even if the long text in column 'A' now ends on page 2, the short text in 'B' will be placed on bottom of page 1!
A possible workaround would be to fill up the 'B' with multiple LFs and/or LF+CRs, but I hope someone can explain how a proper solution could look like?!
Thanks in advance!
Desired text position
Wrong text position if row is split across 2 pages
I have a MigraDoc pdf I am generating and have had the requirement to have some 'inline' tables, I needed to get two tables on a line so after investigating this I found TextFrames worked perfectly... Until it encounters the end of the page. Turns out TextFrames do not recognize the end of the page:
(TextFrame are the red boxes)
So, I was wondering if anyone else had come up with a work around for this?
I had thought if I could find the position of the 'current location' I could calculate if the text frame is going to be too tall then manually inject a page break - but I can not seem to find the 'current position' - probably because it doesn't exist until post render??
Is there any way of getting the rendered height position of the 'current line' when coding or is there a better/easier way of doing what I am looking for?
I have found a piece of code that returns the current position using a kind of pre-render:
public double GetMigraHeightPosition()
{
MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(this.document);
docRenderer.PrepareDocument();
RenderInfo[] RenderInfos = docRenderer.GetRenderInfoFromPage(docRenderer.FormattedDocument.PageCount);
RenderInfo r = RenderInfos[RenderInfos.Count() - 1];
return r.LayoutInfo.ContentArea.Y + r.LayoutInfo.ContentArea.Height;
}
So I am using this plus the height of the table to check if that is greater than the active page size (pagesize minus margins & header/footers). Seems to do the trick with regards to stopping the tables spilling into the footer... I still seem to be having the problem with the second table in the first row going onto the next page...?? Havent got a clue what is happening there?!
Object positions are determined when a document is being "prepared" before it is being rendered. If you make changes at that stage, you have to prepare the document again.
You can create tables with "invisible" cells. You can create tables within tables, but inner tables will not have pagebreaks within, so make sure each nested table fits on a single page.
See also:
https://stackoverflow.com/a/36304148/162529
Is there a way to set fixed height of an element? Could be a table, row or section. This element is dynamically generated from database and it can have a variable number of rows. I need to do that, because the section below needs to be in a fixed position for print out. I am using WPF v1.31. I know it is not the latest, but it's an addition to a quite old application.
You can set the height of a Paragraph or a table Row.
I think you cannot set the height of a Table - but that will be the sum of the heights of all rows. Automatic page breaks will make things complicated if a table does not fit a single page.
A Section always starts on a new page.
TextFrame can be used to place text at a fixed position. Depending on the requirements, this could be simple or complicated.
You can prepare a document to let MigraDoc determine sizes and positions. Then you code can decide whether the items with the fixed position will be on the same page or on a new page.
Here is sample code that shows how to show the progress while creating a PDF:
http://forum.pdfsharp.net/viewtopic.php?f=8&t=3172
The same technique can be used to stitch several MigraDoc documents together to create a single PDF. If I understand your requirements correctly, this could be the way to go - without setting the height of any elements.
I'm producing a PDF Export document for a project i'm working on using MigraDoc; the document can contain many rows spans multiple pages, the document can have a user specified number of columns also, this is where i'm having an issue if there are more columns than can fit onto the page it just gets cut off; what i'm after achieving is to get it to wrap round to a new page.
The current implementation of MigraDoc cannot split tables vertically. All columns have to fit on one page or they will be cut off.
For use with PDF files, you can increase the width of the page in order to get all columns. Could this be a solution?
I am trying to create a Report with two columns.
Records should add in as below...
1.Bob 6.Sarch
2.Sue 7.Barrie
3.Adam 8.James
4.Dave 9.Steve
5.Robin 10.Euan
11.Fred
12.Heidi
13.Liz
For the first column (1-5 in this example), a page break should wrap the data to the second column (6-10). After the second column is full (11-13) the the data should page wrap.
The data used to generate the report will have a fixed number of columns. The height and width required for the data will not change.
I am using with C#, WinForms, .net4. I have tried several various approaches with no success. Thus far I have only managed
1.Bob 2.Sue
3.Adam...
Please help or point me in the right direction :-)
Many Thanks
TL;DR ---> This isn't possible with SSRS, afaik.
If I understand correctly, you want to list the items in a data set, that when rendered with a hard page break renderer will render with these requirements:
items are added vertically as long as there's space on the page
a new column of items is started when the first column ran out of space, vertically
a page break is inserted when the second column filled up the vertical space, thus starting a new, first column on a new page
Now, there's only these controls in SSRS:
Textbox
Table, Matrix
Chart
Gauge
List
Image
Subreport
Line, Rectangle
Out of these only the Tablix (Table/Matrix) and List are remotely capable of such a thing, but they can't satisfy your requirements. I'm afraid the answer to your question is that this can't be (easily) done.
The hard way that this may still be possible is perhaps by creating a custom report item and/or by creating a custom rendering extension. But that may be overkill for just wanting to create a nice little list.