我想从Excel打印到Postscript然后打印到打印机。如何在将打印作业发送到打印机之前指定双面打印和装订。
我一直在关注PrintTicket class。看起来很有希望。但我正在使用.net 3.5的WinForms项目。
如果我不需要,我真的不想设置多个打印队列。那么如何控制双面和装订选项?
private boolean prepareVideoRecorder() {
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mVideoFile = new File(getOutputMediaFile().toString());
mMediaRecorder.setOutputFile(mVideoFile.getAbsolutePath());
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
mMediaRecorder.setOrientationHint(270);
mMediaRecorder.setMaxDuration(10000);
mMediaRecorder.setOnInfoListener(this);
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d("CAMERA", "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d("CAMERA", "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
if (prepareVideoRecorder()) {
// Camera is available and unlocked, MediaRecorder is prepared,
// now you can start recording
mMediaRecorder.start();
}
答案 0 :(得分:2)
您可以使用PrintQueue.AddJob方法将文件添加到打印队列。但它只接受XPS文件。然后,您可以使用PrintTicket类来指定双面打印和/或装订。而不是使用Postscript,打印到XPS并添加一个作业。
Public Shared Function PrintSheetsToXPS(ByVal wb As Excel.Workbook, _
ByVal arr As Array, _
ByVal XPSFileName As String) As String
Dim svInputPS As String = TempPath & XPSFileName
IO.File.Delete (svInputPS)
wb.Worksheets(arr).PrintOut(PrintToFile:=True, _
PrToFileName:=svInputPS, _
ActivePrinter:="Microsoft XPS Document Writer")
Return svInputPS
End Function
Sub demoDuplexStaple(ByVal XPSFileName As String)
'Imports SysPrint = System.Printing
'need to reference ReachFramework
Dim PrintServer As New SysPrint.PrintServer("\\" & My.Computer.Name)
Dim PrintQ As New SysPrint.PrintQueue(PrintServer, "Ricoh Main")
Dim Jobs As SysPrint.PrintJobInfoCollection = PrintQ.GetPrintJobInfoCollection
Dim able As SysPrint.PrintCapabilities = PrintQ.GetPrintCapabilities()
'get the current PrintTicket
Dim CurrentTicket As SysPrint.PrintTicket _
= PrintQ.CurrentJobSettings.CurrentPrintTicket
'modify to staple and duplex
CurrentTicket.Stapling = Printing.Stapling.StapleTopLeft
CurrentTicket.Duplexing = Printing.Duplexing.TwoSidedLongEdge
'add the XPS file to the print queue to print
Dim TestJob As SysPrint.PrintSystemJobInfo _
= PrintQ.AddJob("Test job", XPSFileName, False)
End Sub
然后,如果您需要PDF,可以使用GhostXPS将XPS转换为PDF。不幸的是,目前同时有no way to add bookmarks。但未来可能会addressed。