B4J Tutorial ? Printing on A4 and Letter sized paper

Hello all,
As the title say, this is a quick tutorial on how to print on A4 or Letter sized paper using the follow information provided by Steve Laming (better known as @stevel05).

CLICK HERE for B4J Print JavaFX 8

I have attached two PDF files showing example printouts for both A4 and letter sized paper. It's actually extremely easy to adjust the layouts for any size paper so just give it a go, I've also attached the example project I created just for this post.

A4 is the main paper size used in the UK, I believe Letter size is mainly used in the US (but I could be wrong). In the UK lots for firms with warehouses use Letter sized paper for business to business with carbon copy paper sheets when delivery stock, the delivery driver keep a copy, so does the firm receiving the goods.

Anyway, what tutorial you are thinking, I've just been banging on about nothing interesting. Well you are learning from the attached source code and by looking at the screenshots and PDF files, it's that simple really ;)

I used Scene Builder but I would highly recommend that you use the B4J native built-in designer, you will get the exact same results.

Layout preview/design in Scene Builder
A4Preview.png


Layout outline/design in Scene Builder
A4Outline.png


Enjoy...
 

Attachments

  • Pint on A4.pdf
    51.2 KB · Views: 1,066
  • Print on Letter.pdf
    49.9 KB · Views: 816
  • PrintA4Letter.zip
    69 KB · Views: 1,195
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
Hmm, now how did I know that question was going to arise, I should put some money on the lottery this weekend lol.

One question though, why have you used the Scene Builder and not the B4J Visual Designer?

Okay, there's no actual reason whatsoever.
The example created by Steve was using SB, as I know how to use SB I just created the layouts using SB even though using the built-in native designer was an option too. I just did it, why, I have no idea, I just did?

It was only afterwards I though to myself that I could and should have used the native built-in designer, but by that time I only had about 2 days left to finish the project and there's no harm in using SB, it will not kill the app so I just rolled with it.

You will get the same results using the native built-in designer even though I personally didn't use it, I just didn't, I should have, but I didn't ;)
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
After thinking about it for a while, I now know and realised why I didn't use the native designer @inakigarm.

I originally found Steve's example which used SB, straight away I started to modify and figure out both A4 and Letter paper sizes still using Steve's original B4J project which was using SB, I was modifying Steve's original layout. Once I had figured out the two paper sizes (layouts) by printing PDF files as proof of concept (which took about 15 minutes), I just saved the two files and imported them directly into the B4J project that I was working on, thus I used SB instead of native designer.
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
Is possible run this in linux server with cups?

What you mean with Common UNIX Printing System?

Dunno, maybe, maybe not, I don't really know.
I've only tested my print server solution on a PC and a Mac, both ran absolutely perfect...
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
ts possible run this in linux server with cups?
The easiest way to find out is to try it, I just did a quick search on Google and there are a few posts about it, so it appears it may. But you would need to try it.
 

aeric

Expert
Licensed User
Longtime User
Nice!
Let say I created a program to print barcode labels on A4 or Letter size paper with the FXML template, I can let the user use the Scene Builder to modify the design by drag and drop or change the label properties if they want to.
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello Aeric,
I can let the user use the Scene Builder to modify the design by drag and drop or change the label properties if they want to.
You can but I wouldn't and didn't.

In my invoicing and stock control solutions, I've created a drag and drop layout editor which only took a few hours develop, it stores each views x and y top/left locations. This way my customers can move views around on different printable layouts without contacting me to edit or create new layouts for them, they can do it themselves. The view locations are stored automatically once the left mouse button is let go off. I create default printable templates that customers can then manipulate or leave as they are. Any views that the customer does not want printing, can be dragged off the page to the right hand side to the safe area. Just create and include a layout editor for your customers to use, it's easier and a lot better for the end user as it's incorporated into the same package.

Basic B4J header layout:
Below is a screenshot in the B4J designer of the editable header layout. Users can decide how document headers will look whilst printing on A4 paper.
1000080711.jpg


Bonus:
The images below are taken from my Facebook and Twitter accounts. All the layout are designed in B4J, A7 is a custom paper size.


1000080708.jpg

1000080710.jpg


I decided to add 4 smaller custom ISO A7 paper size printable kanban cards to my Kanban creator software. A7 measures 74 millimeters by 105 millimeters in size.

Left side is A7, right side is A6.
1000080706.jpg


Some examples of my A6 warehouse Kanban cards. These cards as well as others are created using B4J designer and printed using B4J Print Java FX8.
1000080707.jpg

I've developed a beta version of my kanban card printer software. The kanban layouts views are drag and drop, but I've not released that version to my customers as yet as I don't think that they really need it in this case.


Enjoy...
 
Last edited:

Magma

Expert
Licensed User
Longtime User
@Peter Simpson Will be nice-interesting, if you can share the part of code printing at columns how you manage it, for many line items - also if have multiple pages? ... because as i see you have every column as one label (for ex. LblProdCode).
1759571726664.png
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello @Magma,
I cheat because it's easier to do so lol ;)

I have two layout per printout, the main layout (page 1), and the extension of the main layout (page 2+). Not all of my page 1 layouts are the same item height in item area size. For example, one design has a remittance advice slip at the bottom, another has account balances at the bottom, some are standard like in your example above but with net and tax above the total, another layout has a voucher at the bottom that can be torn off and you can give 10%, 5%, 2% etc discounts, I have plenty of layout for invoices, quotes, a delivery note with a space for a signature, picking list and only a couple for purchase order for printing stock lists etc.

Anyway, my secret is knowing exactly how many rows can be printed on page 1 before loading the page 2+ layout to continue prining.

Yes I know, I can just design one page that does both page 1 & 2, but I personally don't want to do that, plus I'm lazy and having 2 layouts per page is quick and simple to integrate rather than writing lots of code. As long as you know exactly how many rows can be printed per document (2 to 3 less rows per document on MacOS), it's extremely quick and simple to integrate. On page 1 you have x amount of rows in the counter, when reached, you load page 2+, reset the counter to page 2+ (a lot more rows as page 2+ is a full page), then just continue printing. It's not that many lines of code, so when I get a chance to do so, I'll simplify and post the code as I currently have code in it (printer options etc) that I do not use but I keep the code there because I know where it is. It really is simple to integrate, you can do it in your sleep.

Below are examples of screens that the information is fully printable in this particular package. @Erel did an excellent job creating B4J for developing desktop applications, especially as this package (as a .jar file not .exe) also runs flawlessly on my MacBook Pro. Printing B4J projects using Print Java FX8 by @stevel05 is a 100% must in my personal opinion. Not only is B4J Print Java FX8 extremely simple to use, but I personally always use it in B4J when printing documentation and also charts via xCharts by @klaus.

When Erel first released B4J, I was 100% sure that I would never ever use it because I have VS installed and I developed in VB.Net, C# and ASP.Net, how wrong was I. These days I can't even remember the last time I developed a simple desktop solution using VS.

Printable invoice list.
1000074064.jpg


Printable invoice details.
1000074063.jpg


Printable information panel.
1000074067.jpg


Printable sales and purchases charts.
1000074065.jpg


Printable full stock list
Untitled-2.jpg


Printable filtered stock list
Untitled-1.jpg


Plus much much more...

@aeric, below is one of my header layout editors for my software. Customers can drag and drop the views around until they are happy with what they have. In this distinct case, the printouts that use this particular header will print like the image below. Once again B4J Print Java FX8 is used to print all my documentation and charts.
Untitled-3.jpg


Hmm, I think I should post these images on the B4X Facebook group page, actually I will when I get a change to do so ;)


Enjoy...
 
Last edited:
Top