Forum How do I...?

Why doesn't my named page work - SOLVED

mark_anderson_us
Hi All

I'm trying to create a PDF where all except 1st page and pages with T&C's have a heading. It's working for the first page, but not the terms page.

Can anyone see a problem with this?


 /* Common settings for all pages  */
          @page {
          size: US-Letter;
          margin-top: 2.0in;
          margin-bottom: 0.7in;
          margin-left: 0.5in;
          margin-right: 0.5in;
          /* insert header HTML at top for all pages unless otherwise specified on specific pages (e.g. first) */
          @top {
          content: flow(header);
          padding-bottom: 5px;
          }
          /* page numbers on bottom right */
          @bottom-right {
          content: "Page " counter(page) " of " counter(pages);
            }

          /* Co name and logo on bottom right */
          @bottom-left {
          content: flow(footer);
          }
          }

          @page:terms {
          margin-top: 0.5in;
          /* don't insert header HTML at top of terms page */
          @top {
          content: normal
          }
          }
          
          @page:first {
          margin-top: 0.5in;
          /* don't insert header HTML at top of page 1 */
          @top {
          content: normal
          }
          }
          
         
          
          /* this will use the named page "terms" where this div occurs */
          div.terms {
                        page:terms;
                        page-break-before: always;
                        
          }



On my T&C page (end of HTML) I have this
<div class="terms">
          these are the T and Cs
</div>


Below is a simplified version my HTML (after XSL transform) that is fed to Prince:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Technique Quotation</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
        
        <meta name="date" content="17/10/2011 17:14:58" />
        <style type="text/css">
          /* Common settings for all pages  */
          @page {
              size: US-Letter;
              margin-top: 2.0in;
              margin-bottom: 0.7in;
              margin-left: 0.5in;
              margin-right: 0.5in;
              /* insert header HTML at top for all pages unless otherwise specified on specific pages (e.g. first) */
              @top {
                       content: flow(header);
                       padding-bottom: 5px;
                   }
              /* page numbers on bottom right */
              @bottom-right {
                        content: "Page " counter(page) " of " counter(pages);
                        border-top-width: 1px; border-top-style: solid;  border-top-color: #b1aead; border-collapse: collapse; border-spacing: 0px; width: 100%;   font-size: 9pt; padding-top: 1em; margin-top: 10px;
                        vertical-align: top;
                        font-family:Arial, Helvetica, sans-serif; font-size: 9pt;
                  }
    
              /* Co name and logo on bottom right */
              @bottom-left {
                       content: flow(footer);
                       border-top-width: 1px; border-top-style: solid;  border-top-color: #b1aead; border-collapse: collapse; border-spacing: 0px; width: 100%;   font-size: 9pt; padding-top: 1em; margin-top: 10px;
                       vertical-align: top;
                       font-family:Arial, Helvetica, sans-serif; font-size: 9pt;
                    }
          }
          
          
          @page:first {
                margin-top: 0.5in;
               /* don't insert header HTML at top of page 1 */
               @top {
                   content: "FIRST PAGE";
               }
          }
          
         @page:terms1 {
               size: landscape;
               @top {
                   content: "TERMS";
               }
          }
          
          /* this will force the page where this occurs to be of type "terms" */
          #terms1 {
                        page: terms1;   
                        position: static;
          }
          
          
          /* This takes any div whose id is header out of the normal flow and places it in the header */
          #header { flow: static(header); align: left; }

          /* This takes any div whose id is footer out of the normal flow and places it in the footer */
          #footer { flow: static(footer); align: left; font-size: 9pt;}

          .body {font-size: 10pt; margin: 0px; vertical-align:top; font-family: Arial, Helvetica, sans-serif; }
          
        </style>
    </head>
    <body>
        <div id="footer">footer text</div>
        
        <div id="header">
            CONTINUATION
        </div>
        
        <p style="page-break-after: always;"> First Page Content</p>
      
        <p> Continuation Page Content</p>
        <br style="clear:both" />
        <div id="terms1">
            <table>
                <tr>
                    <td class="terms_ref">1</td>
                    <td class="terms_text">TERMS PAGE CONTENT. Should be landscape, should not say continuation in header</td>
                </tr>
            </table>
        </div>
    </body>
</html>

Edited by mark_anderson_us

mikeday
It should be "@page terms" and not "@page:terms".
mark_anderson_us
thanks Mike

anyone know of a good css validator?
jim_albright
What I do is I incrementally build my CSS. Process using Prince all along the way. When Prince gives error message that CSS did not parse I back up to where it worked and then look carefully at the little bit of code that isn't working.

Prince outputs a debug message:
Mon Oct 17 11:46:19 2011: C:\Documents and Settings\Albright\My Documents\Bloom\English Books\Vaccinations\previewMode.css: warning: failed to parse all CSS rules

In the to do list is a line number where it fails.

