Created
September 9, 2019 05:44
-
-
Save cfmitrah/d0c96f96020a4d952104a1ef65d1591a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<!--- Here I have mentioned the code for create the object for different types of barcodes ---> | |
<!--- For CODABAR ---> | |
<cfset BarcodeCodabar = createobject("java","com.lowagie.text.pdf.BarcodeCodabar")> | |
<!--- For CODE39 ---> | |
<cfset Barcode39 = createobject("java","com.lowagie.text.pdf.Barcode39")> | |
<!--- For CODE128 ---> | |
<cfset Barcode128 = createobject("java","com.lowagie.text.pdf.Barcode128")> | |
<!--- For EAN13 & EAN8 ---> | |
<cfset BarcodeEAN = createobject("java","com.lowagie.text.pdf.BarcodeEAN")> | |
<!--- Your will give the setCode is based upon the above mentioned format of barcode types ---> | |
<!--- Here I have set the code for EAN13 type barcode ---> | |
<cfset BarcodeEAN.setCode("1234567891234")> | |
<cfset color = createobject("java","java.awt.Color")> | |
<cfset image = BarcodeEAN.createAwtImage(color.black, color.white)> | |
<cfset bufferedImage = createObject("java", "java.awt.image.BufferedImage")> | |
<cfset bufferedImageType = bufferedImage.TYPE_BYTE_GRAY> | |
<cfset bufferedImage = bufferedImage.init(image.getWidth(JavaCast("null", "")),image.getHeight(JavaCast("null", "")), bufferedImageType)> | |
<cfset graphics2D = bufferedImage.createGraphics()> | |
<cfset graphics2D.drawImage(image,0,0,JavaCast("null", ""))> | |
<cfset barcodeImage = imageNew(bufferedImage)> | |
<!--- Output the code as an image ---> | |
<cfcontent type="application/PDF"> | |
<cfheader name="PdfDocument" value="attachment;filename=convertfile.pdf"> | |
<cfdocument format="PDF" overwrite="true" pagetype="A4" mimetype="text/html" saveasname="convertPdfFile.pdf"> | |
<cfimage action="writeToBrowser" source="#barcodeImage#" format="jpg"> | |
</cfdocument> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment