I'm trying to update a Coldbox app from v5.4 to v6...
# box-products
r
I'm trying to update a Coldbox app from v5.4 to v6.8 and all's going well except for pdf generation. I've stepped through the v6.x releases and the problem for me starts with v6.3 onwards and I'm trying to understand the changes that were introduced in that version that I should account for. The following code works as expected until v6.3 when it then returns a 500 with
The web page at *<http://localhost:8500/reports/deliveredby/hand>* might be temporarily down or it may have moved permanently to a new web address. ERR_INVALID_RESPONSE
That code being...
Copy code
public void function deliveredByHand( event, rc, prc ) {
	prc.members = MemberService
		.getMembersByHandDelivery();

	cfheader( name='content-disposition' value='attachment;filename="Delivered by Hand.pdf"' );

	event.renderData(
		data=renderView( 'reports/deliveredbyhand' )
		,type='pdf'
		,pdfArgs={ pagetype:'A4', unit:'cm', margintop:'1', marginbottom:'1',marginleft:'1', marginright:'1' }
	);

	return;
}
Either, what have I been wrong all this time, or what has changed in v6.3 and how should I change my code? Thoughts and advice welcomed.
s
Code looks fine, try to remove "void"
public void function
r
Thanks but no difference. I'm struggling to find the difference between v6.2 and v6.3 of Coldbox that might be causing this new error???
s
I have some recollection that if you use renderData like that then you don't need cfheader? Possibly it's doing cfheader twice?
might be 100% wrong about that
r
Do I really need to write the pdf out to a file and then use
sendFile()
to render it to the browser as that has "disposition" and "name" options?
s
I was just working on one where we do this:
Copy code
var pdfSource = '/app/resources/pdf/#RosterService.getMedicalReleasePDFFile()#';

			var pdfArgs = { 'reg' : reg };

			// if we have a valid e-signature, include it
			if ( !isNull( eSig ) ) pdfArgs.append( { 'medicalRelease' : eSig } );

			var pdfData = RosterService.populateMedicalRelease( argumentCollection = pdfArgs );

			var destination = expandPath( getTempDirectory() ) & createUUID() & ".pdf";

			cfpdfform( action = "populate", source = pdfSource, destination = destination ) {
				for ( var fieldName in structKeyArray( pdfData ) ) {
					if ( !isNull( pdfData[ fieldName ] ) ) {
						cfpdfformparam( name = fieldName, value = pdfData[ fieldName ] );
					}
				}
			}
			cfcontent( type = "application/pdf", file = destination, deleteFile = "Yes" );
			cfheader( name = "Content-Disposition", value = "inline; filename=inLeague-MedicalRelease.pdf" );
populating a pdf form field, but the last two lines are what we did instead of renderData, mostly because I forgot you could use renderData
s
I can confirm there are some issues in cb-6.8, hopefully will figure out the cause.
r
Thank you. Actually I can trace the issue back to v6.3 so I'll stick with v6.2 for now. Do you want me to raise a ticket?
s
Richard already created ticket for Luis 🙂 but I will try to fix it tomorrow
r
Thanks again for raising a ticket. I'll follow the issue.