1 Востаннє редагувалося Betterthanyou (18.06.2016 21:32:46)

Тема: 4А Сторінка

Є в мене CSS i HTML 4A сторінки

<style type="text/css">
        body {
          background: rgb(204,204,204); 
        }
        page {
          background: white;
          display: block;
          margin: 0 auto;
          margin-bottom: 0.5cm;
          box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
        }
        page[size="A4"] {  
          width: 21cm;
          height: 29.7cm; 
        }
        @media print {
          body, page {
            margin: 0;
            box-shadow: 0;
          }
        }
    </style>

    <page size="A4">
          Тут якийсь текст....
    <page>

Але проблеми появилися коли мені потрібно було динамічно вставляти текст, (не за-допомогою PHP, а за-допомогою Qt i C++ справа в тому що MICROSOFT WORD закритий формат, я знаю що його можна автоматизувати OLE і ActiveX здається, але це не то..., мені потрібно самостійно створювати документи) коли переповнюється сторінка текст починає вилазити за межі сторінка.
Я хочу зробити так щоб все текст(і HTML) поміщався в якийсь тег (DIV наприклад) і JS (бажано без фреймворків) розподіляв його по сторінках самостійно, притому потрібно пам'ятати що цей текст буде роздруковуватися.
Я не маю поняття як можна це все поміряти, щоб дізнатися коли йде інша сторінка, бо там будуть таблиці, зображення і т.д. просто length явно не допоможе. Допоможіть скласти скрипт (повторюсь бажано не використовувати фреймворків) що буде розподіляти текст по сторінкам.

2

Re: 4А Сторінка

Я тут так подумав що можна додавати розміри кожного елемента getComputedStyle( Елемент ).width, getComputedStyle( Елемент ).height але й всеодно не вийшло, наприклад якщо текст не поміщається на сторінці то пів сторінки остається пустою а тест який був там (тег <р></p>) переноситься на нову, з таблицями звичайно така ж проблема а якщо тексту більше чим може вмістити вся сторінка він взагалі ніде не вписується.

3

Re: 4А Сторінка

Тобто вам потрібно розбити текст на сторінки 1,2,3...?
Роздруківка має бути тільки для тексту чи і всього, що є на сторінці?

4 Востаннє редагувалося leofun01 (19.06.2016 14:59:07)

Re: 4А Сторінка

Не розумію, в чому проблема. Роздруком HTML-сторінки повністю керує бровзер. Саме бровзер вирішує де буде розрив контенту враховуючи відступи на кожній сторінці і застосовані стилі, не залежно від того, як сторінка була наповнена контентом (звичайно чи динамічно).
Від вас вимагається тільки CSS.
Якщо Ви хочете щоб контент на сторінці відображався так, як він буде надрукованим, то в бровзерах є відповідна опція. Наприклад в Firefox: "File -> Print Preview" ("Файл -> Попередній перегляд"). А робити таке вручну немає ні сенсу, ні потреби, на екрані контент має йти без розривів. Якщо при друку має бути розрив сторінки, тоді використовуйте page-break-after, page-break-before (для уникнення розривів: page-break-inside).
На всякий випадок залишу тут це і корисну статтю.
Організувати нумерацію сторінок можна з допомогою counter, але краще віддати цю роботу бровзеру.

Подякували: Betterthanyou, Djalin2

5 Востаннє редагувалося Betterthanyou (19.06.2016 15:18:27)

Re: 4А Сторінка

VTrim написав:

Тобто вам потрібно розбити текст на сторінки 1,2,3...?
Роздруківка має бути тільки для тексту чи і всього, що є на сторінці?

Так мені потрібно розбити тест на сторінки, якщо коротко то потрібно щоб все було так як в Microsoft word, тобто елементи які можна розбити на сторінки це текст, таблиці і т.д. розбити на сторінки, а фото, відео і інше що не можна розбити на сторінки просто переносити на нову якщо не бракує місця на даній. Але мені хоча б розібратися з текстом і таблицями.
Друкувати потрібно все що можливо (тобто якщо буде відео то звичайно його друкувати не потрібно)

6 Востаннє редагувалося Betterthanyou (19.06.2016 15:06:24)

