Print with XPS and Printer in the same time - printing

  Can you print at the same time in two modes?
1- XPS
2- Printer (َAll models)
If the above item is not possibleو Could you write a program in C# to save a copy of it as a file in the form of an X before printing?
Please guide me in this regard
thanks in advance

The Win2PDF printer can do this. When you print to the Win2PDF printer, change the "Save As Type" to XPS, and check the "Print File" option:
If you want to save and print the file without displaying the File Save window, you can enable the Win2PDF "Auto-name" feature as described here:
https://www.win2pdf.com/doc/automatically-name-pdf.html

Related

are there some way to print by xps printer without show the save dialog?

I'm trying to print by XPS PRINTER without the save dialog.
I'm using the Printer Object on VB6.
Any Idea?
It's not possible to control the XPS Document Writer file name from VB6, but it is possible using a third party product named Win2PDF. To set the XPS file name in Win2PDF, you use the SaveSetting method to save the file name to the registry as in:
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFFileName", "c:\test\test.xps"
After calling SaveSetting with the key set to "PDFFileName", you print to the Win2PDF printer using the VB6 printer object to create the XPS file.

Using printer name Adobe PDF

I have looked everywhere for this solution. The code below allows me to print to the printer, Adobe PDF, but what I want to do is automate the file name save as screen with a generic name and in a specific folder. For example, the file would be saved to C:\temp\tmpResize.pdf and I am having problems there.
var params = this.getPrintParams();
params.interactive=params.constants.interactionLevel.silent;
params.pageHandling=params.constants.handling.none;
params.fileName = "/c/temp/tmpResize.pdf";
params.printerName="Adobe PDF"
this.print(params);
Thanks for your help.

Print MigraDoc document to specific printer

I've created a MigraDoc/PdfSharp document and now need to send it to a specific printer without any user interaction.
What do I need to use as a Renderer and how do I set the printer path/name to the MigraDocPrintDocument?
MigraDocPrintDocument is the correct class.
// Creates a PrintDocument that simplyfies printing of MigraDoc documents
MigraDocPrintDocument printDocument = new MigraDocPrintDocument();
// Attach the current printer settings
printDocument.PrinterSettings = printerSettings;
We use System.Windows.Forms.PrintDialog() to let the user select the printer (this dialog fills the printerSettings structure).
Use
internal PrinterSettings printerSettings = new PrinterSettings();
for the default printer. Change this structure to print with different settings or on a different printer.
Please note that with PDFsharp 1.31, printing will work with the GDI+ build only (the WPF build will not print the document correctly).

Offending Command error while Printing EPS

