How print document in blazor without dialog? - printing

I have pdf file which I need to print.
I use PrintingService for blazor, but it call dialog for printing. How I can not show this or post confirm answer programly?

Related

How to convert PDF web links to file open actions with python pdfrw library

I'm using pdfkit to convert html to pdf which works great, but the external links in the pdf are web links.
The pdf viewer that we are using does not recognize the pdf web links, but file open actions do work.
I've been trying to change the pdf link annotation from a web link to a file open action with the pdfrw library.
I tried to edit the pdf annotation with the following code, but it's not working.
annot.A.update(pdfrw.PdfDict( S='/Launch'))
annot.A.update(pdfrw.PdfDict( F={}))
annot.A.F.update(pdfrw.PdfDict( Type='/Filespec'))
annot.A.F.update(pdfrw.PdfDict( F='(part-1.pdf)'))
annot.A.pop('/Type')
annot.A.pop('/URI')
The link shows up in the new pdf, but there is no action or destination file associated with it.
So after a similar battle today...
you can't define S='/Launch' as string like that. You have to use:
annot.A.update(pdfrw.PdfDict( S=pdfrw.PdfName('Launch')))
Similarly with filespec etc. You may also need to take the () off the filename - as that seemed to break it, at least in Apple Preview.

jsPDF: issue with two-page pdf within Adobe Acrobat Reader

I am facing the issue with two-page pdf within Adobe Acrobat Reader.
I am creating 2 page pdf using jsPDF doc.fromHTML() method.
My pdf is shown properly with header and footer when opened with any browser. Al, so my printer is printing it properly
When I am opening it in adobe reader the second page is showing error while printing the pdf and even footer is also not present on the second page.
Please, can anyone help me in solving this issue?
I tried doc.addPage() but it's adding a blank page
Error Message while printing with Acrobat:
An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem
Try doc.addpage then add text to the second page using doc.text or doc.html
I was trying for days to fix that issue and found that it was causing from
setLineDashPattern
function.
I used dash patterns multiple times in my document and whenever I need to remove this global "line dash" settings from the document I was calling
doc.setLineDashPattern([0], 0);
When I debug my code line by line I found that this was the part that causes Adobe Acrobat to raise an exception. So I changed it to
doc.setLineDashPattern([], 0);
And viola!
Hope it helps someone, since I couldn't find anything about that.
Cheers

How to disable print dialog in Chromium?

There is web page, that has the "Print" button. I load it using DCEF3. If user clicks the button, the Printer selection dialog is shown. I want to disable printing once and for all.
I have been trying to pass command line parameters using the example.
So, I tried the following:
--disable-print-preview
--kiosk
--kiosk-printing
But none of them did the trick. Am I missing something?
CEF3 doesn't support "silent" printing, that is, printing without a printer selection dialog.
All you can do is :
Print to a temporal PDF file and then print the PDF file.
Take a snapshot from the browser and print the bitmap.
Modify the CEF3 libraries to hide the printer selection dialog.
These functions are much easier to use with CEF4Delphi or OldCEF4Delphi. To print in a PDF file all you have to do is call TChromium.PrintToPDF and to take a snapshot you need to call TChromium.TakeSnapshot
Not all the Chromium flags or command line switches are supported by CEF3. --kiosk and --kiosk-printing are not supported as you can see here.
You may even have to modify the JavaScript code in that web page to replace the "print" button function with a custom JavaScript extension registered with CEF3. That extension would send a message to the main browser process to print using your custom function.

Automatically Printing Page, then directing to next page

I am updating an old application, and have been asked to change the old Print routine (which just invoked the print command via javascript, and printed out the html), to one that prints out a pdf (the theory being that we then have more control of the pdf / how it looks etc across all printers.)
Using the Rotativa library, I can generate my pdf's, either on the fly or to a file.
After doing some reading, it appears impossible to stream a pdf from memory, and it has to be created as a file first, sent to the browser, and then deleted.)
the last line of my controller is;
return File(#"D:\Development\Source\Workspaces\ConsumerCreditLicenseSystem\Code\ConsumerCreditSystem\CCLSystem\_Idd\1.pdf", "application/pdf");
What I am strugglign with is getting that page to invoke the Print Dialog. If I send it to a new view with javascript to do this, then I am back to square one as the page is html not my pdf. Is there any way I can mark that my pdf is for printing, or combine it with some html so I can have the old faithful of
window.print();
in the document?
A PDF is not a webpage; it's a binary. When you send the PDF as a response to the user, you have no control over what happens on their end. If their browser is capable of viewing a PDF in place, it will display it; otherwise, it will prompt the user to download it. Either way, it will be up to the user whether they want to print it or not, and it will also be up to them to go back or whatever. You cannot redirect the user automatically at this point.
A slightly better option would be to redirect the user to another page, with a link to a view that will send the PDF down to them. Then, you can do things like force the PDF to download (so it's not rendered inside the same tab/window, effectively taking the user away from your site), or force the link to open in a new tab or window. However, you still will not be able to prompt the user to print.

Adobe Acrobat API - How to skip opening password protected PDFs?

I've been using Delphi and the Adobe Acrobat 9 API. I'm simply opening a PDF and printing it, followed by closing it without saving anything.
I'm having an issue while opening some PDFs though. If the PDF is password protected the Open method displays Adobe's "Input password" prompt. My application is running in an automated fashion, and therefor cannot proceed beyond this password prompt until somebody clicks cancel.
I've been looking for something that will either notify me that the file is password protected prior to opening it, or a parameter or something that will skip password protected files. I need my program to assume it cannot open any passworded PDF.
How about detecting whether the PDF is secured first before trying to open it?
I had a similar issue where I needed to find out if printing was allowed before doing a print commnad on the PDF. The API does not complain and the print function returns success even though the PDF file does not allow for printing.
I wrote a solution a while back by writing an Adobe plug in. If it's not out-of-the box, you 'll need to write a plug in.

Resources