Re: 4А Сторінка

leofun01 написав:

Не розумію, в чому проблема. Роздруком HTML-сторінки повністю керує бровзер. Саме бровзер вирішує де буде розрив контенту враховуючи відступи на кожній сторінці і застосовані стилі, не залежно від того, як сторінка була наповнена контентом (звичайно чи динамічно).
Від вас вимагається тільки CSS.
Якщо Ви хочете щоб контент на сторінці відображався так, як він буде надрукованим, то в бровзерах є відповідна опція. Наприклад в Firefox: "File -> Print Preview" ("Файл -> Попередній перегляд"). А робити таке вручну немає ні сенсу, ні потреби, на екрані контент має йти без розривів. Якщо при друку має бути розрив сторінки, тоді використовуйте page-break-after, page-break-before (для уникнення розривів: page-break-inside).
На всякий випадок залишу тут це і корисну статтю.

Так я вже розібрався з друком, потрібно було просто настроїть браузер щоб він не друкував фон, але я й досі не знаю як розбити текст і таблиці на сторінки.

якщо не налаштувати браузер

https://replace.org.ua/misc.php?action=pun_attachment&amp;item=1313&amp;download=0

Post's attachments

Untitled.png 23.36 kb, 220 downloads since 2016-06-19 

7 Востаннє редагувалося Betterthanyou (19.06.2016 15:13:25)

Re: 4А Сторінка

Ось приклад

<!DOCTYPE html>

