DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: CSS @page questions

  1. #1
    Join Date
    Sep 2010
    Posts
    8

    CSS @page questions

    Hello folks. I'm a hobbyist programmer trying to figure something out.

    I have a bunch of XML files that I wrote. They are formatted with XSL and CSS stylesheets. I then wrote a program that would take the contents of several of my XML files and combine them into an "uber-XML" file.

    The end result looks great in Firefox; the data from each XML file is presented in a table. When I open an uber-XML file in Firefox, all the data is presented in a nice column of tables.

    However, instead of 1 column continuous, I want 2-3 columns on pages (at least when I print). I want the tables to not break across pages or columns.

    Someone in the .NET forum suggested using CSS files, and I found something called "@page", but I can't seem to get it to work. Before I go back there I want to give CSS another shot, but I need a little guidance.

    Oh yes one last thing, all this is done in a Windows local environment, right off my hdd. I don't have a Web or Apache server or anything like that, just Firefox and a text editor (and visual studio).

    Any guidance would be appreciated. Thanks!

  2. #2
    Join Date
    May 2009
    Location
    United Kingdom
    Posts
    49
    Hi, I actually suggest the use of CSS for your issue, from the .NET forum side

    This is quite a simple example of using CSS for print:
    Code:
    <link rel="stylesheet" href="print.css" type="text/css" media="print"  />
    http://www.webcredible.co.uk/user-fr...ylesheet.shtml

    However, your issue with @page is a browser support issue:
    The @page rule and forcing Landscape orientation

    The @page rule has been cut down in scope from CSS2 to CSS2.1. The full CSS2 @page rule was reportedly implemented only in Opera (and buggily even then). My own testing shows that IE and Firefox don't support @page at all. According to the now-obsolescent CSS2 spec section 13.2.2 it is possible to override the user's setting of orientation and (for example) force printing in Landscape but the relevant "size" property has been dropped from CSS2.1, consistent with the fact that no current browser supports it. It has been reinstated in the CSS3 Paged Media module but note that this is only a Working Draft (as at July 2009).

    Conclusion: forget about @page for the present. If you feel your document needs to be printed in Landscape orientation, ask yourself if you can instead make your design more fluid. If you really can't (perhaps because the document contains data tables with many columns, for example), you will need to advise the user to set the orientation to Landscape and perhaps outline how to do it in the most common browsers.

    Of course, some browsers have a print fit-to-width (shrink-to-fit) feature (e.g. Opera, Firefox, IE7) but it's inadvisable to rely on users having this facility or having it switched on.
    http://css-discuss.incutio.com/wiki/...pe_orientation

    CSS3 may be your best bet for overcoming page based constructs, but you would need to check browser support.
    http://www.w3.org/TR/css3-page/#page-size-prop
    Last edited by reedy837; 01-25-2011 at 07:36 AM. Reason: Added CSS3 note and link.

  3. #3
    Join Date
    Sep 2010
    Posts
    8
    thanks again! my computer crashed and I just got it back up. I'll check that out over the next couple days!

  4. #4
    Join Date
    Sep 2010
    Posts
    8
    OK, I'm beginning to think CSS is not what I need. I didn't see any CSS rules for turning a long column of data into multiple columns, and everything I can find about page-breaks is discouraging. I tried to download that Prince program, but it would not install on Win7 64-bit.

    On top of that, when I upload my XSL file to my website, my browsers can't use it. I get (Error loading stylesheet: An unknown error has occurred (805303f4)), which apparently means that a CSS stylesheet can't be referenced from inside an XSL document. AND my XLS document can't contain an inline stylesheet, so that's a big double-bummer right there.

    On top of THAT, the ONLY way I can get my all-local XML docs to find my XSL and CSS files is using a relative URI ... that is 'scripts/blockTemplate.xsl'. I can't use an absolute path (like to 'c:/scripts/blockTemplate.xsl'), and I can't even use '.' or '..' meaning that if I want my XML files in multiple directories I need to constantly copy an updated version to all the folders.

    So, I'm going back to the drawing board. What I really need is a C# .NET control that acts and displays just like an HTML table, but considers itself a single control with a Height property.

    RichTextBox is the closest I can come on my own, but I don't know a) how to format the text or b) how to get the "multiple column" effect. I'm going to work on those for a week or so and see what I can come up with.

    Thanks for the help, and I'll probably be back with more questions.

Similar Threads

  1. CSS usage issue in XSL/XML
    By ug4jee in forum XML
    Replies: 0
    Last Post: 10-05-2009, 08:36 AM
  2. Replies: 0
    Last Post: 12-16-2006, 03:04 AM
  3. Replies: 0
    Last Post: 08-28-2006, 04:05 AM
  4. randomly select quiz questions
    By galgal5814 in forum ASP.NET
    Replies: 5
    Last Post: 03-10-2006, 12:10 PM
  5. Replies: 13
    Last Post: 05-23-2005, 05:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center