Board index

PCGen


IT IS ALIVE!!!

PDF page 2

Post Output Sheets, discuss Output Sheets. Everything that encompasses Output Sheets!

PDF page 2

Postby ltwally » Wed Oct 15, 2014 2:34 am

I've been encountering an odd issue with page 2 of my PDF sheets.

I created a bug for it, here: http://jira.pcgen.org/browse/OS-369

Basically, something inside PCGen is telling it to make column breaks too soon, resulting in columns that aren't the full height of the page.

I was hoping that perhaps a post here might be a good place to ask: what determines when to start a new column on page 2+ ? If it's not java code, I might not mind looking into it, myself.

Thanks
User avatar
ltwally
 
Posts: 25
Joined: Wed Oct 15, 2014 2:27 am

Re: PDF page 2

Postby LegacyKing » Wed Oct 15, 2014 2:53 am

Hi,

It's not java code. It has to do with the xslt code. That drives the page layouts. Did you open a JIRA for OS? I'm a bit slower to review those, but I do look at them and see what can be fixed. It's not my strongest language, but I can often muddle through it.

Post a screen shot or the pdf in the JIRA. I'm curious to see what you are seeing. Also, the pcg file so I can easily recreate the sheet helps.

Cheers,


Andrew Maitland
PCGen Content SB
- Data Chimp
- Quicksilver Tracker Monkey
User avatar
LegacyKing
Site Admin
 
Posts: 689
Joined: Fri Oct 11, 2013 12:35 pm
Location: California, US

Re: PDF page 2

Postby Nylanfs » Wed Oct 15, 2014 4:39 am

He posted the pcg and several pdf's to the Jira listed.


Paul "Yes that Paul" Grosse
PCGen BoD - PR Silverback
ICQ: 14397299
Forums: Nylan (or Nylanfs)
User avatar
Nylanfs
 
Posts: 348
Joined: Thu Sep 11, 2014 6:06 pm
Location: Elkhart, Indiana, United States
Top

Re: PDF page 2

Postby ltwally » Wed Oct 15, 2014 7:04 pm

LegacyKing wrote:Hi,

It's not java code. It has to do with the xslt code. That drives the page layouts. Did you open a JIRA for OS? I'm a bit slower to review those, but I do look at them and see what can be fixed. It's not my strongest language, but I can often muddle through it.

Post a screen shot or the pdf in the JIRA. I'm curious to see what you are seeing. Also, the pcg file so I can easily recreate the sheet helps.

Cheers,


I posted a link to the JIRA bug... but it didn't seem to be getting any traction, and it's a real irritation for me, so I thought I'd post here... I'm not opposed to me helping fix it. But I'm stuck trying to figure out what is determining when it needs a new column/page.

Specifically, the following file appears to be the major XSLT file for Pathfinder/D&D 3.x:
pcgen\outputsheets\d20\fantasy\pdf\fantasy_master_common_blocks.xslt

Page two kicks off with the following:
Code: Select all
<xsl:attribute name="master-reference">Portrait 2 Column</xsl:attribute>
<fo:flow flow-name="body" font-size="8pt">


I have no idea where these two items are defined. I've done searches for "master-reference", and was unable to find it. "body" is obviously far too common to simply run as a search pattern for.

But those two items are all I have to go on. From there, it launches directly into an unnamed block and then starts calling individual templates.

So, if it isn't "master-reference" or "body", or some parent item of one of them, determining when to start a new column... it pretty much has to be Java code.

But that's where I'm stuck at.

I've nearly reached the point where I'm going to hard-code my own columns, like page 1 does. But that's an enormous pain in the rear, and it doesn't fix the issue for anyone else.

Any help would be welcome.
User avatar
ltwally
 
Posts: 25
Joined: Wed Oct 15, 2014 2:27 am
Top

Re: PDF page 2

Postby LegacyKing » Thu Oct 16, 2014 12:45 am

Sorry Itwally,

My actual time free to do real coding seems to be about an hour per week between work, school and family, plus whatever I manage to sneak in during breaks at work, or when I need to get away from school work.

Portrait 2 Column is set in the master.xslt file which pulls the rest of the blocks. You have three layouts - First page has the full span header, and then the dual column appearance, but is actually single column with the blocks going row by row and across. (Confusing to fix there, but that is the layout). Page 2+ is a Double Column layout. That's the equipment, feats, abilities and everything else. Spells do not use a page layout template, and neither does the Bio-Description page.

When I have some free time, possibly tonight, I'll post the code you need to look at to work the calculations properly. I have pulled in the pcg file, and looked at the pdfs. 2 year old was keeping me from debugging anything though.

