.NET Core Pdf silent print -- from a service - asp.net-core

I am search for a Free SDK to print pdf direct to printer queue(s) .
preferred,with printer settings.
I have tried to use IronPdf.PdfDocument,
IronPdf.PdfDocument pdf = new IronPdf.PdfDocument(path);
pdf.Print();//delay for a minute +;
it partially work because some printing (some printers) take more than 60 seconds (instead of a moment)

Related

Converting Windows .PRN file (PCL) to PDF

I have been succesfully capturing PCL content sent by old machinery to a parallel port and converting it to PDF using GhostPCL for a while.
However, we have some older industrial machinery which is based on Windows 2000 and outputs to a HP Laserjet printer via the parallel port. Unfortunately, the software on the machine does not allow additional software or printers to be installed.
The problem is that whilst the captured output appears to be PCL graphic data, I have not found any tools which can convert it - GhostPCL attempts, and you can make out the text a little, but it is completely corrupted.
The captured output results in the output from GhostPCL
I can see that the captured output starts with:
ESC E (PCL command for Reset)
ESC &l0L (PCL command to disable skip perforation)
ESC &r1U (*** UNKNOWN ***)
ESC &l1H (PCL command to Feed from tray 2)
ESC *o0M (*** UNKNOWN ***)
ESC &126A (PCL command for A4 portrait paper)
ESC *g8W (PCL command to configure raster data - 8 bytes)
I can see that the captured output has some PCL codes which do not appear in the official documentation, which results in the weird characters at the start of the PDF.
Does anyone know how to convert this file to PDF ?
Your description shows an attempt to read a language different to pcl, so was the older system designed to talk to a default printer using Epson ESCAPE encoding. so its a dot printing file that the hardware will position those dots in the correct place and pressure, you could try converting to a bmp then massage the image into a pdf page.
You say an HP is connected but is that the true capture of what it is agreeing to use at runtime?
For example If I attempt to save my HP inkjet print file at time of printing I will get a PDF ! but why since the printer normally cant handle those direct?
What may I find If I look and see the default printing language is not set to a PCL or a PJL one.
There are many pcl language variations so a PRN file ideally should have some compatibility declaration such as #PJL ENTER LANGUAGE = PCLXL ) HP-PCL XL;2; Note this is NOT an HP printer just one that declares the following code will be HP style.
The printer can accept many formats and the system can produce many different formats for one printer. Thus you need to check all the system settings to understand what language is actually in run time use. Are you sure that .PRN is a full load of the conversation between the system & printer as print to file is not always the expected 2 way code.
The best way to ensure you capture true printer driver output is to change the drivers output PORT to a fixed filename and ideally use the correct format extension NOT unspecified .prn or .pcl if it is not such.

Link print setting to a PDF document

I have a PDF document and I want to know if there is a way that I can embed print setting into it - such as Page sizing to Actual size and print on both sides.
So when people print the PDF they don't need to change the print settings manually.
Parts of this can be done with the "Viewer Preferences" dictionary (see PDF 1.7 specification section 12.2 for details):
PrintArea
PrintClip
PrintScaling
Duplex
PickTrayByPDFSize
PrintPageRange
NumCopies
However, as usual this depends on the PDF viewer actually using these options. So you might wanna try this out with the PDF viewers your clients use.

PDF to PostScript Using Ghostscript: large files having issues printing

