Using Java Page co-ordinates

We make extensive use of Java Page co-ordinates in JPedal, which we convert both into PDF co-ordinates and also relative offsets. I have been changing this code recently and it has been anything but straight-forward so I have recorded my experiences. I hope you find them helpful. With the expansion of the search functionality to…

Read More

Java printing of custom Swing Components

If you are implementing printing in Java, there is a really good tutorial showing how to add printing support to any Swing component. Printing generally works very well and we use it in our PDF library to provide printing of PDF files. The example uses a PrinterJob to print via Java – essentially, your Swing…

Read More

Java File handling – when is a file actually saved

Consider the following code…. File ff=File.createTempFile(“page”,”.bin”, new File(ObjectStore.temp_dir)); BufferedOutputStream to = new BufferedOutputStream(new FileOutputStream(ff)); to.write(currentDisplay.serializeToByteArray(null));          to.flush();            to.close(); pagesOnDisk.put(key,ff.getAbsolutePath()); It stores a serialised Java Object (currentDisplay) on disk and then stores the file location so we can reuse it. So in theory,  if the value is in the Map pagesOnDisk, we should…

Read More