views:

1473

answers:

3

I need to print 24 labels (37x70mm) on a A4 page.

I generate html for a table with size of an A4 page.

I tried to print the page from a browser but no success: the page doesn't start from the top although I set top margin to 0 (for html page and for browser too).

I tried to generate a pdf file with abcpdf, half succes here, the page starts from the top but it doesn't print the bottom margin.

Any idea?

+1  A: 

There is no easy way to do this with HTML or HTML/CSS.

I'd suggest using PrinceXML, it handles a rich XML vocabulary as well as XHTML / CSS. They even published a book from its pdf output. It is also used in Google Documents to produce the PDFs.

There are nice links on its Wikipedia page.

Osama ALASSIRY
A: 

You really need to generate it as a PDF to get accurate margins etc for labels.

Also keep in mind that when you print with PDF, it has a scaling mode whereby it shrinks the page to fit the margins, you'll either have to tell your users to disable that or you'll have to cater for that.

As for not printing the bottom margin, maybe your printer just doesn't print that far down? I know most of the ones i've owned had a bigger bottom margin than the top and side margins.

Here's a list of PDF libs:

http://stackoverflow.com/questions/373926/lightweight-open-source-pdf-library-in-c

Chris
+3  A: 

I've found a solution using abcpdf to generate a pdf from a html page:

thedoc.mediabox.string = "A4";
thedoc.rect.string = thedoc.mediabox.string;

With this settings the generated pdf has an A4 page size.

johnny