Hi Christoph, that’s how I create a PDF using ERPDFGeneration with custom fonts:
PDFTemplate pdfPage = pageWithName(PDFTemplate.class);
NSMutableDictionary config = new NSMutableDictionary();
config.takeValueForKey(new NSArray<String>("Fonts/MyFont.ttf“,
"Fonts/MyOtherFont.ttf"), "fonts");
NSData pdf =
ERPDFUtilities.htmlAsPdf(pdfPage.generateResponse().contentString(),
CharEncoding.UTF_8, null, config);
In this example the fonts are located in a directory „Fonts“ within „Resources“.
jw
Am 30.01.2014 um 13:13 schrieb Christoph Wick <[email protected]>:
> Hi List,
>
> I try to include fonts into a PDF document using ERPDFGeneration. The
> documentation of ERPFDWrapper tells me that there is a binding called
> "fonts". The binding is described as "(optional) array of font filenames to
> include for PDF generation".
>
> OK so far. But whatever I set the "fonts" bindings to, I get an
> ClassCastException that a String cannot be casted to NSArray<String>.
> Stacktrace below.
>
> I've looked into the code and I found line 120 in FlyingSaucerImpl.java:
>
> NSArray<String> fonts = (NSArray<String>)
> configuration.objectForKey("fonts");
>
> So, what's the correct syntax of the bindings value string to be converted
> into an NSArray of Strings? I've tried ['Font 1', 'Font2'] as well as {'Font
> 1', 'Font2'}, but that all doesn't work.
>
> Thx,
> C.U.CW
>
>
> Stacktrace:
>
> Error: java.lang.ClassCastException: java.lang.String cannot be cast
> to com.webobjects.foundation.NSArray
> Reason: java.lang.String cannot be cast to
> com.webobjects.foundation.NSArray
> Stack trace:
> File Line# Method Package
> FlyingSaucerImpl.java 120 fontsFromConfiguration er.pdf.builder
> FlyingSaucerImpl.java 91 setSource er.pdf.builder
> ERPDFUtilities.java 132 htmlAsPdf er.pdf
> ERPDFWrapper.java 89 responseAsPdf er.pdf
> ERPDFWrapper.java 66 appendToResponse er.pdf
> WOComponent.java 1122 appendToResponse com.webobjects.appserver
> ERXComponent.java 195 appendToResponse er.extensions.components
> WOSession.java 1385 appendToResponse com.webobjects.appserver
> WOApplication.java 1794 appendToResponse com.webobjects.appserver
> ERXApplication.java 2005 appendToResponse er.extensions.appserver
> ERXComponentRequestHandler.java 190 _dispatchWithPreparedPage
> er.extensions.appserver
> ERXComponentRequestHandler.java 235 _dispatchWithPreparedSession
> er.extensions.appserver
> ERXComponentRequestHandler.java 268
> _dispatchWithPreparedApplication er.extensions.appserver
> ERXComponentRequestHandler.java 302 _handleRequest
> er.extensions.appserver
> ERXComponentRequestHandler.java 378 handleRequest
> er.extensions.appserver
> WOApplication.java 1687 dispatchRequest com.webobjects.appserver
> ERXApplication.java 2109 dispatchRequestImmediately
> er.extensions.appserver
> ERXApplication.java 2074 dispatchRequest er.extensions.appserver
> WOWorkerThread.java 144 runOnce com.webobjects.appserver._private
> WOWorkerThread.java 226 run com.webobjects.appserver._private
> Thread.java 722 run java.lang
>
>
> --
> Christoph Wick - Diplom Informatiker, Managing Director
> i4innovation GmbH, Professor-Neu-Allee 39, 53225 Bonn, Germany
>
> T +49 2 28 28 62 97 93
> M +49 1 51 22 65 78 90
> F +49 2 28 28 62 97 99
> M [email protected]
> W www.i4innovation.de
> Skype: christoph_wick
>
> Geschäftsführer: Thomas Heep, Christoph Wick
> Sitz der Gesellschaft: Bonn | Amtsgericht Bonn HRB 18548 | USt-IdNr.:
> DE276502600
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/jw%40oyosys.com
>
> This email sent to [email protected]
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