Cheers,


Andrew Maitland
PCGen Content SB
- Data Chimp
- Quicksilver Tracker Monkey
User avatar
LegacyKing
Site Admin
 
Posts: 689
Joined: Fri Oct 11, 2013 12:35 pm
Location: California, US
Top

Re: PDF page 2

Postby ltwally » Thu Oct 16, 2014 3:39 am

LegacyKing wrote:Sorry Itwally,


No needs to apologize. PCGen is free, and pretty dang good.

My actual time free to do real coding seems to be about an hour per week between work, school and family, plus whatever I manage to sneak in during breaks at work, or when I need to get away from school work.


Again, I understand completely. Finding people with time is always the bane of OSS.

Portrait 2 Column is set in the master.xslt file which pulls the rest of the blocks. You have three layouts - First page has the full span header, and then the dual column appearance, but is actually single column with the blocks going row by row and across. (Confusing to fix there, but that is the layout). Page 2+ is a Double Column layout. That's the equipment, feats, abilities and everything else. Spells do not use a page layout template, and neither does the Bio-Description page.

When I have some free time, possibly tonight, I'll post the code you need to look at to work the calculations properly. I have pulled in the pcg file, and looked at the pdfs. 2 year old was keeping me from debugging anything though.

Cheers,



Inside fantasy_master_common_blocks.xlst, I see this:
Code: Select all
            <fo:simple-page-master master-name="Portrait 2 Column">
               <xsl:attribute name="page-height"><xsl:value-of select="$pageHeight" />mm</xsl:attribute>
               <xsl:attribute name="page-width"><xsl:value-of select="$pageWidth" />mm</xsl:attribute>
               <xsl:attribute name="margin-top"><xsl:value-of select="$pageMarginTop" />mm</xsl:attribute>
               <xsl:attribute name="margin-bottom"><xsl:value-of select="$pageMarginBottom" />mm</xsl:attribute>
               <xsl:attribute name="margin-left"><xsl:value-of select="$pageMarginLeft" />mm</xsl:attribute>
               <xsl:attribute name="margin-right"><xsl:value-of select="$pageMarginRight" />mm</xsl:attribute>
               <fo:region-body region-name="body" column-count="2" column-gap="2mm" margin-bottom="0"/>
               <fo:region-after region-name="footer" extent="0"/>
            </fo:simple-page-master>


However -- and perhaps I'm just a complete noob, here -- I am not seeing anything that actually determines when to start a new column. Is $pageHeight all that is used to determine that? If so -- what uses that variable to start a new column? I'm unable to find anything in the XSLT that is tracking the column height and says "ok time to start a new column / page".
User avatar
ltwally
 
Posts: 25
Joined: Wed Oct 15, 2014 2:27 am
Top

Re: PDF page 2

Postby LegacyKing » Thu Oct 16, 2014 5:07 am

Close but you need to look further up. $name is a Variable to the sheet,