<html lang="uk" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Продукт</title>
</head>
<body>

    <style type="text/css">
        body {
          background: rgb(204,204,204); 
          font-family: 'Times New Roman';
        }
        .page {
          background: white;
          display: block;
          margin: 0 auto;          
          margin-bottom: 0.5cm;
          box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
          width: 21cm;
          height: 29.7cm; 
        }
        .derogation {
            padding: 2.54cm;
        }
        table {
            font-size: 14px;
        }
        @media print {
          body, page {
            margin: 0;
            box-shadow: 0;
          }
        }
    </style>
    
    <div class="page">
        <div class="derogation">
            <p>
                Brother set had private his letters observe outward resolve. Shutters ye marriage to throwing we as. Effect in if agreed he wished wanted admire expect. Or shortly visitor is comfort placing to cheered do. Few hills tears are weeks saw. Partiality insensible celebrated is in. Am offended as wandered thoughts greatest an friendly. Evening covered in he exposed fertile to. Horses seeing at played plenty nature to expect we. Young say led stood hills own thing get.

                At every tiled on ye defer do. No attention suspected oh difficult. Fond his say old meet cold find come whom. The sir park sake bred. Wonder matter now can estate esteem assure fat roused. Am performed on existence as discourse is. Pleasure friendly at marriage blessing or.

                Is allowance instantly strangers applauded discourse so. Separate entrance welcomed sensible laughing why one moderate shy. We seeing piqued garden he. As in merry at forth least ye stood. And cold sons yet with. Delivered middleton therefore me at. Attachment companions man way excellence how her pianoforte.

                Perpetual sincerity out suspected necessary one but provision satisfied. Respect nothing use set waiting pursuit nay you looking. If on prevailed concluded ye abilities. Address say you new but minuter greater. Do denied agreed in innate. Can and middletons thoroughly themselves him. Tolerably sportsmen belonging in september no am immediate newspaper. Theirs expect dinner it pretty indeed having no of. Principle september she conveying did eat may extensive.

                Two assure edward whence the was. Who worthy yet ten boy denote wonder. Weeks views her sight old tears sorry. Additions can suspected its concealed put furnished. Met the why particular devonshire decisively considered partiality. Certain it waiting no entered is. Passed her indeed uneasy shy polite appear denied. Oh less girl no walk. At he spot with five of view.

                Perhaps far exposed age effects. Now distrusts you her delivered applauded affection out sincerity. As tolerably recommend shameless unfeeling he objection consisted. She although cheerful perceive screened throwing met not eat distance. Viewing hastily or written dearest elderly up weather it as. So direction so sweetness or extremity at daughters. Provided put unpacked now but bringing.

                Spot of come to ever hand as lady meet on. Delicate contempt received two yet advanced. Gentleman as belonging he commanded believing dejection in by. On no am winding chicken so behaved. Its preserved sex enjoyment new way behaviour. Him yet devonshire celebrated especially. Unfeeling one provision are smallness resembled repulsive.

                Offered say visited elderly and. Waited period are played family man formed. He ye body or made on pain part meet. You one delay nor begin our folly abode. By disposed replying mr me unpacked no. As moonlight of my resolving unwilling.

                Too cultivated use solicitude frequently. Dashwood likewise up consider continue entrance ladyship oh. Wrong guest given purse power is no. Friendship to connection an am considered difficulty. Country met pursuit lasting moments why calling certain the. Middletons boisterous our way understood law. Among state cease how and sight since shall. Material did pleasure breeding our humanity she contempt had. So ye really mutual no cousin piqued summer result.

                With my them if up many. Lain week nay she them her she. Extremity so attending objection as engrossed gentleman something. Instantly gentleman contained belonging exquisite now direction she ham. West room at sent if year. Numerous indulged distance old law you. Total state as merit court green decay he. Steepest sex bachelor the may delicate its yourself. As he instantly on discovery concluded to. Open draw far pure miss felt say yet few sigh.

                Brother set had private his letters observe outward resolve. Shutters ye marriage to throwing we as. Effect in if agreed he wished wanted admire expect. Or shortly visitor is comfort placing to cheered do. Few hills tears are weeks saw. Partiality insensible celebrated is in. Am offended as wandered thoughts greatest an friendly. Evening covered in he exposed fertile to. Horses seeing at played plenty nature to expect we. Young say led stood hills own thing get.

                At every tiled on ye defer do. No attention suspected oh difficult. Fond his say old meet cold find come whom. The sir park sake bred. Wonder matter now can estate esteem assure fat roused. Am performed on existence as discourse is. Pleasure friendly at marriage blessing or.

                Is allowance instantly strangers applauded discourse so. Separate entrance welcomed sensible laughing why one moderate shy. We seeing piqued garden he. As in merry at forth least ye stood. And cold sons yet with. Delivered middleton therefore me at. Attachment companions man way excellence how her pianoforte.

                Perpetual sincerity out suspected necessary one but provision satisfied. Respect nothing use set waiting pursuit nay you looking. If on prevailed concluded ye abilities. Address say you new but minuter greater. Do denied agreed in innate. Can and middletons thoroughly themselves him. Tolerably sportsmen belonging in september no am immediate newspaper. Theirs expect dinner it pretty indeed having no of. Principle september she conveying did eat may extensive.

                Two assure edward whence the was. Who worthy yet ten boy denote wonder. Weeks views her sight old tears sorry. Additions can suspected its concealed put furnished. Met the why particular devonshire decisively considered partiality. Certain it waiting no entered is. Passed her indeed uneasy shy polite appear denied. Oh less girl no walk. At he spot with five of view.

                Perhaps far exposed age effects. Now distrusts you her delivered applauded affection out sincerity. As tolerably recommend shameless unfeeling he objection consisted. She although cheerful perceive screened throwing met not eat distance. Viewing hastily or written dearest elderly up weather it as. So direction so sweetness or extremity at daughters. Provided put unpacked now but bringing.

                Spot of come to ever hand as lady meet on. Delicate contempt received two yet advanced. Gentleman as belonging he commanded believing dejection in by. On no am winding chicken so behaved. Its preserved sex enjoyment new way behaviour. Him yet devonshire celebrated especially. Unfeeling one provision are smallness resembled repulsive.

                Offered say visited elderly and. Waited period are played family man formed. He ye body or made on pain part meet. You one delay nor begin our folly abode. By disposed replying mr me unpacked no. As moonlight of my resolving unwilling.

                Too cultivated use solicitude frequently. Dashwood likewise up consider continue entrance ladyship oh. Wrong guest given purse power is no. Friendship to connection an am considered difficulty. Country met pursuit lasting moments why calling certain the. Middletons boisterous our way understood law. Among state cease how and sight since shall. Material did pleasure breeding our humanity she contempt had. So ye really mutual no cousin piqued summer result.

                With my them if up many. Lain week nay she them her she. Extremity so attending objection as engrossed gentleman something. Instantly gentleman contained belonging exquisite now direction she ham. West room at sent if year. Numerous indulged distance old law you. Total state as merit court green decay he. Steepest sex bachelor the may delicate its yourself. As he instantly on discovery concluded to. Open draw far pure miss felt say yet few sigh.

                Brother set had private his letters observe outward resolve. Shutters ye marriage to throwing we as. Effect in if agreed he wished wanted admire expect. Or shortly visitor is comfort placing to cheered do. Few hills tears are weeks saw. Partiality insensible celebrated is in. Am offended as wandered thoughts greatest an friendly. Evening covered in he exposed fertile to. Horses seeing at played plenty nature to expect we. Young say led stood hills own thing get.

                At every tiled on ye defer do. No attention suspected oh difficult. Fond his say old meet cold find come whom. The sir park sake bred. Wonder matter now can estate esteem assure fat roused. Am performed on existence as discourse is. Pleasure friendly at marriage blessing or.

                Is allowance instantly strangers applauded discourse so. Separate entrance welcomed sensible laughing why one moderate shy. We seeing piqued garden he. As in merry at forth least ye stood. And cold sons yet with. Delivered middleton therefore me at. Attachment companions man way excellence how her pianoforte.

                Perpetual sincerity out suspected necessary one but provision satisfied. Respect nothing use set waiting pursuit nay you looking. If on prevailed concluded ye abilities. Address say you new but minuter greater. Do denied agreed in innate. Can and middletons thoroughly themselves him. Tolerably sportsmen belonging in september no am immediate newspaper. Theirs expect dinner it pretty indeed having no of. Principle september she conveying did eat may extensive.

                Two assure edward whence the was. Who worthy yet ten boy denote wonder. Weeks views her sight old tears sorry. Additions can suspected its concealed put furnished. Met the why particular devonshire decisively considered partiality. Certain it waiting no entered is. Passed her indeed uneasy shy polite appear denied. Oh less girl no walk. At he spot with five of view.

                Perhaps far exposed age effects. Now distrusts you her delivered applauded affection out sincerity. As tolerably recommend shameless unfeeling he objection consisted. She although cheerful perceive screened throwing met not eat distance. Viewing hastily or written dearest elderly up weather it as. So direction so sweetness or extremity at daughters. Provided put unpacked now but bringing.

                Spot of come to ever hand as lady meet on. Delicate contempt received two yet advanced. Gentleman as belonging he commanded believing dejection in by. On no am winding chicken so behaved. Its preserved sex enjoyment new way behaviour. Him yet devonshire celebrated especially. Unfeeling one provision are smallness resembled repulsive.

                Offered say visited elderly and. Waited period are played family man formed. He ye body or made on pain part meet. You one delay nor begin our folly abode. By disposed replying mr me unpacked no. As moonlight of my resolving unwilling.

                Too cultivated use solicitude frequently. Dashwood likewise up consider continue entrance ladyship oh. Wrong guest given purse power is no. Friendship to connection an am considered difficulty. Country met pursuit lasting moments why calling certain the. Middletons boisterous our way understood law. Among state cease how and sight since shall. Material did pleasure breeding our humanity she contempt had. So ye really mutual no cousin piqued summer result.

                With my them if up many. Lain week nay she them her she. Extremity so attending objection as engrossed gentleman something. Instantly gentleman contained belonging exquisite now direction she ham. West room at sent if year. Numerous indulged distance old law you. Total state as merit court green decay he. Steepest sex bachelor the may delicate its yourself. As he instantly on discovery concluded to. Open draw far pure miss felt say yet few sigh.

                Brother set had private his letters observe outward resolve. Shutters ye marriage to throwing we as. Effect in if agreed he wished wanted admire expect. Or shortly visitor is comfort placing to cheered do. Few hills tears are weeks saw. Partiality insensible celebrated is in. Am offended as wandered thoughts greatest an friendly. Evening covered in he exposed fertile to. Horses seeing at played plenty nature to expect we. Young say led stood hills own thing get.

                At every tiled on ye defer do. No attention suspected oh difficult. Fond his say old meet cold find come whom. The sir park sake bred. Wonder matter now can estate esteem assure fat roused. Am performed on existence as discourse is. Pleasure friendly at marriage blessing or.

                Is allowance instantly strangers applauded discourse so. Separate entrance welcomed sensible laughing why one moderate shy. We seeing piqued garden he. As in merry at forth least ye stood. And cold sons yet with. Delivered middleton therefore me at. Attachment companions man way excellence how her pianoforte.

                Perpetual sincerity out suspected necessary one but provision satisfied. Respect nothing use set waiting pursuit nay you looking. If on prevailed concluded ye abilities. Address say you new but minuter greater. Do denied agreed in innate. Can and middletons thoroughly themselves him. Tolerably sportsmen belonging in september no am immediate newspaper. Theirs expect dinner it pretty indeed having no of. Principle september she conveying did eat may extensive.

                Two assure edward whence the was. Who worthy yet ten boy denote wonder. Weeks views her sight old tears sorry. Additions can suspected its concealed put furnished. Met the why particular devonshire decisively considered partiality. Certain it waiting no entered is. Passed her indeed uneasy shy polite appear denied. Oh less girl no walk. At he spot with five of view.

                Perhaps far exposed age effects. Now distrusts you her delivered applauded affection out sincerity. As tolerably recommend shameless unfeeling he objection consisted. She although cheerful perceive screened throwing met not eat distance. Viewing hastily or written dearest elderly up weather it as. So direction so sweetness or extremity at daughters. Provided put unpacked now but bringing.

                Spot of come to ever hand as lady meet on. Delicate contempt received two yet advanced. Gentleman as belonging he commanded believing dejection in by. On no am winding chicken so behaved. Its preserved sex enjoyment new way behaviour. Him yet devonshire celebrated especially. Unfeeling one provision are smallness resembled repulsive.

                Offered say visited elderly and. Waited period are played family man formed. He ye body or made on pain part meet. You one delay nor begin our folly abode. By disposed replying mr me unpacked no. As moonlight of my resolving unwilling.

                Too cultivated use solicitude frequently. Dashwood likewise up consider continue entrance ladyship oh. Wrong guest given purse power is no. Friendship to connection an am considered difficulty. Country met pursuit lasting moments why calling certain the. Middletons boisterous our way understood law. Among state cease how and sight since shall. Material did pleasure breeding our humanity she contempt had. So ye really mutual no cousin piqued summer result.

                With my them if up many. Lain week nay she them her she. Extremity so attending objection as engrossed gentleman something. Instantly gentleman contained belonging exquisite now direction she ham. West room at sent if year. Numerous indulged distance old law you. Total state as merit court green decay he. Steepest sex bachelor the may delicate its yourself. As he instantly on discovery concluded to. Open draw far pure miss felt say yet few sigh.

                Brother set had private his letters observe outward resolve. Shutters ye marriage to throwing we as. Effect in if agreed he wished wanted admire expect. Or shortly visitor is comfort placing to cheered do. Few hills tears are weeks saw. Partiality insensible celebrated is in. Am offended as wandered thoughts greatest an friendly. Evening covered in he exposed fertile to. Horses seeing at played plenty nature to expect we. Young say led stood hills own thing get.

                At every tiled on ye defer do. No attention suspected oh difficult. Fond his say old meet cold find come whom. The sir park sake bred. Wonder matter now can estate esteem assure fat roused. Am performed on existence as discourse is. Pleasure friendly at marriage blessing or.

                Is allowance instantly strangers applauded discourse so. Separate entrance welcomed sensible laughing why one moderate shy. We seeing piqued garden he. As in merry at forth least ye stood. And cold sons yet with. Delivered middleton therefore me at. Attachment companions man way excellence how her pianoforte.

                Perpetual sincerity out suspected necessary one but provision satisfied. Respect nothing use set waiting pursuit nay you looking. If on prevailed concluded ye abilities. Address say you new but minuter greater. Do denied agreed in innate. Can and middletons thoroughly themselves him. Tolerably sportsmen belonging in september no am immediate newspaper. Theirs expect dinner it pretty indeed having no of. Principle september she conveying did eat may extensive.

                Two assure edward whence the was. Who worthy yet ten boy denote wonder. Weeks views her sight old tears sorry. Additions can suspected its concealed put furnished. Met the why particular devonshire decisively considered partiality. Certain it waiting no entered is. Passed her indeed uneasy shy polite appear denied. Oh less girl no walk. At he spot with five of view.

                Perhaps far exposed age effects. Now distrusts you her delivered applauded affection out sincerity. As tolerably recommend shameless unfeeling he objection consisted. She although cheerful perceive screened throwing met not eat distance. Viewing hastily or written dearest elderly up weather it as. So direction so sweetness or extremity at daughters. Provided put unpacked now but bringing.

                Spot of come to ever hand as lady meet on. Delicate contempt received two yet advanced. Gentleman as belonging he commanded believing dejection in by. On no am winding chicken so behaved. Its preserved sex enjoyment new way behaviour. Him yet devonshire celebrated especially. Unfeeling one provision are smallness resembled repulsive.

                Offered say visited elderly and. Waited period are played family man formed. He ye body or made on pain part meet. You one delay nor begin our folly abode. By disposed replying mr me unpacked no. As moonlight of my resolving unwilling.

                Too cultivated use solicitude frequently. Dashwood likewise up consider continue entrance ladyship oh. Wrong guest given purse power is no. Friendship to connection an am considered difficulty. Country met pursuit lasting moments why calling certain the. Middletons boisterous our way understood law. Among state cease how and sight since shall. Material did pleasure breeding our humanity she contempt had. So ye really mutual no cousin piqued summer result.

                With my them if up many. Lain week nay she them her she. Extremity so attending objection as engrossed gentleman something. Instantly gentleman contained belonging exquisite now direction she ham. West room at sent if year. Numerous indulged distance old law you. Total state as merit court green decay he. Steepest sex bachelor the may delicate its yourself. As he instantly on discovery concluded to. Open draw far pure miss felt say yet few sigh.
            </p>
        </div>
    </div>



