Jump to content

The problem with using BarcodeJ4.jar ScriptMaster> 4?


This topic is 4684 days old. Please don't post here. Open a new topic instead.

Recommended Posts

IMac OSX 10.4.11 + FileMaker Pro Advanced 10 + free 360Works ScriptMaster fmplugin > V4 ( V4.0 to 4.122)

can not get the correct result with BarcodeJ4.jar.

When I install version < V4 ScriptMaster (3.34) - BarcodeJ4.jar (V 2.0. or V2.1) works correctly.

Is it possible to fix it in the next update SriptMaster?

Ino

Link to comment
Share on other sites

What is not working for you? Can you post your log along with a description of what is happening and what you expect to happen?

Smef Pls see,

I hope it will help:

screenshot_ScriptMaster Modules.png screenshot_OK_SM plugIn_3.34.png screenshot_Looks like..SM plugIn_4-122.png screenshot_java long_SM plugIn_4-122.png

attachment=15847:result-Test.rtf]

Message with ScriptMaster v4.122:

java.lang.NullPointerException

Parameters:

{barcode_contents=312345678}

---Script---

Script:

/*

* Copyright 2004 Jeremias Maerki.

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.FileOutputStream;

import java.io.OutputStream;

import org.krysalis.barcode4j.impl.code39.Code39Bean;

import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;

import org.krysalis.barcode4j.tools.UnitConv;

/**

* This example demonstrates creating a bitmap barcode using the bean API.

*

* @author Jeremias Maerki

* @version $Id: SampleB...

Code39 barcode ... script:

/*

* Copyright 2004 Jeremias Maerki.

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.FileOutputStream;

import java.io.OutputStream;

import org.krysalis.barcode4j.impl.code39.Code39Bean;

import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;

import org.krysalis.barcode4j.tools.UnitConv;

/**

* This example demonstrates creating a bitmap barcode using the bean API.

*

* @author Jeremias Maerki

* @version $Id: SampleBitmapBarcodeWithBean.java,v 1.2 2006/11/07 16:45:28 jmaerki Exp $

*/