I'm currently using Ghostscript to convert 500 page PDF files into PostScript.
I'm using Windows 7, Ghostscript x64 v 9.16, and a Kodak Digimaster Commercial Printer.
I use the following arguments for GhostScript to convert a PDF into PS:
C:\Program Files\gs\gs9.16\bin\gswin64c.exe"
-dCompressFonts=true
-dSubsetFonts=true
-dEmbedAllFonts=true
-sFONTPATH=C:\Windows\Fonts\
-dNOPAUSE
-dBATCH
-sDEVICE=ps2write
-sOutputFile="PostScript.ps"
"MyPdf.pdf"
I then add %KDK (proprietary) commands to dictate which pages need to print on which paper by using the %KDKSlip command based on the Printer documentation.
The example below would print all pages on Letter duplex except for pages 1/2 and 5/6. Pages 1/2 would print on a paper defined under the name of "YellowPerf", while 5/6 would print on "TriPerf":
%!PS-Adobe-3.0
%%BoundingBox: 0 0 612 792
%%HiResBoundingBox: 0 0 612.00 792.00
%%Creator: GPL Ghostscript 916 (ps2write)
%%LanguageLevel: 2
%%CreationDate: D:20150506143059-05'00'
%%Pages: 8
%%DocumentMedia: Letter 612 792 0 white ()
%%+ YellowPerf 612 792 0 yellow ()
%%+ TriPerf 612 792 0 white ()
%KDKRequirements: duplex
%KDKSlip: YellowPerf duplex 1
%%+ TriPerf duplex 5
%%EndComments
%%BeginProlog
This is then sent to a Kodak Digimaster printer using a Windows command:
> COPY PostScript.ps PrinterName
This has worked fine with smaller documents, but I'm having issues with larger page sets.
When I attempted to print to the Digimaster using a 500 page PDF to Postscript file, it had errors occur: "Busy, do not reset the RIP".
File size of those that didn't work:
PostScript File Size: 52 MB
PDF File Size: 41 MB
File sizes of those that did work:
PostScript File Size 1MB
PDF File Size: .8 MB
Why does this work fine with smaller files but get hosed on larger files?
Would anyone have any advice?
It is not necessarily the filesize of the PostScript that causes your problem:
It could be the PostScript itself, or
it could be that you made a mistake with your editing of the PS files when you inserted the (proprietary) %KDK-comments.
Are you sure your text editor doesn't silently change your linefeed characters?! This could also change the binary parts of the PostScript!
Also, I'm not sure if the copy command does handle print jobs like it should. I would prefer the lpr command (ah... is that even still available on your version of Windows?!)
To debug this and to explore a few different roads to successful printing, I would try a few different steps:
To debug
Send the original PostScript, without the added %%KDK DSC header comments, to the printer.
That printer model has a nice feature you can utilize: you can check if its RIP processes the input file completely and successfully without needing to output your 500 pages on (wrong) paper and waste it therefore (you'd also need to discard it afterwards -- too much work too). Just click the red "Stop" button on its user interface monitor.
Does that one complete the RIP process successfully?
Yes? Now you can now even print it. Before you do so you can even modify the job settings to select a particular paper tray, by clicking on some button on the interface (can't recall the exact button label though). Then "release" the job and it will print.
If it worked, you can again turn your attention to get your %%KDK lines right.
If it didn't you have to try another route.
Check if a different PDF-to-PS converter is working
Create a PostScript file with the help of pdftops (see here for the pdftops.exe version -- read the README to see which options are available).
Proceed analog to above: first see if it completes the RIP process. Then continue with your %KDK manipulations....
Check if the direct PDF printing is working
The Digimaster model can consume PDF directly. (Well, internally it uses its own PDF-to-PS converter, but that isn't visible to the outside -- so it doesn't really count as a PDF RIP...)
If that works, you can even prepend your appropriate %KDK comments to the PDF file, similar to the lines below (don't rely on me getting the details right, it's from the top of my head, and memory is decades old!):
%!PS-Adobe-3.0
%%.........................
%%DocumentMedia: ..........
%KDKRequirements: .........
%KDKInserts: ..............
%KDKSlip: .................
%KDKBody: .................
%KDKCovers: ...............
%KDKPDFPrintAnnotations: on
%KDKPDFFitToPage: on
%KDKBinaryOK: on
<esc>%-12345X
%%Emulation: pdf
%PDF-1.5
%...here follow the lines of the original PDF file...
...
Send jobs via "Kodak Printfile Downloader" (KPD)
For Windows there used to be the so-called 'Kodak Print File Downloader' (KPD). The KPD is an application, not a printer driver. Not sure if it is still available.
You could open its GUI, then load a PS, PDF, PCL or TIFF file into its to-be-printed-list of jobs. Then select a few job options (like trays, stapling, sorting etc.). Lastly, send the job off to the Digimaster...
The KPD essentially does the same thing, as you want to achieve: insert %KDK commands into the file header. But you want to do it with a script or an editor (and possibly automatically via a batch process, once it works).
The KPD requires interactive user activity and cannot be scripted.
But you can (ab-)use it to intercept the files it creates from the Windows spooling system, study them and then adapt your scripted efforts so that they also work....
Update
(I had wanted to add this already in my initial answer. But time ran out, so I skipped it for the time being..)
Observe the RIP processing directly at the printer UI
Digimaster printers have their own built-in touchscreen or flatscreen or tube monitor (depending on the age of the model). They also typically have a full-time operator who knows the machine and its tweaks and peculiarities quite will. The machine may be quite a distance from the user sending a job.
So the following should be done when debugging a print problem:
Ask the operator to set the printer to "stop printing", but still "receiving new jobs".
Submit any job(s) you want.
Walk up to the printer and its operator.
Release the job for RIP-ping and observe what happens:
You may see everything going alright and completing until the last page (you know how many pages you submitted, right?)
Or you may see the job aborting at a certain page number.
Or you may see the printer RIP chewing extremely long on a certain page (or several pages), but finally completing the job.
Or you may see the printer RIP hanging with a certain page forever.
Or...
In any case, the details which are observable here may give important clues about where to look next...

Windows 8, Print to PostScript printer to file

Am I missing something stupid simple?
I have a new Windows 8 machine... 64-bit.
From an app on my old machine, I generate report output to a "Generic PostScript Printer" which is configured to be sent out to FILE (not LPT, COM, TCP/IP).
While trying the app, it fails to generate the output to the text file provided.
So, I'm taking my application out of the equation. I just go to control panel, pick this printer and tell the Windows printer dialog to do a test print. It comes up with a dialog to enter the file name and I put it into a folder that I have full permissions to... It fails... I even tried as "Administrator" to remove any possible "permission" issues and it still fails.
What am I missing on something that should otherwise be so simple, that even MS dialog / test print doesn't work.
To clarify what I DID do..
Control Panel - get to devices / printers
Add Printer -- clicked on the "printer not found"
Radio for "Add a local printer or network printer..." -- next
Use an existing port -- FILE: (Print to File) -- next
Manufacturer - Generic -- Printers - Generic XPS Class Driver (A) -- next
(used the driver already installed since I tried previously) -- next
Printer name: -- left alone by default of "Generic Color XPS Class Driver (A) -- next
Do not share this printer -- next
Print a test page -- dialog defaults to "Libraries\Documents\", I entered myTest.prn -- Save
It APPEARS to generate the file... however, it only creates the file as a zero-byte size
UPDATE... While digging and struggling, I actually opened a support ticket with Microsoft. They have confirmed that this specific process IS a bug and will be working on a patch (to be delivered with other patches when ready).
ANOTHER UPDATE !
Apparently, the machine I bought from DELL only had Windows 8 BASIC version. Through many support calls back and forth, it is a specific issue when trying to use certain printer drivers (such as Microsoft PS Color Printer -- for Post-Script output), from the default drivers provided with new machines with Windows installed.
OUR WORK AROUND.
For grins, I ultimately went out to HP's website (how common are HP printers :), and downloaded the printer driver for a 2500 LaserJet and install THAT version of PostScript printer. After installing that, and trying the output, I can generate the output to a textfile without problem... even when default setting is to LPT1: and being redirected to an output text file for postscript content.
So, ultimately, issue resolved by using ANOTHER Vendor's printer driver for postscript printing and I'm good to go.

transparent pdf printing/preview in VB6

I am working on a legacy app in VB6 and am wondering what the easiest way would be to implement this requested feature - client wants ability to preview a document being sent to the printer as a PDF. No problem - there are plenty of PDF printer drivers out there that one can use. However, a necessary condition of this feature is absolute transparency - in other words, it should work out of the box after installation of the app, without having to say "To use this feature go to such-and-such website and download this pdf printer driver." In addition, client does not want to see a "Save As..." dialog. The ideal function of the feature is that a button is clicked, and what would have been sent straight to the printer is instead instantly previewed as a PDF that pops up with no further interaction with the user other than the user's initial pressing of a button.
Of course, there are a gazillion PDF packages out there, but they all seem to be along the lines of "here's an API where you can generate PDFs by directly writing lines, circles, graphics, text in specified fonts right to the PDF file". I do not want this - I want something that takes the data that is going right to the printer and pop it up as a PDF without a Save As
Now, CutePDF seems to have something like what I am looking for with their Custom PDF Writer (http://www.cutepdf.com/Solutions/pdfwriter.asp), but a) they do not seem to have an evaluation version; b) they do not seem to have much documentation about it that I can see, and c) it's freakin' expensive
Does anyone know if anything else like CutePDF Custom PDF Writer exists, or is that the only one of its type? I am open to any software as long as it gets this done, be it commercial, shareware, open source, whatever, so long as it satisfies the requirements of:
Must be a PDF printer (i.e. take the data going to the printer and turn it into a PDF)
must be completely transparent to end user (i.e. user must not have to change their printer settings and then change them back, or deal with a Save As dialog and then open the file they saved - it needs to just pop up)
must work with VB6
must be able to be packaged and installed along with the app without the end user having to run another setup program
any ideas?
Thanks in advance :)
We've started using Bio PDF Writer, available here: www.biopdf.com.
It does offer the ability to silently install (which we do). It also offers the capability to write out to a pdf file silently, requiring an ini file to be created first to do so.
However, it is more expensive for a site license than CutePDF is (1,499 vs 299/499). you can buy a single license for 29.99 (USD). This may cover their needs (if it is just one client). Their documentation is pretty decent and they do have a trial version (that, as far as I can tell, has no limitations to it).
You should be able to use any PDF printer software that provides a silent install option and just set the current printer when you need to print via PDF:
Dim oldPrinter as VB.Printer
Set oldPrinter = Printer
Dim p as VB.Printer
For Each p In VB.Printers
If p.DeviceName = "PDF Printer Name" Then
Set Printer = p
End If
Next
' Print Document Here '
Set Printer = oldPrinter
Note: You will need to ensure distributing and installing isn't in violation the license agreement