Skip to main content
Participant
October 4, 2018
Question

Coldfusion 9 - cfdocument fails to render the barcode (code 128) font as expected.

  • October 4, 2018
  • 1 reply
  • 681 views

Hi,

Trying to render the html code to PDF. I am having a hard time to figure out a way to render bar-code font using cfdocument.

- Tried installing the bar-code in local machine, didn't work

- Tried copying the font files to docker Image, didn't work

- Used @11220649-face in style, still didn't work

None of those are working . Appreciate it, If anyone can jump in for a help.

Thanks

Vishnu

<cfdocument

            format="PDF"

            pageType = "custom"

            pageHeight = "3"

            pageWidth = "4"

            margintop="0"

            marginright="0"

            marginleft="0"

            marginbottom="0"

            overwrite="yes"

            name="pdffile"

            fontembed="yes"

            localUrl = yes >

            <cfoutput>

               

                <style type="text/css">

                  

               @11220649-face {

                         font-family: "Code128AB";

                         src: url("#expandPath('./fonts/')#Bc128ab.eot"); /* IE9 Compat Modes */

                         src: url("#expandPath('./fonts/')#Bc128ab.eot?##iefix") format("embedded-opentype"), /* IE6-IE8 */

                                url("./fonts/Bc128ab.otf") format("opentype"), /* Open Type Font */

                                url("#expandPath('./fonts/')#Bc128ab.svg") format("svg"), /* Legacy iOS */

                                url("#expandPath('./fonts/')#Bc128ab.ttf") format("truetype"), /* Safari, Android, iOS */

                                url("#expandPath('./fonts/')#Bc128ab.woff") format("woff"), /* Modern Browsers */

                                url("#expandPath('./fonts/')#Bc128ab.woff2") format("woff2"); /* Modern Browsers */

                                font-weight: normal;

                                font-style: normal;

                    }

                    .barcode    {

                        font-family: "Code 128AB";

                        font-size: 35px;

                        margin-top: 10px;

                        line-height:10px;

                        padding: 2px;

                        margin: 2px;

                        text-align: left;

                    }

               

                   

                </style>

                <html>

                    <body> 

                   

                        <div class="barcode">|ax10KE-xL~</div>

                               

                    </body>


                </html>    

            </cfoutput>        

        </cfdocument>


        <cfcontent type="application/pdf" variable="#pdffile#">

This topic has been closed for replies.

1 reply

Inspiring
October 5, 2018

Assuming a Windows platform, install the barcode TTF font on the server.   CF doesn't play nice with OTF fonts in my experience.

Restart CF and that TTF font should then appear in the CF Admin settings > Fonts section.  

The @font-face section in your CSS with the URL/expand-paths shouldn't be necessary.   Keep in mind CF is rendering this document on the server, and CF9's "internal browser" doesn't have all the CSS bells and whistles of the latest browser versions.  The simple style declaration should be enough to get it done.  

.barcode    {

                        font-family: "Code 128AB";

}

<div class="barcode">123456</div>

vinnu543Author
Participant
October 10, 2018

I am using Docker, so already tried loading fonts into the container, it didn't work. We are planning tackle it by "wkhtmltopdf".  Thanks for your time, paule12345.