Hi
I'm writing an application (in VB.Net) that prints off batches of documents that are posted out to clients.
I have to include OMR marks in the documents so that they can be automatically grouped into batches and folded into envelopes by our OMR printer.
I've wrote a routine that opens pdf documents in Acrobat and adds the OMR marks as Annotations.
I know it is working properly as I can see the markings if I save the document and open in Acrobat /reader later.
The issue I have is I need to automatically print off the documents with the Markup displayed and of course it is not doing this. I was using the .PrintPagesSilent method of AVDoc to print the pages off
I'm not sure if the .PrintPagesSilentEX gives me the option to print the markups, I noticed an iPageOption in PrintPagesSilentEx but can not find in the SDK if this is what I need (or what value should go in other than an integer)
I also wandered if I need to use the .SetOpen method of the Annot to get it to print.
Here is my code:
Sub RenderPDF( byRef sFile as String) Dim AcroAVDoc, AcroAVDoc1 As Object Dim AcroPDDoc, AcroPDDoc1 As Object Dim intPages As Integer Dim srcAnnot, destAnnot, srcPage, destPage, AcroRect As Object 'Acrobat Page Objects Dim PageSize As Object 'Acrobat PageSize H*W Dim PageHeight As Integer Dim destFile As String Dim destPageNum, intPage As Integer Dim strOMR As String If File.Exists(sFile) Then AcroAVDoc = CreateObject("AcroExch.AVDoc") AcroPDDoc = CreateObject("AcroExch.PDDoc") If gOMR Then destFile = Replace(sFile, ".pdf", "_OMR.pdf") If File.Exists(destFile) Then File.Delete(destFile) File.Copy(sFile, destFile) 'creating temporary OMR file AcroAVDoc.open(destFile, Dir(destFile)) AcroPDDoc = AcroAVDoc.GetPDDoc AcroAVDoc1 = CreateObject("AcroExch.AVDoc") AcroAVDoc1.open(gOMRTemplate, "OMR Template.pdf") ' a template containing OMR annots AcroPDDoc1 = AcroAVDoc1.GetPDDoc AcroPDDoc.InsertPages(-2, AcroPDDoc1, 0, 1, False) 'add our template to the doc to use as a source. destPageNum = AcroPDDoc.GetNumPages - 1 srcPage = AcroPDDoc.AcquirePage(destPageNum) For intPage = 0 To destPageNum - 1 gPageCount = gPageCount + 1 strOMR = "OMR_" 'the last page do insert... If gPageCount = gLastPage Then 'insert strOMR = strOMR & "I_" Else 'store strOMR = strOMR & "S_" End If strOMR = strOMR & gintSequence destPage = AcroPDDoc.AcquirePage(intPage) 'get size of page, N.B. adobe grid starts in bottom left corner PageSize = destPage.GetSize() PageHeight = PageSize.y 'get height of page 'Loop through the template annotations and compare to the one we wish to have For intAnnot = 0 To srcPage.GetNumAnnots - 1 srcAnnot = srcPage.GetAnnot(intAnnot) If srcAnnot.GetTitle = strOMR Then destPage.AddAnnot(-2, srcAnnot) destAnnot = destPage.GetAnnot(0) AcroRect = destAnnot.GetRect With AcroRect .Left = 3.3 .right = 54 If PageHeight > 253.85 Then .bottom = PageHeight - 253.85 .Top = PageHeight - 163.75 End If End With destAnnot.SetRect(AcroRect) AcroRect = Nothing destAnnot = Nothing srcAnnot = Nothing gintSequence = gintSequence + 1 If gintSequence > 7 Then gintSequence = 0 System.Threading.Thread.Sleep(1000) 'give it a second... Exit For End If Next Next AcroPDDoc.Save(PDSaveFlags.PDSaveFull, destFile) 'save our marked up file ' Print the Adobe file AcroAVDoc.PrintPagesSilent(0, AcroPDDoc.GetNumPages - 1, 2, False, False) System.Threading.Thread.Sleep(1000) end if end if
Anyone any ideas?
Thanks
Solved it!
I had to use the SetOpen method of the Annotation.