Removing borders on letter size page

1,478 views
Skip to first unread message

Robert

unread,
Feb 16, 2012, 9:02:41 AM2/16/12
to dompdf
Hi,

I am trying to generate Avery 5160 labels from my site. When I print
from HTML I get the headers and footers from the Browser unless I
change print options. But I can't ask every user to change print
options.

So I tried to render a PDF using dompdf from the HTML. But I get a
left and top border on the resulting PDF. Is there a way I can render
without the top and left border? I need to go right to the edges.

thanks,
Rob

Fabien Ménager

unread,
Feb 16, 2012, 9:08:03 AM2/16/12
to dom...@googlegroups.com
It depends on what version of DOMPDF you use, but adding this to your CSS will remove any white margin : 

@page {
  margin: 0;
}

body {
  padding: 0;
  margin: 0;
}

Robert

unread,
Feb 16, 2012, 9:57:26 AM2/16/12
to dompdf
Thanks, I will give that a try and post the results.

Robert

unread,
Feb 17, 2012, 12:11:20 AM2/17/12
to dompdf
That fix worked. The only downside is that I still need to tell
Acrobat not to scale when printing because I'm going edge to edge on
the paper.

thanks again,
Rob

Gabriel Harrison

unread,
Feb 17, 2012, 9:16:17 AM2/17/12
to dom...@googlegroups.com
Hi Rob,

Have you got the page size set to the size of the label or are you  just letting adobe rescale it for you?

Gabriel

Robert

unread,
Feb 17, 2012, 9:33:19 AM2/17/12
to dompdf
I have the page size set to the size of the labels. 3 across and 10
label down. I have to tell Acrobat not to scale it or it shrinks what
I created a bit. I assume adobe like to give the page borders, but
these labels go right to the edge.

I do have the page size set to 8.5in x 11in in the style area before I
render it.

thanks,
Rob

Gabriel Harrison

unread,
Feb 17, 2012, 12:23:19 PM2/17/12
to dom...@googlegroups.com
Hi,

does out make a difference if you set the size to the label size
instead of letter size in the style sheet?

Gabriel

Robert

unread,
Feb 17, 2012, 12:25:51 PM2/17/12
to dompdf
I have all 30 labels prints at one time. So I need the 8 1/2 by 11
paper size.

Rob

BrianS

unread,
Feb 18, 2012, 1:57:07 PM2/18/12
to dom...@googlegroups.com
On Friday, February 17, 2012 12:11:20 AM UTC-5, Robert wrote:
The only downside is that I still need to tell
Acrobat not to scale when printing because I'm going edge to edge on
the paper.

I think that's an application setting and not something that can be specified in the PDF. Though I could be wrong, I'd have to do some more research to know for sure. If you find any information that does indicate such a setting let us know so we can add a feature request to the tracker.

Robert

unread,
Feb 18, 2012, 2:01:59 PM2/18/12
to dom...@googlegroups.com
Looks like this page has some good hints on how to set acrobat to no scaling in the pdf file.

BrianS

unread,
Feb 18, 2012, 8:18:42 PM2/18/12
to dom...@googlegroups.com
Nice find. Thinking on the topic more I don't know that we would necessarily provide this as part of the rendering process. Depending on the back end you are using you should be able to do this directly. I'll have to take a look and see if it's possible with CPDF. If this can be done by setting the viewer preferences as indicated in that post then maybe something like the following may work:

$dompdf = new DOMPDF;
...
$dompdf->render();
$dompdf->get_canvas()->get_cpdf()->setPreferences( 'PrintScaling' , 'None' );

But I'll have to do some more testing before I can give you a definitive answer.
Message has been deleted

BrianS

unread,
Feb 23, 2012, 9:56:17 PM2/23/12
to dom...@googlegroups.com
Alright, I'm pretty sure I posted this already. But it's not showing up yet, so ...

After running some tests I can say that this does not work in dompdf when using the CPDF back end. The PrintScaling preference is available starting with version 1.6 of the PDF spec. CPDF supports version 1.3 of the spec. Adding support for other versions is low on our list of priorities right now.

If you're using the PDFLib back end you should be able to add this preference. I'd have to set up a test-bed and research the appropriate commands, so let me know if you're interested in pursuing this.
Reply all
Reply to author
Forward
0 new messages