In order for every page in an edition to be archived, an “archive variant” must be created so that a PDF copy is stored along with the document in the archive.
These are the steps to carry out:
1.Create the Archive printer.
To do this, make a copy of the printer that is used to output the final PDF of the page when it goes to press. In Fred4, select File > Print, check-out the printer, then change the name and add it as the new configuration.
Make sure that the permissions are set right.
2.Ensure that the Print Queue is set to PDF Variant and that the Output file name is PDF_[High quality print].
3.Open the Administrative Browser and select the Print queues tab.
4.Configure the PDF variant to use the xmlQueue (The input queue of the Generate PDF file data source) so that Back4 will handle the printing of the variant.
5.To test, open a page and print to the Archive printer. If configured properly, an entry in the Back4 task log in the Administrative Browser will show you that the variant was created successfully.
6.You now need to automate the creation of the variant. Take the standard print script and hard code two printers: the "PDF (final print)" printer and the Archive printer. Below is the full script that you can place in the CustomPage.vb file in the addins. The pieces in bold refer to changed names:
<ShellCommand(CanExecute:="Ena_IsWindowActive")> _
Public Sub MDPFinalPrint()
Dim iPrompt As Short = Fred.GetQualifier
Dim asktodo As Boolean = iPrompt And 2 ' Hold CTRL to ask operation (print/open)
Dim showdlg As Boolean = iPrompt And 4 ' Hold ALT (or menu mode) for dialog mode
Dim page As IPageDisp = FredApp.ActivePageDispatcher
Dim optPrint As TeraDP.GN4.Editorial.PrintOptions = Nothing
Dim resPrint As Short = 0
Dim login As TeraDP.GN4.Common.ILogin = TeraDP.GN4.Editorial.EditorialLogin.GetLogin()
Dim obj As Schema.Class.pageObj = New GN4.Schema.Class.pageObj(login.Schema)
optPrint = Fred.GetPDFOptions("Archive") ' No "Default"? opt is nothing and the dialog will open on next step...
' Always save xml for debug into %temp%
optPrint.Dict(Editorial.TPrintOpt.XMLFile) = System.IO.Path.GetTempPath() + "FredPDF.xml"
Dim lay As Short = PrintContent.coLayout
' Ask to print in layout mode when pages drawn in text information mode
If ((page.GetViewShow() And 16) <> 0) And (String.Compare(optPrint.Dict(Editorial.TPrintOpt.Content), lay.ToString()) <> 0) Then
If MsgBox("Do you want to print in 'Layout' mode?", vbYesNo, My.Resources.ids_PrintToPdf) = MsgBoxResult.Yes Then
optPrint.Dict(Editorial.TPrintOpt.Content) = lay.ToString()
End If
End If
' check paper size & marks
Dim fit = optPrint.FitToPage
Dim pagewidth = Page.GetPageWidth
Dim pageheight = Page.GetPageHeight
Dim paperwidth = optPrint.MediaBoxW
Dim paperheight = optPrint.MediaBoxH
Dim markweight = optPrint.MarkWeight
Dim markmargin = optPrint.MarkMargin
Dim pagewidthmarks = pagewidth + markweight + markmargin
Dim pageheightmarks = pageheight + markweight + markmargin
' end check paper size & marks
Dim pagew As Integer = pagewidthmarks
Dim pageh As Integer = pageheightmarks
If optPrint.Marks = 0 Then
pagew = pagewidth
pageh = pageheight
End If
If fit Then
resPrint = Fred.PDFGenerate(optPrint)
Else
If paperheight < pageh Or paperwidth < pagew Then
If MsgBox("The paper size is smaller than the page, proceed anyway?", vbYesNo, My.Resources.ids_PrintToPdf) = vbNo Then
Exit Sub
Else
resPrint = Fred.PDFGenerate(optPrint)
End If
Else ' Paper size larger than page size, no problems for printing
resPrint = Fred.PDFGenerate(optPrint)
End If
End If
If resPrint > 0 Then
MsgBox(My.Resources.IDS_PDFERROR & resPrint)
Exit Sub
End If
Dim file = Fred.PDFGetFile()
Dim data = Fred.PDFGetCustomData() ' The script support "ask","print","printdlg","open" as custom data from WF
If asktodo Or data = "ask" Then
' This is a demo script when acrobat reader is the registered PDF application on client
Dim ask = MsgBox(My.Resources.IDS_PrintPrompt, MsgBoxStyle.YesNoCancel)
If ask = MsgBoxResult.Cancel Then
Exit Sub
ElseIf ask = MsgBoxResult.Yes Then
data = "printdlg"
ElseIf ask = MsgBoxResult.No Then
data = "open"
End If
End If
optPrint = Fred.GetPDFOptions("PDF (final print)") ' No "Default"? opt is nothing and the dialog will open on next step...
' Always save xml for debug into %temp%
optPrint.Dict(Editorial.TPrintOpt.XMLFile) = System.IO.Path.GetTempPath() + "FredPDF.xml"
' Ask to print in layout mode when pages drawn in text information mode
If ((page.GetViewShow() And 16) <> 0) And (String.Compare(optPrint.Dict(Editorial.TPrintOpt.Content), lay.ToString()) <> 0) Then
If MsgBox("Do you want to print in 'Layout' mode?", vbYesNo, My.Resources.ids_PrintToPdf) = MsgBoxResult.Yes Then
optPrint.Dict(Editorial.TPrintOpt.Content) = lay.ToString()
End If
End If
' end check paper size & marks
If optPrint.Marks = 0 Then
pagew = pagewidth
pageh = pageheight
End If
If fit Then
resPrint = Fred.PDFGenerate(optPrint)
Else
If paperheight < pageh Or paperwidth < pagew Then
If MsgBox("The paper size is smaller than the page, proceed anyway?", vbYesNo, My.Resources.ids_PrintToPdf) = vbNo Then
Exit Sub
Else
resPrint = Fred.PDFGenerate(optPrint)
End If
Else ' Paper size larger than page size, no problems for printing
resPrint = Fred.PDFGenerate(optPrint)
End If
End If
If resPrint > 0 Then
MsgBox(My.Resources.IDS_PDFERROR & resPrint)
Exit Sub
End If
If asktodo Or data = "ask" Then
' This is a demo script when acrobat reader is the registered PDF application on client
Dim ask = MsgBox(My.Resources.IDS_PrintPrompt, MsgBoxStyle.YesNoCancel)
If ask = MsgBoxResult.Cancel Then
Exit Sub
ElseIf ask = MsgBoxResult.Yes Then
data = "printdlg"
ElseIf ask = MsgBoxResult.No Then
data = "open"
End If
End If
' Insert here the workstate change
Main.Refresh()
MsgBox("Page sent successfully!")
End Sub
Note
If you wish to also have the print script automatically change the page workstate then add this piece to the bottom of the script above replacing the obj.workstateRefAttr= 308 with the 308 being the ID of the workstate you wish to set the page to:
Dim ids(0) As Integer
ids(0) = page.GetPageId
obj.workstateRefAttr = 308
login.UpdateObjs(ids, New GenericObj() {obj.ToGenericObj(login.Schema, Schema.Class.pageObj.Attr.workstateRefAttr)}, Nothing, False, False, True, False, Nothing)
Main.Refresh()
MsgBox("Page sent successfully!")
End Sub
Now, you must tie this complete print script to the Fred menus. The name of this example script is MDPFinalPrint. We must create a toolbar icon in the main toolbar of Fred that will call this script and therefore print and archive the page at the same time. You can place this icon directly next to the default print icon in Fred:
To add this, you must open the Fred4_Tabitems.xml file and update the Main Toolbar area with this line calling the MDPFinalPrint script:
<l:TBBtn CommandParameter="LayoutClosePage" ToolTip="Close Page" Icon="%33_close page_16.png" />
<Separator />
<l:TBBtn CommandParameter="MDPFinalPrint" ToolTip="Final Print" Icon="%8_grid_16.png" />
<l:TBBtn CommandParameter="PDFGenerate" Param="T" ToolTip="Print as PDF: Hold ALT to show dialog box or Right click to show list of printers" Icon="%187_Print_16.png" />
<l:TBBtn CommandParameter="PageTest" ToolTip="Test page" Icon="%1_test page_16.png" />
You can see that the code was inserted between the default print button and the separator, making it the first icon after the separator in the main toolbar.
The users will now use this button to release a page, sending to both the press and creating a variant of the page for archiving purposes.