andyhutch77 / MvcRazorToPdf

Create pdf documents within an asp .net mvc project by generating your views as normal but returning a PdfActionResult. This converts regular produced razor/html to pdf documents in the browser using the iTextXmlWorker.
125 stars 105 forks source link

Getting rid of the margins #18

Open joetinger opened 9 years ago

joetinger commented 9 years ago

Is there anyway to get rid of the margins? CSS doesn't seem to be working and I want my image in the top left corner.

Thanks, Jake

andyhutch77 commented 9 years ago

@joetinger Hi Joe, sorry I thought this would be straight forward but unfortunately not.

I was hoping a pure css approach would be able to tackle this one.

Let me know if you figure it out, will keep you posted if I do.

ElanHasson commented 9 years ago

This is probably possible using the recent commit I made exposing the document. On Oct 15, 2014 4:52 PM, "Andrew Hutchinson" notifications@github.com wrote:

@joetinger https://github.com/joetinger Hi Joe, sorry I thought this would be straight forward but unfortunately not.

I was hoping a pure css approach would be able to tackle this one.

Let me know if you figure it out, will keep you posted if I do.

— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/18#issuecomment-59274144 .

opr commented 6 years ago

Hi chaps,

did you figure out how to remove the margins from the pages?

Cheers

shameen commented 6 years ago

I tried many different methods to get out of the margin (via HTML+CSS), and the only thing which worked was relative positioning on a div (it didn't work on the table):

<body>
    <div style="position:relative;top:-80px;left:-47px">
        <table>
        ...
        </table>
    </div>
</body>

Edit: You can't seem to stretch an element past 100% height (~1025px), so there is a double-height margin at the bottom of the page. I got around this by a few more position:relative hacks:

<tr>
    <td>
        <div style="position:relative;top:@(rowIndex*10)px">
        ...
        </div>
    </td>
</tr>

with the top amount scaling for each table row. Not ideal at all, but this is the only way i could fill the entire page without margins.