I am writing a custom module that will be used to print consignment labels for a shipping provider.

The labels print 4 to a page. The module provides a form that allows the user to specify the number of packages, the dimensions etc then prints a label for each package. I will want to format them with CSS so that they print correctly to the label peel off sections etc

One way I had worked out to do this was to have a second form on the page which submits to a PHP file in my module directory. I place the code in this PHP page to process the labels and output which I can then print from.

This solution works, however it is outside of Drupal in that the form posts to a standalone PHP script. Is there a way to do this within Drupal? I have looked at the Print, PDF module but I dont know if I can configure it in this way.


If you want to break out of the theming system and display your own markup for a page you can do so.

Simply print whatever you want in your callback and rather than returning the content do an exit;

It isn't very elegant but it will do the job.


A simple solution is to store submitted data in $form_state['storage] and rebuild then form. Then in form function, you can check to see if the $form_state has the submitted data and display the result instead, or the result and the form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.