Google /css validator/ and you will find them. Some work with your browser as add-ons. I use both the firefox addon and also W3C. I just tried the W3C one and found that I had to choose to set the validation to CSS 3. CSS 2.1 didn't like my color choice of /brown/. CSS 3 is showing an error but Prince says it works. I'll look at my CSS to see what W3C doesn't like. The W3C does a pretty print of your CSS if that will help out. Prince is on the cutting edge so it is possible that Prince has features working that don't validate with W3C

Jim Albright
Wycliffe Bible Translators

jim_albright
If you look at the Prince/about us you find:

Håkon Wium Lie, Director

Håkon is a web pioneer, having proposed CSS while working with Tim Berners-Lee at CERN in 1994. Håkon became a devotee [of Prince XML] when he found that Prince could format his book on CSS (co-authored with Bert Bos) and his PhD thesis. Håkon is a graduate of MIT's Media Lab and is also the CTO of Opera Software.

I was just checking some of the latest CSS 3 specs. You will see Håkon is one of the editors.

Jim Albright
Wycliffe Bible Translators

mark_anderson_us
Thanks for reply jim

jim_albright wrote:
Prince outputs a debug message:
Mon Oct 17 11:46:19 2011: C:\Documents and Settings\Albright\My Documents\Bloom\English Books\Vaccinations\previewMode.css: warning: failed to parse all CSS rules


Will have to llok up command line setting for debug

Google /css validator/ and you will find them. Some work with your browser as add-ons. I use both the firefox addon and also W3C. I just tried the W3C one and found that I had to choose to set the validation to CSS 3. CSS 2.1 didn't like my color choice of /brown/. CSS 3 is showing an error but Prince says it works. I'll look at my CSS to see what W3C doesn't like. The W3C does a pretty print of your CSS if that will help out. Prince is on the cutting edge so it is possible that Prince has features working that don't validate with W3C


Turns out this will be quite time consuming. Spent half hour sso far. The W3 Service seems to be broken. Tried uploading a file and direct input in IE9 and FF7.0.1 and all give:

Target: No file
I/O Error: You have sent an invalid request.

Went to downlaod the CSS vlaidator for FF. Doesn;t work with 7.0.1. having problems finding 6.x

Will keep looking though

Regards

Mark
dauwhe
CSS validation is a big issue for us, especially as the files might be 3,000 lines long. I find the online validators next to useless due to false positives from all the paged media stuff. I just checked a working file, and there were 317 errors from Jigsaw even using the CSS 3 profile.
mikeday
I think the best solution would be for us to add optional log messages to Prince warning of unrecognised CSS syntax.
mark_anderson_us
I tried several validators today. Many don;t support CSS 3, so thye're not that useful

Would be good if we could get mesages in log
jim_albright
That is probably why I use Prince as the validator.
Currently it just says the CSS didn't parse and you have to look for error.
Better info on where the problem is in CSS via Prince is currently #24 in the to do list.
That doesn't give you any idea when it will be done but it is on their list.

3000 lines of CSS? Wow that is a lot.

Jim Albright
Wycliffe Bible Translators

mark_anderson_us
jim_albright wrote:
That is probably why I use Prince as the validator.
Currently it just says the CSS didn't parse and you have to look for error.
Better info on where the problem is in CSS via Prince is currently #24 in the to do list.
.


Hi Jim

I'm using on windows. I tried the verbose and debug options. It didn't report my error. I even changed "margin-top" to "margi-top" in one of the style and didn't see that in the log either, what options do you use?

Below is my log
Regards