try {

//Create the barcode bean

Code39Bean bean = new Code39Bean();

final int dpi = 150;

//Configure the barcode generator

bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar

//width exactly one pixel

bean.setWideFactor(3);

bean.doQuietZone(false);

String tempdir = System.getProperty("java.io.tmpdir");

if ( !(tempdir.endsWith("/") || tempdir.endsWith("\\")) )

tempdir = tempdir + System.getProperty("file.separator");

//Open output file

File outputFile = new File(tempdir + "bcode.jpg");

OutputStream out = new FileOutputStream(outputFile);

try {

//Set up the canvas provider for monochrome JPEG output

BitmapCanvasProvider canvas = new BitmapCanvasProvider(

out, "image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);

//Generate the barcode

bean.generateBarcode(canvas, barcode_contents);

//Signal end of generation

canvas.finish();

} finally {

out.close();

File f = new File( tempdir + "bcode.jpg" );

fileExists = f.exists();

return f;

}

} catch (Exception e) {

return e;

}

Thaneke you

Ino

[

CODE39_Barcode_Example_script.rtf

result-Test.rtf

Link to comment
Share on other sites

  • 3 weeks later...

We looked into this and there was some part of the jar that was not compatible with the updated version of groovy that is included with scriptmaster 4. ScriptMaster 3 used an older version of groovy.

I think users have posted a few other ways to do barcodes, such as http://fmforums.com/forum/topic/73810-barcode-generator/. There are a couple of newer posts as well that I'm sure you can find with a search.

Link to comment
Share on other sites

Hi David and thanks for reply.

I got a file with scripts from Aleksander today that is working for him in SM3

Somehow I found a modified version of the Code39 script that worked with SM4.

It seems that the original script was creating a file, that were saved to tmp dir.

The modified script seems to generate "on the fly".

I took the modified script and created some versions of different barcode types.

However, while the barcode does generate without error, I am suspecting that it is generating barcodes which can not be read..... did some testing on the screen with my iPhone and various free barcode readers. They did read other barcodes, but did not any of my generated....

I know you are expert on those scripts, maybe you could see if it needs some tweeking ?

I am attaching the basic Code39 script as a file....

Get the Barcode4j.jar file here: http://barcode4j.sourceforge.net/download.html

code39_script.txt

Link to comment
Share on other sites

To anyone who would like to implement barcode creation, here is what is working using latest version of SM.

After fiddling around the last few days, I accomplished to make this work :D

Long story short; some of the scripts here on fmforum had the approach of creating the barcode and save it to a tmp folder on the computer. This seems to not work with latest groove in SM.

The approach in the script below is to "stream" the barcode directly to the container field.

Take a look at BarcodeJ4 website for list of possibly variations and to download the BarcodeJ4.jar file. (note that you get a whole package with files from the download but only need the BarcodeJ4.jar)

http://barcode4j.sourceforge.net/

Note to 360works: Feel free to incorporate these barcode scripts in future versions of SM.

The script below is Datamatrix. However, it is quite easy to modify for other types.

Change 1 line and 2 words:

Find the line:

import org.krysalis.barcode4j.impl.datamatrix.DataMatrixBean;

and replace with one of these:

org.krysalis.barcode4j.impl.codabar.CodabarBean

org.krysalis.barcode4j.impl.code128.Code128Bean

org.krysalis.barcode4j.impl.code39.Code39Bean

org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5Bean

org.krysalis.barcode4j.impl.postnet.POSTNETBean

org.krysalis.barcode4j.impl.upcean.EAN13Bean

org.krysalis.barcode4j.impl.upcean.EAN8Bean

org.krysalis.barcode4j.impl.upcean.UPCABean

org.krysalis.barcode4j.impl.upcean.UPCEBean

Then modify this line:

DataMatrixBean bean = new DataMatrixBean()

The bold words should be changed to the type and you can see the word as it is the last word of the lines above.

Remember to create the variables: barcode_contents - dpi - pixels

For me it works best with dpi= 100 or 150 and pixels = 1

Remember that some barcode types has restrictions for content. See more on BarcodeJ4 website.

/**

* This script is created by Jeremis Maerki

* Modified by Claus Lavendt - [email protected]

* Variables: barcode_contents - dpi - pixels

* Try vary the dpi and pixels

*/

import java.awt.image.BufferedImage

import java.io.File

import java.io.FileOutputStream

import java.io.OutputStream

import org.krysalis.barcode4j.impl.datamatrix.DataMatrixBean;

import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider

import org.krysalis.barcode4j.tools.UnitConv

import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider

import java.awt.*

import java.awt.image.*

import org.krysalis.barcode4j.impl.AbstractBarcodeBean

import org.krysalis.barcode4j.output.bitmap.BitmapBuilder

String msg = barcode_contents

DataMatrixBean bean = new DataMatrixBean()

int resolution = Integer.parseInt(dpi) //dpi

int orientation = 0

int pixelsPerModule = Integer.parseInt(pixels) //make one module = one pixel

bean.setModuleWidth(pixelsPerModule * 25.4 / resolution)

dim = bean.calcDimensions(msg)

BufferedImage image = BitmapBuilder.prepareImage(dim, orientation,

resolution, BufferedImage.TYPE_BYTE_BINARY)

Graphics2D g2d = BitmapBuilder.prepareGraphics2D(image, dim, orientation, false)

Java2DCanvasProvider canvas = new Java2DCanvasProvider(g2d, orientation)

bean.generateBarcode(canvas, msg)

g2d.dispose()

return image

//Encode the BufferedImage as a PNG file

//ImageIO.write(image, "png", new File("D:/out.png"))

Link to comment
Share on other sites

  • 1 month later...
  • Newbies

Hi Claus,

Good job for this post!

Could you share an example or demo of your implementation of the BarcodeJ4 with your solution?

I think it will be useful for some of us.

Thank you. ;)

--

Edu Croissier

AS

To anyone who would like to implement barcode creation, here is what is working using latest version of SM.

After fiddling around the last few days, I accomplished to make this work :D

Long story short; some of the scripts here on fmforum had the approach of creating the barcode and save it to a tmp folder on the computer. This seems to not work with latest groove in SM.

The approach in the script below is to "stream" the barcode directly to the container field.

Take a look at BarcodeJ4 website for list of possibly variations and to download the BarcodeJ4.jar file. (note that you get a whole package with files from the download but only need the BarcodeJ4.jar)

http://barcode4j.sourceforge.net/

Note to 360works: Feel free to incorporate these barcode scripts in future versions of SM.

The script below is Datamatrix. However, it is quite easy to modify for other types.

Change 1 line and 2 words:

Find the line:

import org.krysalis.barcode4j.impl.datamatrix.DataMatrixBean;

and replace with one of these:

org.krysalis.barcode4j.impl.codabar.CodabarBean

org.krysalis.barcode4j.impl.code128.Code128Bean

org.krysalis.barcode4j.impl.code39.Code39Bean

org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5Bean

org.krysalis.barcode4j.impl.postnet.POSTNETBean

org.krysalis.barcode4j.impl.upcean.EAN13Bean

org.krysalis.barcode4j.impl.upcean.EAN8Bean

org.krysalis.barcode4j.impl.upcean.UPCABean

org.krysalis.barcode4j.impl.upcean.UPCEBean

Then modify this line:

DataMatrixBean bean = new DataMatrixBean()

The bold words should be changed to the type and you can see the word as it is the last word of the lines above.

Remember to create the variables: barcode_contents - dpi - pixels

For me it works best with dpi= 100 or 150 and pixels = 1

Remember that some barcode types has restrictions for content. See more on BarcodeJ4 website.

/**

* This script is created by Jeremis Maerki

* Modified by Claus Lavendt - [email protected]

* Variables: barcode_contents - dpi - pixels

* Try vary the dpi and pixels

*/

import java.awt.image.BufferedImage

import java.io.File

import java.io.FileOutputStream

import java.io.OutputStream

import org.krysalis.barcode4j.impl.datamatrix.DataMatrixBean;

import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider

import org.krysalis.barcode4j.tools.UnitConv

import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider

import java.awt.*

import java.awt.image.*

import org.krysalis.barcode4j.impl.AbstractBarcodeBean

import org.krysalis.barcode4j.output.bitmap.BitmapBuilder

String msg = barcode_contents

DataMatrixBean bean = new DataMatrixBean()

int resolution = Integer.parseInt(dpi) //dpi

int orientation = 0

int pixelsPerModule = Integer.parseInt(pixels) //make one module = one pixel

bean.setModuleWidth(pixelsPerModule * 25.4 / resolution)

dim = bean.calcDimensions(msg)

BufferedImage image = BitmapBuilder.prepareImage(dim, orientation,

resolution, BufferedImage.TYPE_BYTE_BINARY)

Graphics2D g2d = BitmapBuilder.prepareGraphics2D(image, dim, orientation, false)

Java2DCanvasProvider canvas = new Java2DCanvasProvider(g2d, orientation)

bean.generateBarcode(canvas, msg)

g2d.dispose()

return image

//Encode the BufferedImage as a PNG file

//ImageIO.write(image, "png", new File("D:/out.png"))

Link to comment
Share on other sites

This topic is 4684 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.