none
[UWP]Printing an InkCanvas UWP RRS feed

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
  • Hi,

    Well, if you mean the PrintHelper could meet your requirement for printing ink strokes you could definitely use it. But in the ColoringBook sample, it needs PhotoPrintHelper for this requirement.

    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 10, 2018 6:16 AM
    Moderator
  • Hi:

    I continue with the same problem the parameter is not correct pixelWidth. now if I draw the stroke that is not image with extesion gif . The PhotoPrintHelper is needed

    Monday, December 10, 2018 11:28 AM
  • may be problem PagetoPrint.xaml with InkCanvas .
    • Edited by Javier Ra Friday, December 21, 2018 8:36 AM cooregir
    Monday, December 17, 2018 9:04 AM
  • Hi

    It can be a problem PagetoPrint if the stroke doesn't come out. 

    Friday, December 21, 2018 8:38 AM
  • How Can I print the stroke of the InkCanvas ?
    Wednesday, January 16, 2019 2:18 PM
  • How can I print the InkCanvas stroke, if I don't have an image
    in case of using PagetoPrint , ContinuationPage as I can configure it to show Print Preview
    Friday, January 25, 2019 7:50 PM