I want a document with multiple pages. Every page should have the same header. One section of the document contains a long table, which stretches over multiple pages. On every page of this section I want to show a title above the table.
I came up with two solutions so far. Both seem hacky and have their downsides:
Make the title part of the header in this section. Feels wrong and is also annoying when I have other pages in the document which should contain the header but not the title.
Make the title part of the table and use HeadingFormat. Feels hacky as well because the title doesn't "fit" in the columns of the table.
Any better ideas?
Re 1: Put the table in a new section and set a new header for that section. One line can be the standard header shared by all pages, another line can be a special header for the table section.
Does not look hacky to me.
Re 2: You can set the HeadingFormat for several rows. So you can use the first row for the "header" without any border and with a MergeRight so it spans the whole page. Not really hacky and will look like normal text outside the table.
Solution 1 has a downside as every new section starts on a new page. Well, the table is so important that it even gets an own page header, so this downside should not matter.
A hacky and tricky solution would be using PDFsharp to add a special header on all pages with the table on it. I think I'd go for option 2.
Related
My report adds a page break and resets a custom page number whenever a group changes. How can I print only the first page of each group?
Crystal itself doesn't have a great way for you to programmatically print specific pages. But there are a few ways to make this kind of work:
Easy: Make a formula that generates a list of which pages are ones you want to print. (It might output something like 1,2,5,7,9, which you could copy and paste into the Page Range when you go to print.)
Medium: Make a modified version of this report that excludes any data you don't want to print. Figure out a maximum number of records that fit on a page (for example, 18) and only take the first 18 per group. (This might be easier to set up with a custom SQL statement in Crystal.)
Difficult: Same as option 2, but you write suppression formulas for everything on your report. If Page Number > 1, the entire page goes blank. After printing you just remove the blank pages from the file. Tedious, but no ink wasted...
I have a base document with sections created by programmatically inserting from a separate template document. The insertion is fine, but the footer isn't appearing on any extra pages created as a result of the insertion, i.e. the first page has a footer, but page two (created by inserting content) does not. If the original document has a two pages then it will render with a footer on the first two pages, but not the third.
Is there a way I can force the footer to render on all of the pages I have created?
There are three types of Headers/Footers in a Section e.g.
Header/Footer for First page,
Primary Header/Footer which can also be used for Odd numbered pages and
Header/Footer for Even numbered pages.
So, if you want to keep same Header/Footer across all pages in Word document, you can first clear all Headers/Footers (see Section.HeadersFooters.Clear() method) from all Sections in Document and then build/assign a single Primary Header/Footer to the first Section.
You might also want to turn off/on 'Different First Page' and 'Different Odd & Even Pages' options using 'Section.PageSetup.DifferentFirstPageHeaderFooter' and 'Section.PageSetup.OddAndEvenPagesHeaderFooter' properties.
Also, using Aspose.Words, you can programmatically control How Headers and Footers should appear during Joining and Appending Documents.
I work with Aspose as Developer Evangelist.
I am using PDFSharp to export a table to PDF (using the regular MigraDoc.DocumentObjectModel.Tables.Table object). It works great except I ran into a few issues:
if the content of a single cell in the table is longer than the height of the page it seems like the content just gets cut off. A table itself can span multiple pages but a row seems like it can only be 1 page high and It seems like it doesn't extend onto the next page.
Is there any workaround to this or is this just a bug in the library?
Also for tables that span multiple pages, is there a way to have the header row on the table show up at the top of every page?
Re first question:
It's documented that MigraDoc does not break table rows over multiple pages. It's not a bug, it's a limitation. So it's up to you to design the tables that this does not cause problems.
IIRC there is a hack published on the PDFsharp forum that increases the page height to work around this problem. If you only need PDFfiles, this could be a workaround.
Edit: Didn't find the link when I made the post, but found it today when I tried again: Here's the workaround:
http://forum.pdfsharp.net/viewtopic.php?p=4311#p4311
I didn't try it myself.
Re second question:
Rows marked as header rows will be repeated on every new page. Just set the HeadingFormat property of those rows to true.
I have a section on my website where I plan to add a lot of text-based content, and rather than display this all at once it would be nice if I could add paging on just these pages. If possible, I would like to put all of my content within one content item and have the paging work automatically, building a URL along the lines of http://example.org/articles/title?page=2 or similar.
I've stumbled across an article that mentions paging with Sitecore items and this seems rather close to what I require, although mine requires pagination on a single content item, rather than multiple items. Can someone help me adapt this article towards my needs (if it's on the right track of where I should be looking)?
Is it possible to do this with a Sitecore content item?
http://briancaos.wordpress.com/2010/09/10/create-a-google-style-paging-component-in-c/
I think you'd either want to create your own WebControl and define a custom Render() method that reads the query string to write out the correct information, or you could even do it all in a Sublayout (a user control ASCX file). I've done this before by adding in a custom tag in the Rich text editor via Sitecore (I think I used <hr class="page-break" />) then in my ASCX I'd look for that HTML tag and split the content into chunks from that. I think my solution also used jQuery for some of it but you could probably do it with C# too.
Edit:
You'd want to split the tasks up and have the "paged" content as well as a list of pages (like the article you referenced) so you can easily generate the page buttons. Both of these could be done in two separate repeaters.
You can split the text from a single field into the different pages using approach described here: Split html string to page. All you need to do after that - read the query string and display appropriate block.
If I understand you correctly you have an Item in Sitecore that has x number of text fields and you only want a subset of those displayed depending on input in the querystring ?
In it's simplest form you want a sublayout that handles that.
Basically I'd imagine you having fields called Text1, Text2, text3 etc.
This .ascx could then retrieve the data for fields the fields you'd want using the control and adding them.
Then you could use the code from the article to generate the paging links.
This should be simple enough, but I'd say it would be a better idea to have an item in sitecore and use it's children as the data you want viewed and paged.
It's nicer because if you start out with 5 "page" fields and suddenly want 10, your item will keep on growing, where children can be added without bloating the parent page. Plus the user could then order the children how he sees fit.
I hope this helps a bit.
I am working on a project in C# that will produce a Word document using the Word Automation API.
I would like to insert page breaks at specific points in the generated document and I am currently doing this successfully with the following code:
// Generate page break
object pageBreak = WdBreakType.wdPageBreak;
wordApp.Selection.InsertBreak(ref pageBreak);
However, if the document has naturally wrapped onto the next page anyway after running out of room on the previous page then I don't really want to be generating a page break or else I will end up with a blank page.
What I would really like is the ability to find out exactly where the cursor is and if it is on the first line and column of the current page then I can safely assume that it is not necessary to insert a page break.
Is there a way to access the position of the cursor? Or another solution that would do the same thing? It seems like a simple requirement so I apologize in advance if I have missed the obvious.
Assuming that you are programmatically building the document in a way that would cause wordApp.Selection to properly reflect your actual (and relevant) position in the document, you can determine its line and column on its starting page using its Information property and the following two WdInformation enums (shown here as VBA; not sure what the .NET PIA syntax is offhand):
line = wordApp.Selection.Information(wdFirstCharacterLineNumber)
col = wordApp.Selection.Information(wdFirstCharacterColumnNumber)
These values correspond to the Ln and Col values seen in Word's status bar. If they are both equal to 1, then you are in the first position of the page on which the Selection begins.
Good luck!
You could try setting property on the paragraph that causes it to have a page break before it. I don't if Word Automation API allows it to be set, but it seems exactly what you need.