Code: Select all
   <xsl:variable name="vAttribs_tree">
      <myAttribs:myAttribs>
         <xsl:copy-of select="$vAttribs/*"/>
      </myAttribs:myAttribs>
   </xsl:variable>
   <xsl:variable name="vAttribs_all" select="xalan:nodeset($vAttribs_tree)"/>
   <xsl:variable name="pageHeight">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/height, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/height, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/height, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/height, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/height, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/height, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:choose>
               <xsl:when test="contains(/character/export/paperinfo/name, 'Letter')">
                  <xsl:value-of select="25.4 * 11.0"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="297"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <xsl:variable name="pageWidth">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/width, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/width, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/width, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/width, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/width, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/width, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:choose>
               <xsl:when test="contains(/character/export/paperinfo/name, 'Letter')">
                  <xsl:value-of select="25.4 * 8.5"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="210"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <xsl:variable name="pageMarginTop">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/margins/top, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/margins/top, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/top, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/margins/top, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/top, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/margins/top, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="10"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <xsl:variable name="pageMarginBottom">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/margins/bottom, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/margins/bottom, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/bottom, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/margins/bottom, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/bottom, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/margins/bottom, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="10"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <xsl:variable name="pageMarginLeft">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/margins/left, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/margins/left, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/left, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/margins/left, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/left, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/margins/left, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="10"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <xsl:variable name="pageMarginRight">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/margins/right, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/margins/right, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/right, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/margins/right, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/margins/right, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/margins/right, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="10"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <xsl:variable name="pagePrintableWidth">
      <xsl:value-of select="($pageWidth - $pageMarginLeft - $pageMarginRight)"/>
   </xsl:variable>
   <xsl:variable name="pagePrintableHeight">
      <xsl:value-of select="($pageHeight - $pageMarginTop - $pageMarginBottom)"/>
   </xsl:variable>
   <xsl:variable name="skillmastery">
      <xsl:for-each select="/character/special_qualities/special_quality">
         <xsl:if test="substring(name,1,13)='Skill Mastery'">
            <xsl:value-of select="associated"/>
         </xsl:if>
      </xsl:for-each>
   </xsl:variable>


   <!-- Include all of the output attributes -->
   <!-- vAttribs will be set up in the stylesheet that calls this one -->
   <xsl:template name="attrib">
      <xsl:param name="attribute"/>
      <xsl:copy-of select="$vAttribs_all/*/*[name() = $attribute]/@*"/>
      <xsl:for-each select="$vAttribs_all/*/*[name() = $attribute]/subattrib/@*">
         <xsl:variable name="bar" select="name()"/>
         <xsl:call-template name="attrib">
            <xsl:with-param name="attribute" select="$bar"/>
         </xsl:call-template>
      </xsl:for-each>
   </xsl:template>

   <xsl:template name="page.layouts">
         <!--   PAGE DEFINITIONS   -->
         <fo:layout-master-set>
            <fo:simple-page-master master-name="Portrait 2 Column">
               <xsl:attribute name="page-height"><xsl:value-of select="$pageHeight" />mm</xsl:attribute>
               <xsl:attribute name="page-width"><xsl:value-of select="$pageWidth" />mm</xsl:attribute>
               <xsl:attribute name="margin-top"><xsl:value-of select="$pageMarginTop" />mm</xsl:attribute>
               <xsl:attribute name="margin-bottom"><xsl:value-of select="$pageMarginBottom" />mm</xsl:attribute>
               <xsl:attribute name="margin-left"><xsl:value-of select="$pageMarginLeft" />mm</xsl:attribute>
               <xsl:attribute name="margin-right"><xsl:value-of select="$pageMarginRight" />mm</xsl:attribute>
               <fo:region-body region-name="body" column-count="2" column-gap="2mm" margin-bottom="7mm"/>
               <fo:region-after region-name="footer" extent="4.4mm"/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="Portrait">
               <xsl:attribute name="page-height"><xsl:value-of select="$pageHeight" />mm</xsl:attribute>
               <xsl:attribute name="page-width"><xsl:value-of select="$pageWidth" />mm</xsl:attribute>
               <xsl:attribute name="margin-top"><xsl:value-of select="$pageMarginTop" />mm</xsl:attribute>
               <xsl:attribute name="margin-bottom"><xsl:value-of select="$pageMarginBottom" />mm</xsl:attribute>
               <xsl:attribute name="margin-left"><xsl:value-of select="$pageMarginLeft" />mm</xsl:attribute>
               <xsl:attribute name="margin-right"><xsl:value-of select="$pageMarginRight" />mm</xsl:attribute>
               <fo:region-body region-name="body" margin-bottom="7mm"/>
               <fo:region-after region-name="footer" extent="4.4mm"/>
            </fo:simple-page-master>
   
      </fo:layout-master-set>
   </xsl:template>


PageHeight is controlled by:

Code: Select all
   <xsl:variable name="pageHeight">
      <xsl:choose>
         <xsl:when test="contains(/character/export/paperinfo/height, 'in')">
            <xsl:value-of select="25.4 * substring-before(/character/export/paperinfo/height, 'in')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/height, 'cm')">
            <xsl:value-of select="10 * substring-before(/character/export/paperinfo/height, 'cm')"/>
         </xsl:when>
         <xsl:when test="contains(/character/export/paperinfo/height, 'mm')">
            <xsl:value-of select="substring-before(/character/export/paperinfo/height, 'mm')"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:choose>
               <xsl:when test="contains(/character/export/paperinfo/name, 'Letter')">
                  <xsl:value-of select="25.4 * 11.0"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="297"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>


You select your paper type, it alters the values. The first section is selecting pcgen export values for in, mm or cm. If those are missing, then it has two fallback positions to determine those values - Letter = '25.4 * 11.0' vs everything else = 297.

Those values are stored in the variable and then supplied to the later calculations throughout the sheet. And in case that is confusing, you also need to look at base.xml.ftl which is what I mean by pcgen supplying those values.

Code: Select all
      <paperinfo>
         <name>${pcstring('PAPERINFO.NAME')}</name>
         <height>${pcstring('PAPERINFO.HEIGHT')}</height>
         <width>${pcstring('PAPERINFO.WIDTH')}</width>
         <margins>
            <top>${pcstring('PAPERINFO.MARGINTOP')}</top>
            <bottom>${pcstring('PAPERINFO.MARGINBOTTOM')}</bottom>
            <left>${pcstring('PAPERINFO.MARGINLEFT')}</left>
            <right>${pcstring('PAPERINFO.MARGINRIGHT')}</right>
         </margins>
      </paperinfo>


