@media print Text alignment
« on: January 09, 2024, 11:25:32 AM »
Hello, my dears. I have a question. How do I do that so that the text is in the middle and not at the top in the print preview, and I can't even manage the line spacing. Am I doing something wrong or is it something to do with osclass itself?


Code: [Select]
<style>
             
             @media print {
#print {
    min-height: 10em;
    display: table-cell;
    vertical-align: top;
    position: relative;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%)
     }
             
          .centered {
  position: relative;
  vertical-align: top;
  top: 80%;
  left: 50%;
  transform: translate(-50%, -50%);
}
          </style>
         
          <script>
             
        function printDiv(print){
              var restorepage = document.body.innerHTML;
              var printcontent = document.getElementById('print').innerHTML;

              document.body.innerHTML = printcontent;
                 
              window.print();
                 
              document.body.innerHTML = restorepage;

}
</script>
         
          <details>
          <summary><h1></h1></summary><button onclick="printDiv('print')">Print</button><div id='print'>
             
              <p><center><div><h1><?php echo osc_item_category() ; ?></h1></div></center></p>
              <p style="line-height: 150%"><center><div><font size="5" style="display:table-cell; vertical-align:middle; font-weight:bold;"><?php echo osc_item_title(); ?></font></div></center></p>
              <p></p>
              <p class="centered" style="line-height: 150%"><center><div><p><span><font  size="5" style="display:table-cell; vertical-align:middle; font-weight:bold;text-align: end; position: relative;"><?php echo osc_item_formated_price(); ?></font></span></p></div></center>

*

MB Themes

Re: @media print Text alignment
« Reply #1 on: January 10, 2024, 09:09:54 AM »
Easiest way is to use display flex and auto margins. But not sure how much is supported with print.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: @media print Text alignment
« Reply #2 on: January 10, 2024, 02:12:16 PM »
That does not work. I would like it to be like in the picture. So the text is there in the red area with line spacing.


*

MB Themes

Re: @media print Text alignment
« Reply #3 on: January 10, 2024, 02:46:45 PM »
There are various techniques to centralize content but not going to test it here :)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: @media print Text alignment
« Reply #4 on: January 10, 2024, 03:32:58 PM »
Thanks for this information, but how could I implement this using CSS? I've already tried a few things.

*

MB Themes

  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: @media print Text alignment
« Reply #6 on: January 12, 2024, 01:42:28 PM »
Thanks, I'll try it.

Re: @media print Text alignment
« Reply #7 on: January 12, 2024, 03:15:36 PM »
I once did it like this, so the line spacing is visible on the website, but not in the print preview.

I don't understand why @media print doesn't include it, maybe I'm missing something.

Code: [Select]
<style type = "text/css">
 @media print {
  .centre {
    line-height: 5.5em ;
    margin:0 ;
    font-size: 12pt;
  }
}   
          centre {
         
 line-height: 5.5em;
         
}
     
             
          </style> <details>
          <summary><h1></h1></summary><button onclick="printDiv('print')">Print</button><div id='print'>
              <img src="https://haushaltgeraete-chemnitz.com/Sale-banner.png" alt="" width="500" height="600"><br>
              <centre class="centre"><p style=“line-height: 200%“><center><div><h1><?php echo osc_item_category() ; ?></h1></div></center></p></centre>
              <centre class="centre"><p style=“line-height: 200%“><center><div><font size="5"><?php echo osc_item_title(); ?></font></div></center></p></centre><br>
              <p></p><br>
              <centre class="centre"><p style=“line-height: 200%“ ><center><div><p style=“line-height: 200%“><span><font size="5" ><?php echo osc_item_formated_price(); ?></font></span></p></div></center></p></centre><br><?php if( osc_count_item_meta() >= ) { ?>
      <div id="custom_fields">
        <div class="meta_list">
          <?php while ( osc_has_item_meta() ) { ?>
            <?php if(osc_item_meta_slug()!='festpreis') if(osc_item_meta_slug()!='evp') { ?>
              <div class="meta">
                  <strong></strong> <centre class="centre"><p style=“line-height: 200%“><center><span><?php echo osc_item_meta_value(); ?></span></center></p></centre><br>
              </div>
            <?php ?>
          <?php ?>
        </div>
      </div>
    <?php ?>
              </div>
</details>

*

MB Themes

Re: @media print Text alignment
« Reply #8 on: January 12, 2024, 03:41:38 PM »
Media query may not support everything.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: @media print Text alignment
« Reply #9 on: January 15, 2024, 01:24:33 PM »
Yes, that is possible, what can I do about it? does anyone have an idea?

*

MB Themes

Re: @media print Text alignment
« Reply #10 on: January 15, 2024, 02:22:35 PM »
No plan to invest time in these, pretty sure there are more focused forums on such topic.
Printing is very limitted in these days.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: @media print Text alignment
« Reply #11 on: January 15, 2024, 04:15:33 PM »
I was able to solve it easily using tables as a distance, it looks very good.
I would like to thank everyone who gave me tips here.

Now my osc_item_meta_value just needs a QR code, but that's another topic.

If you would like to have it for your A4 A4 display, perhaps for your business/store, here is the code.


Code: [Select]
<style type = "text/css">
 @media print {
  .centre {
    line-height: 9.5em ;
    margin:auto;
    font-size: 12pt;
    content:"10";
  }
}   
          centre {
         
 line-height: 5.5em;
         
}
           
 @page{
    size:5.5in 2in;
    marks:crop;
    bleed:0.125in;
    margin:0.55in;
}           
           
     
             
          </style>
              <script>
             
        function printDiv(print){
              var restorepage = document.body.innerHTML;
              var printcontent = document.getElementById('print').innerHTML;

              document.body.innerHTML = printcontent;
                 
              window.print();
                 
              document.body.innerHTML = restorepage;

}
</script>
          <details>
          <summary><h1></h1></summary><button onclick="printDiv('print')">Print</button><div class="centre" id='print'>
              <img src="https://haushaltgeraete-chemnitz.com/Sale-banner.png" alt="" width="500" height="600"><br>
              <centre class="centre"><p style=“line-height: 200%“><center><div><h1><?php echo osc_item_category() ; ?></h1></div></center></p></centre>
              <table height=50><tbody><tr><td></td></tr></tbody></table>
              <centre class="centre"><p style=“line-height: 200%“><center><div><font size="5"><?php echo osc_item_title(); ?></font></div></center></p></centre><br>
               <table height=20><tbody><tr><td></td></tr></tbody></table>
              <center><p><?php if(function_exists('prt_tag_item')) { prt_tag_item(osc_item_id()); } ?></p></center><br>
              <table height=50><tbody><tr><td></td></tr></tbody></table>
              <centre class="centre"><p style=“line-height: 200%“ ><center><div><p style=“line-height: 200%“><span><font size="8" ><?php echo osc_item_formated_price(); ?></font></span></p></div></center></p></centre>
              <br><table height=100><tbody><tr><td></td></tr></tbody></table>
                  <?php if( osc_count_item_meta() >= ) { ?>
      <div id="custom_fields">
        <div class="meta_list">
          <?php while ( osc_has_item_meta() ) { ?>
            <?php if(osc_item_meta_slug()!='festpreis') if(osc_item_meta_slug()!='evp') { ?>
              <div class="meta">
                  <strong></strong> <table><tbody><tr><td></td></tr></tbody></table><centre class="centre"><p style=“line-height: 200%“><center><span><h1><?php echo osc_item_meta_value(); ?></h1></span></center></p></centre><br>
              </div>
            <?php ?>
          <?php ?>
        </div>
      </div>
    <?php ?>
              </div>
</details>