locked
A5 Printing using Raw Data in C# RRS feed

  • Question

  • http://support.microsoft.com/kb/322091

    I have used the above to link to print raw data this works fine. But my requirement is how do i print this same logic to print the data in A5 sheet for printing. 

    when i select print it should print the raw data in A5 sheet without any dialog.

    Currently it prints the A4 size in A5 sheet so data is not accurate.

    Let me know how can i achieve this.

    Thanks



    Sunday, July 21, 2013 8:31 AM

All replies

  • Hi abdul2smart,

    From your description, I know you want to print file to A5 paper, but when you print the A4 size in A5 sheet so data is not accurate. The reason is A5(148mm*210mm) paper is smaller than A4(210mm*297mm) paper. I think you can set the Paper size when you print A4 size in A5 sheet. You can set this property in Printer’s Properties.

    I created a Windows Form Application follow the above link to test, it works fine. My working environment is Window 8 Pro, HP LJ602 Printer.

    If I misunderstood, please let me know.

    Best Regards

    Jimmy

    Monday, July 22, 2013 5:36 AM
  • Thanks jimmy for your post.

    I did try that..

    PaperSize paperSize = new PaperSize("A5 (210 x 148 mm)", 0, 0);  

    PrinterSettings.DefaultPageSettings.PaperSize = paperSize;

    but it doesn't work.

    looking for other workaround.

    Thanks

    Monday, July 22, 2013 11:18 AM
  • Hi,

    According your description and Code, I think whether you can set Paper size like this (Please modify code according to your need).

    IEnumerable<PaperSize> paperSizes = settings.PaperSizes.Cast<PaperSize>();
    PaperSize sizeA5 = paperSizes.First<PaperSize>(size => size.Kind == PaperKind.A5);
    PaperSize sizeA4 = paperSizes.First<PaperSize>(size => size.Kind == PaperKind.A4);
    settings.DefaultPageSettings.PaperSize = sizeA5; 
    

    Here are some related references.

    http://stackoverflow.com/questions/2595610/printablearea-in-c-sharp-bug

    http://stackoverflow.com/questions/14361662/printing-html-in-a4-and-a5-paper-format

    http://stackoverflow.com/questions/12351375/how-can-i-set-printpriviewdialog-papersize-to-a5-in-c-sharp-codebehind

    Best Regards

    Jimmy


    Jimmy Yang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 24, 2013 7:23 AM
  • Jimmy,

    It doesn't help at all. still it is printing the A4 data in A5 sheet so the data is not accurate i already did seen the above links.

    I'm sending the print data as stream of bytes to printer.

    Thanks

    Sunday, July 28, 2013 5:58 AM