Hope that helps... the 2 year old is wanting attention.


Andrew Maitland
PCGen Content SB
- Data Chimp
- Quicksilver Tracker Monkey
User avatar
LegacyKing
Site Admin
 
Posts: 689
Joined: Fri Oct 11, 2013 12:35 pm
Location: California, US
Top

Re: PDF page 2

Postby ltwally » Thu Oct 16, 2014 5:44 pm

Andrew,

Thanks. Yes, I did see all that... but what I do not see is the line of code that says, "hey, this thing is now taller than the $pageHeight and we need to start a new column or page." That is the piece of code I'm not seeing -- and that is the piece of code that I believe is broken.

I have also looked at base.xml and base.xml.ftl... again, I'm not seeing the code that says "hey, this thing is too tall, let's start a new column".
User avatar
ltwally
 
Posts: 25
Joined: Wed Oct 15, 2014 2:27 am
Top

Re: PDF page 2

Postby LegacyKing » Fri Oct 17, 2014 2:57 am

base.xml.ftl is the file, if you have a base.xml still, then ignore it. PCGen 6.4+ will use the ftl file. (which is the freemarker template version)

The Base file is only for giving nodes and values from pcgen to the xslt files. We can do fancy things in it, like loops, and omit objects based upon criteria. We can also force a gamemode to ignore the default base.xml file and use one specifically designed for the game system if we want to. However, the actual pdf manipulation is all contained in the xslt file - think of base as a database holding information, the xslt is what directly takes that information and places it in a defined manner. xlst controls all aspects of the sheet, dimensions, blocks, titles, and more.

Now, if there is code that says begin new, I don't know. Likely in the FOP or FO conversion process, which is above and beyond my capabilities. All I do know is that the height, width and margin values are calculated with the above code blocks. What appears to be happening is some of the values need to be updated or what is output is causing a value deception. The feats lacking a DESC w/ BENEFIT appeared to be a possible culprit here.


Andrew Maitland
PCGen Content SB
- Data Chimp
- Quicksilver Tracker Monkey
User avatar
LegacyKing
Site Admin
 
Posts: 689
Joined: Fri Oct 11, 2013 12:35 pm
Location: California, US
Top

Re: PDF page 2

Postby ltwally » Fri Oct 17, 2014 3:31 am

Andrew,

The issue I've been having isn't that the page height is wrong, it's that page 2 is triggering new columns too early. So, I'm expecting that the problem is with the code that determines when a new column gets triggered. That's what I'm trying to find... I'm pretty sure it's not in the fantasy_master_common_blocks.xlst or base.xml.ftl...
User avatar
ltwally
 
Posts: 25
Joined: Wed Oct 15, 2014 2:27 am
Top

Re: PDF page 2

Postby LegacyKing » Sun Oct 19, 2014 3:58 pm

Fun trying to keep the conversations from two different sources together. I flagged James and asked him to take a look. We're also having issues with Prepared Spells for half-casters - paladins and rangers.


Andrew Maitland
PCGen Content SB
- Data Chimp
- Quicksilver Tracker Monkey
User avatar
LegacyKing
Site Admin
 
Posts: 689
Joined: Fri Oct 11, 2013 12:35 pm
Location: California, US
Top

Re: PDF page 2

Postby ltwally » Tue Oct 21, 2014 1:33 am

I would definitely appreciate any further help with this that I can get. I downloaded a fresh copy of PCGen 6.0.4 on an older workstation that I no longer use. It has Java 7u25. Same issue.

I'm almost to the point where I'd craft my own output sheet that hard-codes Page 2... but that's a lot of effort, and it doesn't fix the underlying bug. There's definitely something odd going on with PCGen.
User avatar
ltwally
 
Posts: 25
Joined: Wed Oct 15, 2014 2:27 am
Top

Re: PDF page 2

Postby LegacyKing » Wed Oct 22, 2014 6:34 am

I have at least one person who has signed on and is interested in helping with OS sheets. I might be able to direct them towards fixing this bug.


Andrew Maitland
PCGen Content SB
- Data Chimp
- Quicksilver Tracker Monkey
User avatar
LegacyKing
Site Admin
 
Posts: 689
Joined: Fri Oct 11, 2013 12:35 pm
Location: California, US
Top


Return to Output Sheets

Who is online

Users browsing this forum: No registered users and 1 guest