{"id":1740,"date":"2016-11-29T23:14:54","date_gmt":"2016-11-29T23:14:54","guid":{"rendered":"http:\/\/blog.paranoidprofessor.com\/?p=1740"},"modified":"2016-12-06T22:14:32","modified_gmt":"2016-12-06T22:14:32","slug":"machine-generation-of-pdf-files-the-easy-way-part-iv","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2016\/11\/29\/machine-generation-of-pdf-files-the-easy-way-part-iv\/","title":{"rendered":"Machine generation of PDF files the easy way &#8211; part IV"},"content":{"rendered":"<p>This fourth example will extend upon my <a href=\"http:\/\/blog.paranoidprofessor.com\/index.php\/2016\/11\/24\/machine-generation-of-pdf-files-the-easy-way-part-iii\/\">previous<\/a> XSL-FO script to convert the list from a table with a few boxes into more of a polished form. The final result will generate a form and will look like this.<\/p>\n<p><a href=\"http:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/11\/data4.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-1793 size-full\" src=\"http:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/11\/data4.png\" alt=\"data4\" width=\"789\" height=\"380\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/11\/data4.png 789w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/11\/data4-300x144.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/11\/data4-768x370.png 768w\" sizes=\"(max-width: 789px) 100vw, 789px\" \/><\/a>You are only really limited to your imagination for a lot of XSL-FO. It is possible to change how the pages are laid out, types of headers, types of footers, orientation of the pages, various margins, add additional fonts or even add graphics.<\/p>\n<p>One of the small things that really makes forms look like forms is the ability to put a small description in each of the cells. If the form is machine printed it will look good but if the form is for the user to fill in, it is a necessary description.<\/p>\n<p>The only change is to add these small descriptions for each cell of this form. Conceptually, what you do is to have a table within each cell where the description is very small text and the field value is a normal sized text.<\/p>\n<p>This isn&#8217;t the only way to achieve this result but to add this to an existing form is fairly mechanical in nature. This method causes all of the descriptions to look the same and be located the same spot in each cell.<\/p>\n<p>You could fool around with fonts and sizes but getting things to line up the way you want without using an inner table would be challenging.<\/p>\n<h3><strong>Simple cell<\/strong><\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;xsl:template match=&quot;person&quot;&gt;\r\n    &lt;fo:table-row &gt;\r\n       &lt;fo:table-cell font-weight=&quot;bold&quot; border-collapse=&quot;collapse&quot; border-style=&quot;solid&quot; border-width=&quot;.1mm&quot; text-align=&quot;left&quot; padding=&quot;1mm&quot; &gt;\r\n           &lt;fo:block&gt;\r\n           &lt;xsl:value-of select=&quot;first&quot;\/&gt;\r\n           &lt;xsl:value-of select=&quot;last&quot;\/&gt;\r\n           &lt;\/fo:block&gt;\r\n       &lt;\/fo:table-cell &gt;\r\n       &lt;fo:table-cell&gt;  \r\n\r\n           ...\r\n           second cell left off for clarity\r\n\r\n       &lt;\/fo:table-cell&gt;\r\n    &lt;\/fo:table-row &gt;\r\n&lt;\/xsl:template&gt;\r\n<\/pre>\n<h3><strong>Cell with description<\/strong><\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;xsl:template match=&quot;person&quot;&gt;\r\n    &lt;fo:table-row &gt;\r\n       &lt;fo:table-cell border-collapse=&quot;collapse&quot; border-style=&quot;solid&quot; border-width=&quot;.1mm&quot; text-align=&quot;left&quot; padding=&quot;1mm&quot; &gt;\r\n\r\n           &lt;fo:block font-family=&quot;Helvetica&quot; font-size=&quot;10pt&quot; &gt;\r\n            &lt;fo:table table-layout=&quot;fixed&quot; width=&quot;100%&quot; &gt;\r\n              &lt;fo:table-column column-width=&quot;proportional-column-width(100)&quot; \/&gt;\r\n              &lt;fo:table-body&gt;\r\n                  &lt;fo:table-row&gt;\r\n                    &lt;fo:table-cell &gt;\r\n\r\n                        &lt;fo:block font-family=&quot;Courier&quot; font-weight=&quot;bold&quot; font-size=&quot;6pt&quot; &gt; Name\r\n                        &lt;\/fo:block&gt;\r\n\r\n                    &lt;\/fo:table-cell&gt;\r\n                  &lt;\/fo:table-row&gt;\r\n\r\n                  &lt;fo:table-row&gt;\r\n                    &lt;fo:table-cell &gt;\r\n\r\n                        &lt;fo:block&gt;\r\n                        &lt;xsl:value-of select=&quot;first&quot;\/&gt;\r\n                        &lt;xsl:value-of select=&quot;last&quot;\/&gt;\r\n                        &lt;\/fo:block&gt;\r\n\r\n                    &lt;\/fo:table-cell&gt;\r\n                  &lt;\/fo:table-row&gt;\r\n              &lt;\/fo:table-body&gt;\r\n            &lt;\/fo:table&gt;\r\n           &lt;\/fo:block&gt;\r\n\r\n       &lt;\/fo:table-cell &gt;\r\n       &lt;fo:table-cell border-collapse=&quot;collapse&quot; border-style=&quot;solid&quot; border-width=&quot;.1mm&quot; text-align=&quot;left&quot; padding=&quot;1mm&quot; &gt;\r\n\r\n           ...\r\n           second cell left off for clarity\r\n\r\n       &lt;\/fo:table-cell &gt;\r\n    &lt;\/fo:table-row &gt;\r\n&lt;\/xsl:template&gt;\r\n\r\n<\/pre>\n<p>There is virtually really no changes over the cell with border that was added in the previous\u00a0step. Well one tiny attribute change. The attribute padding was added to to put a very tiny space between the values provided and the edges of their cell. Simply put adding padding=&#8221;.1mm&#8221; adds a .1mm margin around the innermost cell.<\/p>\n<p>Adding niceties of this type do make for a polished product but the users cannot appreciate the effort put in. It will be quite visible when maintaining the xslt code.<\/p>\n<p>&nbsp;<\/p>\n<p>Download source and pdf for this example<\/p>\n<div class=\"\"><a href=\"http:\/\/blog.paranoidprofessor.com\/wp-content\/downloads\/fop-data4.zip\" target=\"_self\" class=\"emd_dl_blue\">Download files<\/a><\/div>        <style type=\"text\/css\">\r\n    .emd_dl_blue {\r\n        -moz-box-shadow:inset 0px 1px 0px 0px #bbdaf7;\r\n        -webkit-box-shadow:inset 0px 1px 0px 0px #bbdaf7;\r\n        box-shadow:inset 0px 1px 0px 0px #bbdaf7;\r\n        background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5) );\r\n        background:-moz-linear-gradient( center top, #79bbff 5%, #378de5 100% );\r\n        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5');\r\n        background-color:#79bbff;\r\n        -webkit-border-top-left-radius:0px;\r\n        -moz-border-radius-topleft:0px;\r\n        border-top-left-radius:0px;\r\n        -webkit-border-top-right-radius:0px;\r\n        -moz-border-radius-topright:0px;\r\n        border-top-right-radius:0px;\r\n        -webkit-border-bottom-right-radius:0px;\r\n        -moz-border-radius-bottomright:0px;\r\n        border-bottom-right-radius:0px;\r\n        -webkit-border-bottom-left-radius:0px;\r\n        -moz-border-radius-bottomleft:0px;\r\n        border-bottom-left-radius:0px;\r\n        text-indent:0;\r\n        border:1px solid #84bbf3;\r\n        display:inline-block;\r\n        color:#ffffff !important;\r\n        font-family:Georgia;\r\n        font-size:15px;\r\n        font-weight:bold;\r\n        font-style:normal;\r\n        height:41px;\r\n        line-height:41px;\r\n        width:153px;\r\n        text-decoration:none;\r\n        text-align:center;\r\n        text-shadow:1px 1px 0px #528ecc;\r\n    }\r\n    .emd_dl_blue:hover {\r\n        background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff) );\r\n        background:-moz-linear-gradient( center top, #378de5 5%, #79bbff 100% );\r\n        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff');\r\n        background-color:#378de5;\r\n    }.emd_dl_blue:active {\r\n        position:relative;\r\n        top:1px;\r\n    }\r\n    <\/style>\n<p>The next set of changes for this can be found in <a href=\"http:\/\/blog.paranoidprofessor.com\/index.php\/2016\/12\/06\/machine-generation-of-pdf-files-the-easy-way-part-v\/\">part V<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This fourth example will extend upon my previous XSL-FO script to convert the list from a table with a few boxes into more of a polished form. The final result will generate a form and will look like this. You &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2016\/11\/29\/machine-generation-of-pdf-files-the-easy-way-part-iv\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[73,81,78,82],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1740"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1740"}],"version-history":[{"count":6,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1740\/revisions"}],"predecessor-version":[{"id":1829,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1740\/revisions\/1829"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}