using a second input folder

as mentioned in watermarking, I’ve an input pdf watermarked with several other pdf files.

I’ve one pdf SourcePDF from an input task. Now I want to iterate through another folders pdf contents, the WatermarkPDFs.

For each Watermark PDF found in the WatermarkPDFs folder I want to output one new merged PDF, named SourcePDF_WatermarkPDF.pdf. How can this be done in workflow? I struggled using the loop task.

Basic idea:

’ Outer Loop, open every watermark PDF
’ For every file in watermark folder apply the watermark to the input pdf
’ attach the original filename and watermark-filename to an output variable
’ use the output variable for the final pdf.
For every file forund in WatermarkPDFs

'inner loop stamp the watermarks

    For pageindexin = 0 to SourcePDFin.Pages.Count-1
            SourcePDFin.Pages.Item(pageindexin).Merge2 WatermarkPDF.Pages.Item(0), 0.0, 0.0, 0.0, 1.0


    Next

'Set a new PDF name

myPDF.Save False

Next

If I understand correctly, you have a Watermark.PDF file that contains a single page, which is just a watermark you want to apply to every page of every pdf found in the WatermarkPDFs folder.

The simplest way to achieve this is to create a process that starts with a Folder Capture input task, pointing to the WatermarkPDFs folder. This will automatically loop through all files in that folder.

Then, use a Run Script task that stamps the Watermark.PDF page onto each page of the captured PDF (just like you managed to do in that other post you referenced).

Finally, use a Send To Folder output task to save the modified PDF to a specific folder.

Phil, thx, but it’s the other way round:

I’ve just one folder containing a bunch of files, the watermarking pdfs, static, not incoming, to be applied to the incoming Pdf, e.g. the incoming PDF should be stamped (each page) with every watermarking PDF, then saved, then stamped with the next watermarking PDF.

So the question is about how to clone the incoming PDF then saving it to a different file name and all that in a loop.

OK try the following process:

Folder Capture ==> Run Script ==> Delete

Add the %{workingDir} local variable to your process and give it a path (Ex: C:\Forum\160398)

Inside the %{workingDir} folder create the following sub-folder:WatermarkPDFs; this is where your watermarks will reside. (Ex: C:\Forum\16039\WatermarkPDFs)

In the Run Script, use the following script. The Output folder will automatically be created inside the %{workingDir} folder if it doesn’t exist:

Dim watermarkID, WatermarkPDF
Dim workingDir, objFSO, objFolder, outputFolder
Dim myPDF, myPDFName, myPDFPageIndex, myPDFPageCount
Dim myFinalPDF, myFinalPDFPage

workingDir = Watch.GetVariable(“workingDir”)

Set myPDF = Watch.GetPDFEditObject
Set WatermarkPDF = Watch.GetPDFEditObject
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFolder = objFSO.GetFolder(workingDir & "\WatermarkPDFs")

outputFolder = workingDir & "\FinalOutput"
If NOT objFSO.FolderExists(outputFolder) Then objFSO.CreateFolder(outputFolder)

For Each watermarkID In objFolder.Files
myPDF.Open Watch.GetJobFileName, false
myPDFName = Watch.ExpandString(“%O”)
myPDFPageCount = myPDF.Pages.Count

  Set myFinalPDF = Watch.GetPDFEditObject
  myFinalPDF.Create outputFolder & myPDFName & "_" & watermarkID.name

If LCase((objFSO.GetExtensionName(watermarkID))) = LCase("pdf") then
       WatermarkPDF.Open watermarkID, false

        For myPDFPageIndex = 0 to  myPDFPageCount-1
             Set myPDFPage = myPDF.Pages.Item(myPDFPageIndex)
             myFinalPDF.Pages.InsertFrom2 WatermarkPDF, 0, 1, myFinalPDF.Pages.Count()

             Set myFinalPDFPage = myFinalPDF.Pages.Item(myPDFPageIndex)
             myFinalPDFPage.Merge2 myPDFPage, 0.0, 0.0, 0.0, 1.0

             Set myFinalPDFPage = nothing
             Set myPDFPage = nothing
        Next
  End If

  myFinalPDF.Save true
  myFinalPDF.Close

  myPDF.Save False
  myPDF.close

  WatermarkPDF.Save False
  WatermarkPDF.Close

Next

Rod!

Great, thx, works!
Even with transparent watermarks (changed the sequence so watermarks will merge onto the original pdfs) and added little code to deal with page offsets.