Mark
Started: "C:\Program Files (x86)\Prince\engine\bin\prince.exe" --debug "C:\Users\mark.anderson\Desktop\XSL Stuff\Test\Quotation_Test_v1.16_b1.xsl_xslt" "C:\Users\mark.anderson\Desktop\XSL Stuff\Test\Quotation_Test_v1.16_b1_20111019094140723.pdf"
prince: debug: loading license: C:\Program Files (x86)\Prince\engine/license/license.dat
prince: loading style sheet: C:\Program Files (x86)\Prince\engine/style/fonts.css
prince: debug: loaded resource: C:\Program Files (x86)\Prince\engine/style/fonts.css
prince: debug: loaded resource: type: no
prince: Loading document...
prince: loading XML input: C:\Users\mark.anderson\Desktop\XSL Stuff\Test\Quotation_Test_v1.16_b1.xsl_xslt
prince: debug: loaded document: file:///C:/Users/mark.anderson/Desktop/XSL%20Stuff/Test/Quotation_Test_v1.16_b1.xsl_xslt
prince: debug: sniffed doctype: XHTML
prince: loading style sheet: C:\Program Files (x86)\Prince\engine/style/xhtml-ns.css
prince: debug: loaded resource: C:\Program Files (x86)\Prince\engine/style/xhtml-ns.css
prince: debug: loaded resource: type: no
prince: loading style sheet: C:\Program Files (x86)\Prince\engine/style/common.css
prince: debug: loaded resource: C:\Program Files (x86)\Prince\engine/style/common.css
prince: debug: loaded resource: type: no
prince: loading style sheet: C:\Program Files (x86)\Prince\engine\style\hyph.css
prince: debug: loaded resource: C:\Program Files (x86)\Prince\engine\style\hyph.css
prince: debug: loaded resource: type: no
prince: loading style sheet: C:\Program Files (x86)\Prince\engine\style\mathml.css
prince: debug: loaded resource: C:\Program Files (x86)\Prince\engine\style\mathml.css
prince: debug: loaded resource: type: no
prince: loading style sheet: C:\Program Files (x86)\Prince\engine\style\svg.css
prince: debug: loaded resource: C:\Program Files (x86)\Prince\engine\style\svg.css
prince: debug: loaded resource: type: no
prince: debug: prepack
prince: loading image: C:\Users\mark.anderson\Desktop\XSL Stuff\Test\.\Logo.png
prince: debug: loaded resource: C:\Users\mark.anderson\Desktop\XSL Stuff\Test\.\Logo.png
prince: debug: loaded resource: type: no
prince: Converting document...
prince: debug: pack
prince: debug: font request: 500 Arial, Helvetica, sans-serif
prince: debug: font scan: Arial
prince: debug: font scan: Arial, 34 matches
prince: debug: font scan: Helvetica
prince: debug: font scan: Helvetica, 34 matches
prince: debug: font scan: Times New Roman
prince: debug: font scan: Times New Roman, 34 matches
prince: debug: font scan: Symbol
prince: debug: font scan: Symbol, 1 matches
prince: debug: font scan: MingLiU
prince: debug: font scan: MingLiU, 2 matches
prince: debug: font scan: Mangal
prince: debug: font scan: Mangal, 2 matches
prince: debug: font scan: Vrinda
prince: debug: font scan: Vrinda, 2 matches
prince: debug: font scan: Raavi
prince: debug: font scan: Raavi, 2 matches
prince: debug: font scan: Shruti
prince: debug: font scan: Shruti, 2 matches
prince: debug: font scan: Latha
prince: debug: font scan: Latha, 2 matches
prince: debug: font scan: Gautami
prince: debug: font scan: Gautami, 2 matches
prince: debug: font scan: Tunga
prince: debug: font scan: Tunga, 2 matches
prince: debug: font scan: Kartika
prince: debug: font scan: Kartika, 2 matches
prince: debug: font scan: Arial Unicode MS
prince: debug: font scan: Arial Unicode MS, 15 matches
prince: used font: Arial, Regular
prince: debug: font request: 800 Arial, Helvetica, sans-serif
prince: used font: Arial, Bold
prince: debug: font request: bold Arial, Helvetica, sans-serif
prince: debug: font request: small-caps Arial, Helvetica, sans-serif
prince: debug: font request: Arial, Helvetica, sans-serif
prince: debug: font request: serif
prince: used font: Times New Roman, Regular
prince: debug: font request: italic Arial, Helvetica, sans-serif
prince: used font: Arial, Italic
prince: debug: font request: 600 Arial, Helvetica, sans-serif
prince: Resolving cross-references...
prince: debug: pack
prince: debug: writing output: C:\Users\mark.anderson\Desktop\XSL Stuff\Test\Quotation_Test_v1.16_b1_20111019094140723.pdf
prince: loading image: C:\Users\mark.anderson\Desktop\XSL Stuff\Test\.\Logo.png
prince: debug: loaded resource: C:\Users\mark.anderson\Desktop\XSL Stuff\Test\.\Logo.png
prince: debug: loaded resource: type: no
prince: Finished: success
Process ended with exit code: 0
jim_albright
--verbose --server --log-stats


See if this helps. Looks like
--log-stats

is undocumented. Don't know if this is an oversight or on purpose. But I needed it.

Jim Albright
Wycliffe Bible Translators

mark_anderson_us
jim_albright wrote:
--verbose --server --log-stats


See if this helps. Looks like
--log-stats

is undocumented. Don't know if this is an oversight or on purpose. But I needed it.



Thanks Jim. Didn't help unfortunately (3 deliberate erros in CSS)

Regards

mark
jim_albright
The only other "strange" code that I have is a js.

This is a file called PrincessJavascript.js:


function logPageCount()
{
Log.data("total-page-count", Prince.pageCount); }

Prince.addEventListener("complete", logPageCount, false);


and called by
-- script "PrincessJavascript.js"

the VB.NET code is
If sStylesheetFileName = "" Or sStylesheetFileName = "#none#" Then
sArguments = sOptions & _
" --script " + quote + sJavascriptFileName + quote + _
" --log " + quote + sLogCurrentName + quote + _
" --output " + quote + sPDFoutputName + quote + _
" --input " + quote + sInputFormat + quote + _
" " + quote + sDocumentFileName + quote

Jim Albright
Wycliffe Bible Translators