Page 1 of 2

Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 5:05 pm
by swingman
Hi all,

Servoy 6.1.3, Mac OS X 10.6.8 / 10.7.x / 10.8.2. Latest Java 7 on server and client. We try to print an invoice. Invoice previews fine in Servoy with proper fonts. We click save as PDF or view as PDF in Preview. resulting invoice has bad bit-mapped font. Has anyone seen this issue?

Christian

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 5:08 pm
by swingman
Should look more like this:

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 5:11 pm
by Harjo
How are you printing that invoice? print-preview? smart-client? web-client? just a form in Servoy?

With pdf-print, you can embed the font (look for the pdf options, in the pdf_output plugin in Servoy)

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 5:13 pm
by swingman
Smart Client, Print Preview, Click 'Print Button', get Apple's Print Dialog, PDF Dropdown, Save as PDF or Open PDF in Preview...

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 5:26 pm
by Harjo
so in the print-preview you see the right font?
that's strange.... that means, the font is recognized (locally) by Servoy.

You didn't had this with Java 6?

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 6:16 pm
by pavelzver
Hi,

I have the same issue with Java 7 on Mac OS X. Fonts showing up properly on the print preview, but they do not print the same way. Everything was fine with the previous versions of java.

Does any one have any suggestions?

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Mon Feb 04, 2013 7:17 pm
by swingman
Harjo wrote:so in the print-preview you see the right font?
that's strange.... that means, the font is recognized (locally) by Servoy.

You didn't had this with Java 6?


No, it was working fine before on Java 6.

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Tue Feb 05, 2013 12:09 am
by Harjo
Please, file a bug report in the Servoy Support system

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Fri May 24, 2013 4:21 pm
by swingman
Any news on this? We have the same problem on Java 7 latest, Mac OS X latest, Servoy 6.1 latest.
We work around by printing to PDF and emailing them to the users.

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Wed Aug 13, 2014 10:45 am
by Gordon McLean
swingman wrote:Any news on this? We have the same problem on Java 7 latest, Mac OS X latest, Servoy 6.1 latest.
We work around by printing to PDF and emailing them to the users.


Did you make any further progress on this Christian ? The fonts are not working either as a print or pdf regardless of how I try and output from Servoy directly. I am looking at moving it to Velocity to overcome the problem but that is going to add a fair amount of work generating the template :(

Cheers
Gordon

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Tue Aug 19, 2014 7:10 pm
by swingman
Hi Gordon,

just looked at the production code and we are still sending ourselves PDFs to get around the issue.

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Tue Aug 19, 2014 8:36 pm
by Gordon McLean
swingman wrote:Hi Gordon,

just looked at the production code and we are still sending ourselves PDFs to get around the issue.


Hi Christian

Thanks and interesting, I tried this and the PDFs also failed to render the fonts on the Mac. As it was a relatively simple single page report I re worked it in html using velocity which was fine printed but again as a PDF it lost the fonts :( I am guessing this is the PDF rendering in the java component - none the less a workaround has saved the day :)

Thanks
Gordon

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Wed Aug 20, 2014 10:35 am
by Harjo
I have tested this, and this indeed happens, when you set the Servoy client, to use the system print dialog.
Schermafbeelding 2014-08-20 om 10.21.05.png
Schermafbeelding 2014-08-20 om 10.21.05.png (87.16 KiB) Viewed 11118 times


I wondered why we never had complaints about this, and this is because we print the form, directly to pdf (with embedding fonts) inside Servoy and show it as a popup.
Did you already filled a case?? if so please let me know, I will vote for it.
Although I wonder if Servoy can do something about it, because when you don't Save as PDF or Open PDF in Preview... but directly print it the printer, the right fonts are shown on the print.

this is snippet of the code we use

Code: Select all
/**
* @properties={typeid:24,uuid:"49aafa02-acfd-4eb7-aa8b-7708ca5cbcfa"}
* @param {String} form
* @param {String} sendfilename
* @param {Boolean} [vCurrentRecordOnly]
*/
function printAsPdf(form, sendfilename, vCurrentRecordOnly) {
   if (!vCurrentRecordOnly) {
      vCurrentRecordOnly = false
   }
   //only allow characters
   var regExp = /[^a-zA-Z0-9_]/g
   var filename = sendfilename.replace(regExp, '');
   application.output(new Date())
   plugins.pdf_output.startMetaPrintJob()
   if (utils.stringMiddle(application.getOSName(), 1, 7) == "Windows") {
      plugins.pdf_output.insertFontDirectory('c:/Windows/Fonts');
   }

   if (application.getOSName().match("Mac")) {
      //plugins.pdf_output.insertFontDirectory('/System/Library/Fonts/');
      plugins.pdf_output.insertFontDirectory('/Library/Fonts/');
      //plugins.pdf_output.insertFontDirectory('~/Library/Fonts/');
   }
   forms[form].controller.print(vCurrentRecordOnly, false, plugins.pdf_output.getPDFPrinter());
   var pdf = plugins.pdf_output.endMetaPrintJob()
   
   var question = plugins.dialogs.showQuestionDialog('i18n:1.question', 'i18n:1.message.openorsavepdf', 'i18n:1.open', 'i18n:1.saveas')
   if (question == i18n.getI18NMessage('i18n:1.open')) {
      var filenames = plugins.file.createTempFile(filename, '.pdf')
      plugins.file.writeFile(filenames, pdf);
      openFile(filenames.getAbsolutePath())
   } else {
      var save = plugins.file.showFileSaveDialog(filename + '.pdf')
      if (save) {
         var success = plugins.file.writeFile(save, pdf);
         if (success) {
            plugins.dialogs.showInfoDialog('i18n:1.info', 'i18n:1.message.downloadsaveready', 'i18n:1.ok');
         } else {
            plugins.dialogs.showErrorDialog('i18n:1.error', 'i18n:1.message.downloadsaveerror', 'i18n:1.ok');
         }
      }
   }
}

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Wed Aug 20, 2014 10:46 am
by Gordon McLean
Hi Harjo

I have not filed a bug, I elected for a work around as I rarely use Servoy to print, generally electing to use Velocity. This was an in house solution that I may roll out as a saas product, hence the question. I next to never use the smart client it was coincidental that I chose to save to PDF and lost the fonts and when I tried smart client got the same result hence investigating further.

best
Gordon

Re: Java 7, Print to PDF not recognising fonts Mac OS X

PostPosted: Wed Aug 20, 2014 10:54 am
by Harjo
it becomes even stranger!

I showed in my answer a piece of a screenshot, of 2 different preview's, right?
when I print both preview's to the same printer, the printout is exactly the same, with the right font!!! :shock: