Print multipaged WPF control without page breaking on a line of data C# -


i made invoice has listview on bottom list of line items. can run on 1 page mark overloaded documentpaginator class allow me print multiple pages. however, cuts page in middle of line of listview. found article uses bitmap of wpf control, checks color of pixels of line determine if there whitespace or data (code below). when make control bitmap though, spacing , line height different when print wpf control xps or printer. other ideas out there on how intelligently break pages or bitmap match xps?

 private void getgoodcut()     {         int goodcut = _lastcut;          int lastnumber = 0;         int numbercount = 1;         // @ most, take 32 pixel lines find white space         (int = 0; < 32; i++)         {             int number = rowpixelwhitecount(_bitmap, goodcut);             goodcut--;              if (number == lastnumber)             {                 numbercount++;                 // white space count between lv lines 12                  if (numbercount == 12)                 {                     lastnumber = - 6;                     break;                 }             }             else             {                 // if started inside white space, can break if starting before/at middle of white space                 if (numbercount > 5)                 {                     lastnumber = - 6;                     break;                 }                 numbercount = 1;             }              lastnumber = number;         }          _lastcut -= lastnumber;     }   private int rowpixelwhitecount(system.drawing.bitmap bmp, int row)     {         int colorcount = 0;         system.drawing.imaging.bitmapdata bmpdata = bmp.lockbits(new system.drawing.rectangle(0, 0, bmp.width, bmp.height), system.drawing.imaging.imagelockmode.readonly, bmp.pixelformat);         int stride = bmpdata.stride;         intptr firstpixelinimage = bmpdata.scan0;          unsafe         {             byte* p = (byte*)(void*)firstpixelinimage;             p += stride * row;  // find starting pixel of specified row             (int column = 0; column < bmp.width; column++)             {                 // printing in black/white, non-black pixels                 byte blue = p[0];                 byte red = p[1];                 byte green = p[3];                 if (blue > 0 && red > 0 && green > 0)                     colorcount++;                  // go next pixel                 p += 3;             }         }         bmp.unlockbits(bmpdata);         count.add(colorcount);          return colorcount;     } 

i believe secret printing multiple pages wpf application use multiple fixeddocument elements... can use documentpaginator element in process. documented online, won't go on again here. instead, please refer wpf printing part 2 – fixed document page on nbd tech website full story.

as additional help, can refer advanced wpf part 2 of 5: printing in windows presentation foundation page on abhishek shukla's website.

finally, if else fails, might interested in using code wpf print engine: part i page on code project.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -