简体   繁体   English

页面中断无法正常工作

[英]Page-Break not working properly

Hello, I hope someone can help me with this problem. 您好,希望有人可以帮助我解决这个问题。 Basically I'm having an issue with page-break, let me break down every little step I made: 基本上,我在分页方面遇到了问题,让我分解一下我所做的每个小步骤:

#1 Initially, I had a page break problem using window.print(), due to the fact that I was using Table tag. #1最初,由于我使用的是Table标记,因此我使用window.print()遇到了分页问题。

     @media print {

  @page :first{
    margin-top:1cm; 
  }

  @page {
    margin-top:3cm; 
  }
}

h1, h2, h3, h4, div, table, tr, td, th{
    font-family:Arial, Helvetica, sans-serif;
    border-collapse:collapse;
    width:auto;
    margin:11px;
}


.cuerpo{ 
    position:relative;
    top:200px;
    right:9px;
    font-size:9px;
}


.cuerpo{
    padding-top:150px;
    font-size:9px;
    font-weight:500;
    page-break-after:always;
}


.cuerpo tr {
    padding:3px;
    line-height:15px;
    height:10px;
    width:15px;
}

.cuerpo tbody td, .cuerpo thead th{
    border:1px solid #000000;
    padding:1px;
}

http://jsfiddle.net/the_best/u99BQ/ http://jsfiddle.net/the_best/u99BQ/


#2 Then, I found in a forum that page-break works with 'display:block;' #2然后,我在一个论坛中发现分页符可与'display:block;'一起使用。 instead and changed the font-size:13px so it doesn't look too big and can fit as well on the paper. 而是更改了font-size:13px,使其看起来不会太大,也可以放在纸上。 I added that particular line of code in css this is what happened: if you try font-size=100% will break correctly but it'll look way too big. 我在CSS中添加了特定的代码行,这就是发生的情况:如果您尝试font-size = 100%会正确中断,但是看起来太大了。

 @media print {

   @page :first{
    margin-top:1cm; 
  }

   @page {
     margin-top:3cm; 
   }
}

h1, h2, h3, h4, div, table, tr, td, th{
    font-family:Arial, Helvetica, sans-serif;
    border-collapse:collapse;
}


thead tr .ancho {
    width:95;
    width:80;
}

#nombre-hotel {
    text-align:center;
}


#cuerpo{ 
    page-break-inside:avoid;
    padding-top:150px;
    position:relative;
    top:50px;
    border-collapse:collapse;
    font-size:90%;
}

#cuerpo tr{ 
    page-break-inside:avoid;
    page-break-after:auto; 
    /*page-break-after:auto;*/
    display:block;
    /*padding:3px;
    line-height:15px;
    height:10px;
    width:15px;*/
}

#cuerpo td, #cuerpo th{ 
    page-break-inside:avoid;
    border:solid 1px #CCCCCC;
}

http://jsfiddle.net/the_best/VwTa7/ http://jsfiddle.net/the_best/VwTa7/

Basically the issue is to get the page-break right with an appropriate font size, and and align cells. 基本上,问题在于使用合适的字体大小正确地进行分页符,然后对齐单元格。 Unfortunately that's not coming out for me. 不幸的是,这对我来说不是。 If someone can help me I would appreciate it a lot. 如果有人可以帮助我,我将不胜感激。 If you need detailed information just let me know. 如果您需要详细信息,请告诉我。

if you give .th-hotel a min-width and use font-size: 13px; 如果您给.th-hotel一个最小宽度并使用font-size:13px; page break works I think the problem were the multi lines at the hotel column 分页符工作,我认为问题是酒店专栏的多行

http://jsfiddle.net/VwTa7/1/ http://jsfiddle.net/VwTa7/1/

    #cuerpo{ 
        page-break-inside:auto;
        font-size: 13px;
    }

    #cuerpo tr{ 
        page-break-inside:avoid;
        page-break-after:auto;
    }

    .th-hotel {
        min-width: 250px;
    }

Oh never mind, I just figured out that it's way better to use dompdf to deliver your document to a PDF. 噢,没关系,我只是想出了使用dompdf将文档交付为PDF的更好方法。 The PDF format takes care of proper page-break regardless you're using table or anthing else. 无论您使用桌子还是其他物品,PDF格式都会确保适当的分页符。 It just works fine just need to hit the print button and it'll come out good. 只需按一下打印按钮,它就可以很好地工作。 Thanks for your comment anyways. 仍然感谢您的评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM