Create a PDF file from IBM Notes Document lotusscript

Hello,

Now i have the last version of PDF Creator and my Lotusscript agent doesn’t working.
It was working fine with the version 1.7 of PDF Creator.

here the code :

Set PDFCreator = CreateObject(“PDFCreator.clsPDFCreator”)

If PDFCreator Is Nothing Then
MsgBox “Vérifier que PDFCreator est bien installé sur votre pc”,“PDFCreator n’est pas détecté”
End If

If Not PDFCreator.cStart("",True) GoTo processError

PDFCreator.cPrinterStop = True
PDFCreator.cClearCache
If mode = “liste_select” Then 'on a plusieurs docs sélectionnés
Set doc = collection.GetFirstDocument
Set uidoc = workspace.EditDocument(True, doc) 'on ouvre le premier en mode Edition
ElseIf mode = “liste” Then 'le mail n’est pas ouvert
Set uidoc = workspace.EditDocument(True) 'on l’ouvre en mode Edition
Else 'le mail est ouvert
Set doc = workspace.CurrentDocument.Document
Set uidoc = workspace.EditDocument(True, doc) 'on le ré-ouvre en mode Edition
End If
debut:
emetteur = uidoc.FieldGetText(“From”)
intitule = uidoc.FieldGetText(“Subject”)
'20 premiers caractères de l’émetteur - + les premiers caractères de l’intitulé pour faire max 100

'impression PDF
Dim PrinterPath As String
PrinterPath = “PDFCreator”
On Error GoTo impressionImpossible
Call uidoc.Print(1, 0, 0, False, PrinterPath)
On Error Resume Next
suite:
'fermeture du mail en mode Edition
Call uidoc.Close
If mode = “liste_select” Then 'si on a plusieurs docs
Set doc = collection.GetNextDocument (doc)
If Not doc Is Nothing Then 's’il en reste
Set uidoc = workspace.EditDocument(True, doc) 'on ouvre le suivant en mode Edition
GoTo debut
End If
End If
If nbdoc >0 Then
Do Until PDFCreator.cCountOfPrintjobs = nbdoc
Loop
With PDFCreator
.Ccombineall
.cOption(“UseAutosave”) = 1
.cOption(“UseAutosaveDirectory”) = 1
.coption(“AutosaveDirectory”)=spdfpath
.cOption(“AutosaveFilename”) = nomfichier & “.pdf”
.cOption(“AutosaveFormat”) = 0
End With
PDFCreator.cPrinterStop = False
While PDFCreator.cCountOfPrintjobs > 0
Sleep 1
Wend
End If
PDFCreator.cClose
testVide = False
Do Until testVide = True
Call deplace(testVide,spdfpath)
Loop
objFSO.DeleteFolder(spdfpath & temppath)
Exit Sub
impressionImpossible:
nbdoc = nbdoc-1
GoTo suite
fin:
Exit Sub
processError:
MsgBox “Vérifier que PDFCreator est bien installé sur votre pc”,“Fonctionnalité PDF n’est pas opérationnelle”
Print "Error: “+Error()+” Line: "+Cstr(Erl)
Resume fin

End Sub

Sub doublon(objFSO, debutNom, extension)
If Right(debutNom, 1) <> “.” Then
Call doublon(objFSO, Left(debutNom, Len(debutNom)-1), Right(debutNom, 1) & extension)
ElseIf Left(Right(debutNom, 4),1) = “(” And IsNumeric(Left(Right(debutNom, 3),1)) And _
Left(Right(debutNom, 2),1) = “)” Then
objFSO.MoveFile debutNom & extension, Left(debutNom, Len(debutNom) - 4) & “(” & _
Left(Right(debutNom, 3),1) +1 & “).” & extension
ElseIf Left(Right(debutNom, 5),1) = “(” And IsNumeric(Left(Right(debutNom, 4),2)) And _
Left(Right(debutNom, 2),1) = “)” Then
objFSO.MoveFile debutNom & extension, Left(debutNom, Len(debutNom) - 5) & “(” & _
Left(Right(debutNom, 4),2) +1 & “).” & extension
Else
objFSO.MoveFile debutNom & extension, Left(debutNom, Len(debutNom)-1) & " (1)." & extension
End If
End Sub

What is the difference for it’s working with the new version ?

Hi,

since PDFCreator itself was completely rewritten after version 1.7.3, the COM interface has also changed. Please have a look at http://docs.pdfforge.org/pdfcreator/latest/en/pdfcreator/com-interface/ for all information on the new COM interface and the main differences towards the version you have been using previously. You will probably need to rewrite most of the code, if not all. The COM interface is now built in such a way that future updates shouldn’t cause any problems.

Best regards,

Robin

Could you help to translate this code that is working with PDFCreator vertion1.7 to the new version 2…

Hi,

we can help if you have any specific questions, there are also some examples for the new COM interface in your PDFCreator path which might help. Here is some general information to keep in mind when migrating from 1.7. to 2.x : http://docs.pdfforge.org/pdfcreator/latest/en/pdfcreator/com-interface/user-manual/basics/workflow-comparsion-v1-7-v2/

Best regards,

Robin

Are you any more examples of script for Merge document to 1 pdf ?

We have some examples in our documentation.
Here is one for merging all print jobs: http://docs.pdfforge.org/pdfcreator/latest/en/pdfcreator/com-interface/user-manual/how-to/merge-all-jobs/