print pdf #13528
Replies: 11 comments 31 replies
-
Like with a printer? Edit: Maybe this XAMARIN-Case works: https://www.syncfusion.com/kb/8767/how-to-print-pdf-documents-in-xamarin-forms-platform |
Beta Was this translation helpful? Give feedback.
-
The PrintManager.GetForCurrentView() is not supported for WinUI desktop applications (Used in the link above). I am struggling to find a solution to print a pdf document in .Net Maui (Windows platform). |
Beta Was this translation helpful? Give feedback.
-
In case it helps, I have a .NET MAUI demo that shows you how to do this using the native platform APIs to print a PDF file with a single line of code (after you've added the helper classes). private async void PrintPdf_OnClicked(object sender, EventArgs e)
{
var stream = await FileSystem.OpenAppPackageFileAsync("pdfviewer-overview.pdf");
// See the 3 classes in /Helpers/ folder.
var helper = new PrintHelper();
#if WINDOWS
helper.Print(stream, "pdfviewer-overview.pdf", this.Window.Handler.PlatformView as Microsoft.UI.Xaml.Window);
#elif __IOS__ || MACCATALYST || ANDROID
helper.Print(stream, "pdfviewer-overview.pdf");
#endif
} See the project for the rest of the info => https://github.com/LanceMcCarthy/CustomMauiExamples/tree/main/src/DocumentPrinting |
Beta Was this translation helpful? Give feedback.
-
Thank you @LanceMcCarthy , I will check definitely this out! |
Beta Was this translation helpful? Give feedback.
-
Anyone has success printing PDF by creating a webview with 0 width height and using javascript to do it |
Beta Was this translation helpful? Give feedback.
-
Anyone find a work around for this? |
Beta Was this translation helpful? Give feedback.
-
Its working LikeABo$$ OMG!!! Thanks Lance!! You are a life saver. You are
the best!!!
…On Tue, Aug 22, 2023 at 11:10 AM Lance McCarthy ***@***.***> wrote:
Thanks @Cywizz <https://github.com/Cywizz>!
@MichaelHall001 <https://github.com/MichaelHall001> I'm sorry for the
delay, I was on vacation last week and GitHub CodeSpaces was not sufficient
enough for me to say "yeah, it's fixed". I have updated the demo and used
Cywizz's abstraction approach to surface the common naming to the MAUI
layer:
[image: image]
<https://user-images.githubusercontent.com/3520532/262414624-2b7951aa-7c2d-4552-8edd-e605166a2444.png>
You can see the new code at the following locations:
-
https://github.com/LanceMcCarthy/CustomMauiExamples/blob/main/src/DocumentPrinting/DocumentPrinting/MainPage.xaml.cs
-
https://github.com/LanceMcCarthy/CustomMauiExamples/blob/main/src/DocumentPrinting/DocumentPrinting/Helpers/PrintHelper.Android.cs
—
Reply to this email directly, view it on GitHub
<#13528 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVPFYY3FXCZQZQ3GVJEL7XDXWTKXBANCNFSM6AAAAAAVF2IULE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
We never were able to get it working. It came up with no error messages
when we compiled it after you fixed it. My client couldn't get his blue
tooth printer to talk to the phone and stuff. We abandoned everything.
Sorry.
…On Thu, Sep 14, 2023 at 9:10 AM Nicolas Luza ***@***.***> wrote:
@LanceMcCarthy <https://github.com/LanceMcCarthy> hello, your project
works with the default pdf, but I try to put another pdf and I get
System.IO.FileNotFoundException: '33_5072.pdf', it is saving in
'\DocumentPrinting\DocumentPrinting\objœDebug\net7.0-android\assets', do
you know what could it be?
[image: image]
<https://user-images.githubusercontent.com/43099709/268002798-e986471f-41e9-471d-a1a1-e2dcadb76650.png>
thx
—
Reply to this email directly, view it on GitHub
<#13528 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVPFYY7ANYIFVK4GP675JZLX2MF5JANCNFSM6AAAAAAVF2IULE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hey! @LanceMcCarthy what if I don't want to print the pdf I want to print the image which path I am passing in a string. I am getting the file but it seems it is not getting loaded in the previewPages but the data is present is canvas children element and some how print task is not working proper, I am sharing my code can you help me out with this. public async void Print(Stream inputStream, string filepath, Window nativeWindow)
#if MACCATALYST |
Beta Was this translation helpful? Give feedback.
-
@LanceMcCarthy Yes, although I am getting image bitmap and it is also added in the canvas as I debug I can see canvas has added the image as its children, when I print then also the print is happening smoothly, The issue is with the preview only, for first time when it is been called it has the the data but still not visible in preview although for the second time also I can the image is been displayed in canvas. Here I had modified the code, if you found anything please let me know. Also it will help others who are facing issue in printing the image on Windows, All windows operations are working fine here except the previewPage functionality
#if MACCATALYST
#elif WINDOWS
#endif
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
how to print pdf?
Beta Was this translation helpful? Give feedback.
All reactions