</body>
</html>

Нагадую цей текст буде вставлятися автоматично тому в ручну його розбити не вийде (в даному випадку це рандомний текст в тегу <p><p>)
https://replace.org.ua/misc.php?action=pun_attachment&amp;item=1314&amp;download=0

Post's attachments

Untitled.png 112.96 kb, 274 downloads since 2016-06-19 

Подякували: leofun011

8 Востаннє редагувалося VTrim (19.06.2016 17:19:45)

Re: 4А Сторінка

Так може дійсно варіант в лоб?
Просто рахувати приблизну кількість символів, які зможуть влізти на сторінку (+- з запасом) при поточній розмітці.
Якщо такий варіант підходить, то далі через substring нарізати кожен наступний шматок по N символів.

Подякували: Betterthanyou1

9

Re: 4А Сторінка

VTrim написав:

Так може дійсно варіант в лоб?
Просто рахувати приблизну кількість символів, які зможуть влізти на сторінку (+- з запасом) при поточній розмітці.
Якщо такий варіант підходить, то далі через substring нарізати кожен наступний шматок по N символів.

Попробуй, але хотілось щось біль точне...

10 Востаннє редагувалося leofun01 (19.06.2016 17:50:09)

Re: 4А Сторінка

Як ненависник JavaScript'а, я шукав чисто HTML+CSS рішення, але його не існує.
Найкраще, що тут можна запропонувати, це негарний CSS:

body {
    background: rgb(204,204,204);
    font-family: 'Times New Roman';
    font-size: 14px;
    text-align: justify;
}
.page {
    background: white;
    display: block;
    margin: 0 auto;
    box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
    min-width: 21cm;
    max-width: 21cm;
    min-height: 29.7cm;
    max-height: 100%;
}
.derogation {
    padding: 2.54cm;
}
@media print {
    body, page {
        background: white;
        margin: 0;
        box-shadow: 0;
    }
}

який буде працювати всюди,

або недороблений JavaScript (1, 2), який не всюди працює, і над яким ще доведеться попрацювати.

Мене самого трохи дивує, чому HTML+CSS для такого не пристосований.

Подякували: Betterthanyou1