HI, i want to convert xps file to pdf file and add a background in c# i did it by using Microsoft print to pdf but the problem that i cant add a background i try to add background to xps then convert it to pdf using microsoft print to pdf RRS feed

  • Question

  • i do not want to use any referance like spire or iTextsharp...etc  i want to do it totaly from micosoft 


    Wednesday, September 9, 2020 9:06 PM

All replies

  • Hello,

    Use PdfSharp, under downloads get the binaries. Add them to your project. Then use it e.g.

    var xpsFileName = Combine(AppDomain.CurrentDomain.BaseDirectory, "documentation.xps");
    var pdfFileName = Combine(AppDomain.CurrentDomain.BaseDirectory, "documentation.pdf");
    PdfSharp.Xps.XpsConverter.Convert(xpsFileName, pdfFileName, 0);

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Wednesday, September 9, 2020 10:31 PM
  • Hi mahmoud sleem,

    Thank you for posting here.

    I found a post whose problem seems to be similar to yours. Please check if the solution in the post works for you.

    Print FixedDocument/XPS to PDF without showing file save dialog

    Best Regards,


    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, September 10, 2020 1:37 AM