user1740003
user1740003

Reputation: 57

multiple print css for same page

I am building an order entry system for a local company that sells health products. I am using asp.net with C#. When the user clicks print on the final invoice I actually want to print a couple copies of the invoice but I want each copy to show / hide different fields. Is there a way to create multiple print css' and when print is hit I could call print function using different css each time. I want to print an invoice for the customer with just the fields they need but also an invoice for the packer displaying any extra packing notes but not displaying money values, and then a final copy for the business records with all data.

Upvotes: 1

Views: 3162

Answers (1)

Gary Chen
Gary Chen

Reputation: 29

This is what works for me:

<style type="text/css">
@media print 
        {
            .printOnly {
               display: block !important;
               page-break-after: always;
            }

            #original_content {
               page-break-after: always;
            }
        }
</style>
<body>
   <div id="original_content">
      ...(your original content)...
   </div>

   <div class="printOnly" style="display:none"> 
      ...(basically a copy of original content, you can repeat this div 
      multiple times if you need more than one copy)...
   </div>
</body>

Upvotes: 2

Related Questions