iTextSharp, page break in PDFPTable and define body size - c#

I want to know, how can I do make a page break in PDFPTable but I don't want it cut the table just after the table header ?
And I want to define a size to the body of my page but I don't know how can I make that can you help me please ?

According to this, no, you cannot manually force a page break within a table. Your primary alternatives are to either just make multiple tables or use WriteSelectedRows. If you are forcing a page break then you generally "know when" you want to do it so either option should work. Multiple tables allow you to still leverage iTextSharp's flow logic whereas WriteSelectedRows gives you more control but assumes you have calculated if things actually fit. See this for a sample of using WriteSelectedRows.
To control the document's size you can either use the constructor to Document which optionally takes a Rectangle and a margin or you can call SetPageSize on the Document if you want to control it per-page.

Related

MigraDoc page break on sub-sections

I am using MigraDoc which might generate a document like the following example:
However I want to be able to 'bind' a given number of paragraphs/tables (or anything else) together so that if a page break is detected anywhere during any of the items, the whole block is moved onto the next page - for example (where highlighted text is all 'bound' together somehow):
Hope the question makes sense...?! I’m not sure where to start with this but have a definitive requirement for it!
Paragraphs have a KeepTogether property that prevents pagebreaks within the paragraph.
Paragraphs have a KeepWithNext property that prevents pagebreaks between this paragraph and the next one. A typical use case are head lines that make no sense at the bottom of the page.
For tables, see here:
https://stackoverflow.com/a/1327228/162529

How to remove some data in Header in next page (RDLC Report)

I'm having a trouble on creating reports for my client because of the format. I just want to display the logo on the first page of my report and the rest will display without the logo. Please see my sample format.
Note: I dont want to remove the title on my header because I want to show that to all pages. I just want to remove or hide some data on header.
Using the following expression for the Hidden property should give you the desired behavior, like Ashnish Emmanuel suggested.
=(Globals!PageNumber <> 1)
When an item gets hidden, the objects below will move up. This means that the header's size should indeed shrink. This should then cause the body to move up as well.
The size of the body won't really change , there will just be more space on the page for the body to use.
However, if you defined a fixed height for the header, this will not force it to shrink because it will keep the empty space behind the last item. Which will mean that your body won't move up either. If you wish to create space between controls I suggest you always do it inside a report item (ex: rectangle, textbox, tablix) because this will give you more control over it (expressions).
Another solution is to remove the report header all together and work with a Tablix with a single column. You can replace the TextBoxes in the cells with Rectangles. The header row has the same functionalities as the page header, but you also have a CanGrowand CanShrink property which could solve your problem. You can also define multiple header rows which would allow you to hide an entire row with ease.
For the row used as body, you should then re-size the rectangle to be the same size as the actual page. And set the Keep Togetherproperty as true. This will then break the same way like the regular report body.
I think you are looking for Report Header.
In RDLC any control which is out the Table or the Tablix it will not be repeated, hence work as report header !
if you want to repeat , you place the item/data it in page header , use it for your Title.

Compare word documents(.docx) with a document template(.dotx)

Is there any way I can compare a word document(.docx) with a document template(.dotx) generated in microsoft word.
I want to do this comparison programmatically using c#.
I want to compare both documents word to word so that I can determine to which template the document belongs. I don't just want to compare the size of both but I want to compare the contents also.
By this comparison I want get the following results.
From which document template the document is generated.
In the document template, I want to check that at which place a particular information is stored.
Say for example I want to search for the communication information of a person, then I want to traverse the document and check that At which position the template has the area/section for Address.(i.e. Top left corner, top center, In a paragraph, In body etc)
In same way I want to extract other information too, Like Link to other documents etc.
After getting those positions I want to get that Information from the .Docx file.
Say, If I found that the Address in the top-left and there are five links referring to other documents in five different paragraphs. Then what I want is to get the Address and save it to a variable. After that I want to replace those link contents from placeholders to Actual hyperLinks. i.e If a Link is referring to Doc-A then Instead of just showing a Plain text I want replace it with A hyperlink to Doc-A.
Any suggestions?
Thank You.
Your question is rather too vague and involved to give a really good answer, however...
To find out from which template a document was generated the object model provides the property: Document.AttachedTemplate with will return the full file name. This is certainly better than comparing word-by-word (which is also very time-consuming)
The Word object model also provides the method CompareDocuments (belongs to the Word.Application class). This will "highlight" differences in the text content of two documents.
Links will be found in the Document.Hyperlinks collection
Getting the position of things is a bit chancy with Word and it depends on what you really mean by "top-left", etc. Better would be to construct the templates using content controls, form fields and/or bookmarks so that you can uniquely identify important sections. However, Word does provide the Range.get_Information method that can return relative and absolute positions on the page if that's what you really want.

Using ASP.Net, what would be the best control to use in this situation?

I'm writing a small program that lets the user enter a keyword. The program then searches through a database table and finds all records (using LINQ) that match the user's search criteria.
The resulting records that are returned will be displayed on the screen as images (much like Googles image search page). The user will then be able to click on any of the returned images and be taken to a page with more detail about that image.
My question is, what is the best control to use to display the images that result from the user's initial search? This is an ASP.Net program. Would it be better to show the images in a gridview? Or a listview? Or build a table and fill each cell with an image button? I've never done this before so I'm basically just wondering how to present the data.
I'm not looking for code but I'd love to hear how you'd handle this.
Thanks!
EDIT:
I should add that all the images are the same size and I'm thinking that I'd return all images and let the user scroll down the page. Realistically, I don't think there would ever be more than 50 images for the user to choose from. I'm envisioning having five images on each row of results returned, like the below image:
I've always been a fan of keeping things simple by using a Repeater where I can. You'll have more control over how things will look writing for own HTML.
Since you're using images, and I assume they will be in different sizes, I'd make the Itemtemplate contain a div with an anchor and img inside of it. Slap a max width onto the images and hide the overflow on the div so the images don't look scrunched.
Just set the datasource property of what's returned from the filter, call a databind() and you're good to go.
That's how I'd approach this situation. I too am interested in hearing from others for comparison.
I'd go for the trusty Repeater control. That gives you the flexibility to render whatever you want for any collection.
I would create a control that builds a dynamic table control. You could have a List<string> to hold the url of each image. I would expose a public method called AddImage(string imageUrl) that would add the url to the List<string> collection.
Once the page is ready to be rendered, I would divide the number of images you have by 5 (this will give you the number of rows you need) and then just render the table. In addition, before rendering, you could use LINQ to get the data before render (for example, to sort it)

How to tell height of paragraph in OpenXML?

I'm generating an MS Word document from user data. The data is placed in a container which is serialized to XML, and the resulting XML is converted to OpenXML using XSLT. There are a few minor changes done programmatically in C# to generate the Word document, as they can't be done with XSLT.
There is a user requirement that an item be placed completely on one page without any associated data being split onto another page. Sometimes one item will fill up an entire page, and sometimes I can fit three or four items on one page (I need to insert a separator (horizontal rule) between items that fit on the same page.)
Is there a way to determine whether or not one item or OpenXML paragraph will fit entirely on the "current" page? This can be either via C# or XSLT, and I can work something out.
Unfortunately, the only way this can be reliably done is to actually render the output, including all of the font sizes, bolding, kerning and all that. Which means you have to do the pagination in Word, and then save it back to the OpenXML.

Categories

Resources