Reputation: 4412
I've got an application that generates PDF files. I want to achieve this: some pages are to be printed in regular paper (present in a specific printer tray) and others in a special sticker paper (from another printer tray)
If the PDF file itself could contain this information, which would be read at printing time, it would solve the problem, but I don't think that's possible.
I managed to inspect the PDF and generate a file with its specifications. Here's some code:
sw = New StreamWriter(File.Open(DATOutputFile, FileMode.Create))
sw.WriteLine("Zustell".PadRight(20, " ") & ZustellPages(0))
Dim i As Integer
Dim aux = ""
For i = 0 To AddressPages.Count - 2
aux = aux & AddressPages(i) & ","
Next
aux = aux & AddressPages(i)
sw.WriteLine("Adressen".PadRight(20, " ") & aux)
aux = ""
For i = 0 To BotenPages.Count - 2
aux = aux & BotenPages(i) & ","
Next
aux = aux & BotenPages(i)
sw.WriteLine("Botenbezirk".PadRight(20, " ") & aux)
aux = ""
For i = 0 To Etiquetas.Count - 2
aux = aux & Etiquetas(i)(0) & "-" & Etiquetas(i)(1) & ","
Next
aux = aux & Etiquetas(i)(0) & "-" & Etiquetas(i)(1)
sw.WriteLine("Label".PadRight(20, " ") & aux)
sw.Close()
This bit creates a file that looks like this:
That said, I know which pages contain labels, addresses, etc. Each destined to different printer trays when printing is ordered.
How can this be achieved?
Can I create a post script file with tray specifications from the PDF or as I create the Crystal report?
EDIT:
I have created a PS file from the PDF and at the beginning of the specifications for each page, there is something like this:
%%Page: 11 72
%%BeginPageSetup
%%PageBoundingBox: 0 0 596 842
%%PageOrientation: Portrait
%%EndPageSetup
%%<!--LARADOCID--xx/10000000/E/0000011-->
<< /MediaPosition 3 /TraySwitch false >> setpagedevice
<< /PageSize [595 842] /ImagingBBox null >> setpagedevice
STARTP
I was thinking that here is the place to insert some code that specifies the tray to be used for that page, however, I don't know how to.
Upvotes: 1
Views: 2993
Reputation: 11
i'm trying to solve a similar problem i need to print each page on different tray. the postscript file creation is composed of two part one that is made by the program that want to print creating a ps without any printer specific command and another part where the postscript driver add all the information about tray selection , page size , ... i was able to print on different tray specifying the right command on each printer on HP
%%PageTrailer
%%Page: 2 2
%%PageBoundingBox: 0 0 595 842
%%BeginPageSetup
/pagesave save def
21 0 obj
<</Type/Page/MediaBox [0 0 595 842]
/Parent 3 0 R
/Resources<</ProcSet[/PDF]
/Font 23 0 R
>>
/Contents 22 0 R
/CropBox
[0 0 594.0 842.0]
>>
<</ManualFeed false /MediaPosition 0>> setpagedevice <-- just add this
endobj
%%EndPageSetup
22 0 obj
<</Length 922>>stream
on Lexmark i added something like that currentpagedevice /InputAttributes get 0 get setpagedevice i've just made some reverse eng. with the printer stopped and i did some diff between the version of ps produced by the printer C:\Windows\System32\spool\PRINTERS changing the tray output
Upvotes: 1
Reputation: 31159
You could try creating a job ticket for your PDF file but it would depend on your printer being able to read and take action on a PJTF (which can be embedded in the PDF file).
Whether you can do this on conversion to PostScript rather depends on the software you use to convert the PDF to PostScript, the answer is 'probably not'.
Your best bet is probably to convert to a DSC-compliant PostScript file, and then post-process the PostScript and inject the tray selection in the page setup for each page. DSC compliant files are structured so that it is possible to find these sections relatively easily.
Of course, you will need to know the tray selection PostScript sequence required for your printer.
Upvotes: 2