在以正确的顺序打印PDF文档时出现问题 [英] Problem printing PDF documents in the right order

查看:259
本文介绍了在以正确的顺序打印PDF文档时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我需要一些帮助来解决我使用带有正确参数的Process.Start()打印PDF文档的问题.我将Acrobat Reader与无声打印参数一起使用.我的文档正在打印(至少在大多数情况下),但是它们没有按期望的顺序输出.
我正在使用MS Visual Studio Express 2010在VB.NET中进行此操作.
我使用9个Checkbox控件(CB2至CB10)和一系列相应的If--End If来指导打印(每个Checkbox对应于一组pdf文档).我使用Button_Click事件启动打印.

不遵守顺序,因为如果所有9个Checkbox都选中,则我从Checkbox2获得pdf,其他pdf,然后从Checkbox10、9、8 ... 4获得pdf,并带有pdf'来自Checkbox3的内容显然由于某些原因而被忽略.

我的代码示例:

If CheckBox2.Checked = True Then
   PrintFiche2(TextBox4.Text + "Comptabilite.pdf", tempprinter)  ''print header page
   ArrayFiches = pdfDir.GetFiles("Contrat\*.pdf") ''Build temp array of files names
   Print2(ArrayFiches, tempprinter) ''print the array of pdfs
   ...get more arrays and print them
End if

If CheckBox3.Checked = True Then
...
End if
...up until CheckBox10



是否存在我不知道可以用来真正控制文档顺序的属性?逻辑很简单,只是这个问题使该项目无法交付给用户...
无论使用哪种打印机,甚至使用pdf打印机,我都能得到相同的结果,因此至少这不是随机的事情.

任何指导将不胜感激!

谢谢!

解决方案

您没有显示实际开始打印的代码,因此我们只能猜测.我敢打赌,您将开始每个文档的打印作业,而不必等待上一个文档完成打印.由于打印文档需要花费不同的时间,但是要同时打印所有文档,因此您将按完成每个文档的顺序来获取它们,而不是按开始时的顺序来获取它们.

如果您的代码在开始新的打印作业之前等待上一个文档完成打印,则会按正确的顺序获取它们.


是的,这就是我的想法也是如此,但是我不知道该怎么做.

这是我用来打印作业的代码:

  Sub  Print2( ByVal  ArrayFiches, Dim  Fichier  As  IO.FileInfo
     Dim  pdfName  As   String 
     Dim  proc  As  新建过程

    proc.StartInfo.Verb = " 
    proc.StartInfo.CreateNoWindow = 
    如果 ArrayFiches.Length>  0  然后
        对于 每个 Fichier  ArrayFiches中
            pdfName = Fichier.FullName
            proc.StartInfo.FileName = pdfName
            proc.StartInfo.Arguments = " & pdf名称和罪犯
            proc.Start()
        下一步
        proc.Dispose()
    结束 如果
结束  



有9个部门需要来自18个可能目录的pdf文档.
根据哪个部门(因此我的CheckBox代表一个特定部门),我将从其中几个目录中获取pdf数组(取决于每个部门的需求),并为每个数组调用上述子例程.
每个目录可能只有几个pdf,或者根本没有.

因此,每个打印作业都可以轻松地包含发送到打印机的数十个pdf文件.

我使用最新的Acrobat Reader进行打印,并将其设置为打开pdf文件的默认程序.我还设置了Acrobat Reader以根据每一页选择纸张格式.

谢谢!


谢谢!

我添加了:

 proc.WaitForExit()

,但我得到了相同的结果.


而且我认为这是正常的,因为该过程并未结束,只是被重新用于下一个文件.实际上,最后Acrobat阅读器仍然处于打开状态,这印证了这一点.

因此,实际上,我没有从Acrobat阅读器获得任何反馈.除非AcroRd32.exe生成了秘密"生成的特定事件,否则我无法捕获以暂停对Start()的下一次调用,否则我不知道该怎么办.


Hello everyone!

I''m in need of some help to figure out a problem I have printing PDF documents using Process.Start() with the correct parameters. I use Acrobat Reader with the silent printing parameter. My documents are printing (for the most part at least), but they''re not coming out in the desired order.
I''m doing this in VB.NET using MS Visual Studio Express 2010.

I use 9 Checkbox controls (CB2 to CB10) and a series of corresponding If--End If''s to guide the printing (each Checkbox corresponds to a group of pdf documents). I use a Button_Click event to launch the printing.

The order is not respected, in that, if all 9 Checkboxes are Checked, I get pdf''s from Checkbox2, miscellaneous pdf''s, then pdf''s from Checkbox10, 9, 8...4 with the pdf''s from Checkbox3 apparently being ignored for some reason.

Example of my code:

If CheckBox2.Checked = True Then
   PrintFiche2(TextBox4.Text + "Comptabilite.pdf", tempprinter)  ''print header page
   ArrayFiches = pdfDir.GetFiles("Contrat\*.pdf") ''Build temp array of files names
   Print2(ArrayFiches, tempprinter) ''print the array of pdfs
   ...get more arrays and print them
End if

If CheckBox3.Checked = True Then
...
End if
...up until CheckBox10



Is there a property I''m not aware of that I can use to really control the order of my documents? The logic is very simple, it''s just that this problem is keeping this project from being delivered to the users...
I get the same results whichever printer I use, even a pdf printer, so at least it''s not a random kind of thing.

Any guidance would be greatly appreciated!

Thank you!

解决方案

You''re not showing the code that actually starts the printing so we can only guess. My bet would that you''re kicking off print jobs for each of these documents without waiting for the previous document to finish printing. Since the documents are taking different amounts of time to print, but printing all at the same time, you''ll get them in the order that each document takes to finish, not the order that you kicked them off in.

If your code waits for the previous document to finish printing before starting a new print job, you''ll get them in the correct order.


Yes, that''s what I was thinking too, however I don''t know how to go about doing that.

Here is the code that I use to print the jobs:

Sub Print2(ByVal ArrayFiches, ByVal Imprimante)
    Dim Fichier As IO.FileInfo
    Dim pdfName As String
    Dim proc As New Process

    proc.StartInfo.Verb = "print"
    proc.StartInfo.CreateNoWindow = True
    If ArrayFiches.Length > 0 Then
        For Each Fichier In ArrayFiches
            pdfName = Fichier.FullName
            proc.StartInfo.FileName = pdfName
            proc.StartInfo.Arguments = "/t " & pdfName & Imprimante
            proc.Start()
        Next
        proc.Dispose()
    End If
End Sub



There are 9 departments which need pdf documents from 18 possible directories.
Depending on which department (hence my CheckBoxes representing a particular department), I will fetch arrays of pdfs from several of those directories (depending on the needs of each department) and call the above Subroutine for each of these arrays.
Each directory can possibly have several pdfs or none at all.

And so each print job can easily consist of several dozen pdf files being sent to the printer.

I use the latest Acrobat Reader to do the printing and have set it as the default program to open pdf files. I have also set Acrobat Reader to select the paper format according to each page.

Thank you!


Thanks!

I added:

proc.WaitForExit()

but I get the same results.


And I think it''s normal since the process doesn''t end, it just gets reused for the next file. In fact, the Acrobat reader remains open in the end which confirms this.

So, in effect, I''m not getting any feedback from Acrobat reader. Unless there are specific events "secretly" generated by AcroRd32.exe I can trap to pause the next call to Start(), I don''t know how else I can go about this.


这篇关于在以正确的顺序打印PDF文档时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