0
<html>
<body>
        <h3 align="center"><b>Print Card</b></h3>
        <table border="1">
        <tr>
            <td></td>
            <td><b>Start of Shift</b></td>
            <td><b>End of Shift</b></td>
            <td></td>
        </tr>
        <tr>
            <td>Debit Total:</td>
            <td>£24.00</td>
            <td>£22.00 </td>
            <td>(£2.00)</td>
        </tr>
        <tr>
            <td>Credit Total:</td>
            <td>£32.00</td>
            <td>£30.00</td>
            <td>(£2.00)</td>
        </tr>
    </table>
   </body>
</html>

I wrote above in my Print.cshtml. And my Controller Action method is as below.

public ActionResult PrintCard()
{
    Transactions transationsShift = new Transactions();
    transationsShift = transationsShift.GetShiftData();
    return new RazorPDF.PdfResult(transationsShift, "Print");
}

Which generated below PDF.

enter image description here

But the first column of table is by default is too wide. I want to set width of each column manually which i am not able to do.

I tried to apply css class to table but no luck.

style="width:25%" to each column but not getting applied. :(

How can I do that? Any suggestions are welcome!

Thanks in advance. :)

jhoepken
  • 1,842
  • 3
  • 17
  • 24
  • For that one specific attribute you _might_ be able to use the `width` HTML attribute instead of the CSS attribute, so ``. Otherwise, [see this answer](http://stackoverflow.com/a/28631800/231316) which talks about the age and version of RazorPDF and how to upgrade and/or move away from it. – Chris Haas Mar 14 '16 at 17:11
  • I tried adding inline style as you suggested but that too didn't work. – Devendra Yadav Mar 15 '16 at 16:15
  • Just to be clear, my suggestion was *not* to use an inline style but to use an HTML attribute. If that's what you meant and tried then your only option to go through the things in the post that I linked to. – Chris Haas Mar 15 '16 at 16:19
  • Yes I tried which you suggested. But didn't get resolution of my problem. I will go through with above link. – Devendra Yadav Mar 15 '16 at 17:00

1 Answers1

0

I had this issue with converting to PDF, and what I did was convert to an Excel sheet first, where I can set the column width, and then converted the Excel to a PDF.

JP Hochbaum
  • 637
  • 4
  • 15
  • 28
  • I am afraid but this doesn't seems feasible way to achieve the desired output. I mean i first will have to play for converting Excel & then only i can try further. Any other thing you can suggest please. – Devendra Yadav Mar 15 '16 at 16:18