none
[UWP]Printing an InkCanvas UWP

All replies

  • Hi,

    If you want to print the InkCanvas, a possible way is that you could save the whole InkCanvas into a image then print the image. 

    You could use Win2D to save the InkCanvas into a image. Like this:

    CanvasDevice candev= CanvasDevice.GetSharedDevice();
    CanvasRenderTarget renderTarget = new CanvasRenderTarget(candev, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight, 96);
    
    using (var drawsession= renderTarget.CreateDrawingSession())
    {
        drawsession.Clear(Colors.White);
        
     drawsession.DrawInk(inkCanvas.InkPresenter.StrokeContainer.GetStrokes());
    }
    //save stream into image file 
    //you could try to save the stream into bitmap image directly
    using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
    {    
         await renderTarget.SaveAsync(fileStream, CanvasBitmapFileFormat.Jpeg, 1f);
    
    }
    
    Then you could try to print the image that contains the whole InkCanvas


    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 30, 2018 3:28 AM
    Moderator
  • For example : in the App ColoringBook appears PrintHelper.cs and photoPrintHelper.cs here appears in the preview what has been drawn in the inkCanvas
    Friday, November 30, 2018 7:37 PM
  • Hi,

    Do you mean the sample ColoringBook? If this sample could met your requirement, you could refer it definitely.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, December 3, 2018 2:49 AM
    Moderator
  • This problem
    Tuesday, December 4, 2018 2:21 PM
  • Hi,

    Form the screen shoot I could only know there is a ArgumentException. But I could not know the detail message. Could you please copy the detail message to me or translate it to English?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 5, 2018 7:57 AM
    Moderator
  • Hello:

    The parameter is not correct 'pixelWidth'.

    Here I have a question when you do PhotoPrintHelper you need PrintHelper


    • Edited by Javier Ra Wednesday, December 5, 2018 9:25 AM mistake
    Wednesday, December 5, 2018 9:12 AM
  • Hi,

    So the exception is related to the pixelWidth and you will need to check this parameter again.

    >>Here I have a question when you do PhotoPrintHelper you need PrintHelper

    I'm little confused about this? Could you explain this to me with more description?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 6, 2018 5:46 AM
    Moderator
  • Hi:

    I said if PhotoPrintHelper depends on PrintHelper.cs, if PagetoPrint.xaml is needed, continuationPge.xaml

    Thursday, December 6, 2018 5:23 PM
  • Hi,

    Yes of course, the PhotoPrintHelper class is inherited from PrintHelper class. PrintHelper class defined some proerties and methods used in the PhotoPrintHelper class.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, December 7, 2018 7:52 AM
    Moderator
  • Hi:

    it is also mandatory to have PagetoPrint.xaml, ContinuationPage.xaml

    Friday, December 7, 2018 8:05 AM
  • To print the stroke you need PhotoPrintHelper, PrintHelper is enough.
    Friday, December 7, 2018 8:33 AM