I am printing an EPS File generated with following credentials.
%-12345X#PJL JOB
#PJL ENTER LANGUAGE = POSTSCRIPT
%!PS-Adobe-3.0
%%Title: InvoiceDetail_combine
%%Creator: PScript5.dll Version 5.2.2
%%CreationDate: 10/7/2011 4:46:59
%%For: Administrator
%%BoundingBox: (atend)
%%Pages: (atend)
%%Orientation: Portrait
%%PageOrder: Special
%%DocumentNeededResources: (atend)
%%DocumentSuppliedResources: (atend)
%%DocumentData: Clean7Bit
%%TargetDevice: (HP Color LaserJet 4500) (2014.200) 0
%%LanguageLevel: 2
%%EndComments
While doing Selection Printing on Ricoh Afficio 2090 or any other drivers/printers get the following error printed on the sheets
ERROR: undefined
OFFENDING COMMAND: F4S47
Stack:
.
Kindly Review and suggest a turn around for the same as i am already stuck in this hell. I have tried to convert/extract in PS but all in vain. I am using gsview to Print and view these files.
This is the problem:
%%PageOrder: Special
A ps document with "Special" page order can NOT be re-ordered. You cannot do a selection or range with this file because it is broken for this use. You must reprocess the file using Distiller or ghostscript (ps2ps or ps2pdf) in order to print selected or re-ordered pages from the document.
You can avoid this by generating your postscript files with a real Postscript™ driver (one not created by Microsoft).
The GSView Documentation has more about this.
Previously:
This line ...
%%TargetDevice: (HP Color LaserJet 4500) (2014.200) 0
... tells us that the file was generated with HP printers as a target. So this really is not an EPS file. Because it's not Encapsulatable. To generate output on a printer the file has to execute the showpage operator, which is a no-no for EPS files.
So uncheck the EPS box (it's a big fat lie, anyway), and select (install) a Generic Postscript driver. If you need to send it to multiple makes of printer, the file needs to make as few assumptions about the printer as possible.
The first thing is that this is not a valid EPS file, as it has PJL attached at the front. Many PostScript printers will strip this off, but by no means all.
This probably is not the source of the problem.
There is no way to 'review' the problem as you have not supplied the complete PostScript program. Without that there is no way to tell what is actually wrong, the error message tells you that the interpreter encountered 'F4547' while trying to parse a token, and that this has not been defined as a routine.
Most likely the file is corrupt, either damaged in some way, or possibly it is a biinary file and has been transmitted by some process which does has done some kind of conversion (CR/LF is common). The offending command looks like its ASCIIHex encoded, so that may be a red herring.
If you want additional help, you are going to have to make the whole program available somewhere.

Way to default the name of the generated XPS file?

If a user prints a report, and they happen to be using the Microsoft XPS printer, i would like the default the filename to something meaningful.
i would have thought that the XPS printer would take the name of the print job, and use that as the default filename - but it doesn't.
Is there some other, programatic, way to default the name of the generated XPS file when i print to that printer? i was thinking there might be something like:
a registry key
global shared memory
API call like SetDefaultXPSFilename()
extended attributes about a print job
Example
Automate Excel to create a spreadsheet:
Excel xl = new ExcelApplication();
Workbook wb = xl.Workbooks.Add();
GenerateReport(wb);
wb.PrintOut();
Now if the user's default printer is the Microsoft XPS Document Writer, then the user will get:
i would like a way for that File name to be defaulted to something useful, such as:
20110729 - Chip Bank Settlement Sheet.xps
The user will accept the default filename, and files will organized automatically, rather than the user typing:
asdfadf.xps
References
eggheadcafe: XPS Default File Name
MSDN: XPS Name when Sent to Printer
Bump: 20110729 (12 months later)
Well,
here is a simple way (at least in my case):
(myPrintPage inherits from System.Drawing.Printing.PrintDocument)
With myPrintPage
With .PrinterSettings
If .PrinterName = "Microsoft XPS Document Writer" Then
.PrintToFile = True
.PrintFileName = "c:\test.pdf"
End If
End With
.Print()
End With
I haven't found a way, yet, to determine whether or not the printer I have chosen is going to print into a file, hence the test on the printer's name.
In addition to above, here is a piece of code I found useful:
Let's say that my default printer is NOT the XPS Document Writer. My code needs to archive automatically some data, print a report in XPS, then offer the user to print the report on the default printer. In the second step, I need to change the PrinterSettings of myPrintPage.
Here is how:
'save xps results
'is the XPS printer installed?
Dim myXPSfound As Boolean = False
For Each s As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
If s.Contains("XPS") Then
myXPSfound = True
Exit For
End If
Next
If myXPSfound Then
'Manual settings of the XPS printerSettings
Dim myXPSPrinterSettings As New Drawing.Printing.PrinterSettings
myXPSPrinterSettings.Collate = False
myXPSPrinterSettings.Copies = 1
myXPSPrinterSettings.Duplex = Drawing.Printing.Duplex.Simplex
myXPSPrinterSettings.FromPage = 0
myXPSPrinterSettings.MaximumPage = 9999
myXPSPrinterSettings.MinimumPage = 0
myXPSPrinterSettings.PrinterName = "Microsoft XPS Document Writer"
myXPSPrinterSettings.PrintRange = Drawing.Printing.PrintRange.AllPages
myXPSPrinterSettings.PrintToFile = True
myXPSPrinterSettings.ToPage = 1
myPrintPage.PrinterSettings = myXPSPrinterSettings
myPrintPage.PrinterSettings.PrintToFile = True
myPrintPage.PrinterSettings.PrintFileName = mytargetFileName & ".xps"
Try
myPrintPage.Print()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error Printing the XPS File")
End Try
Else
MsgBox("The Microsoft XPS Writer was no found on this computer", MsgBoxStyle.Information, "Error Printing the XPS File")
End If
It can be handy sometimes.
The Microsoft XPS Document Writer (MXDW) will generate an output file path without prompting the user if the application that prints sets lpszOutput in DOCINFO.
If you don't have access to the code of the application then another option is to build an XPS driver that generates a file path even when lpszOutput hasn't been set. The Windows Driver Kit (WDK) is the place to start.
For more details and links see this post.
Win2PDF 7 can save as XPS, and does default to the name of the print job. If you don't want to use the print job as the name displayed in the File Save dialog, you can change the default file name by setting a registry value named "PDFTitle".
You can also set the output file without prompting either using the lpszOutput field of DOCINFO, or by setting a registry setting named "PDFFileName" as described in the Win2PDF documentation. The file will be created in the XPS format if the file name contains an .xps extension.

Resources