Skip to content

Commit

Permalink
New VBS Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
btompkinson committed Jul 18, 2019
1 parent b08725e commit 51f5fd1
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 3 deletions.
6 changes: 3 additions & 3 deletions C#/Server.UploadFTP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ static void Main(string[] args)
APServer.Server server = new APServer.Server();

// Setup the FTP request supplying credentials if needed
server.AddFTPRequest("#.#.#.#", "/folder");
server.SetFTPCredentials("john.doe", "asdfasdf");
server.AddFTPRequest(hostAddress: "#.#.#.#", targetDirectory: "/folder");
server.SetFTPCredentials(user: "john.doe", password: "asdfasdf");

// Set which files will upload with the FTP request
// To attach a binary file use AddFTPBinaryAttachment
server.FTPAttachOutput = true;
server.AddFTPAttachment($"{strPath}Server.Input.ps");
server.AddFTPAttachment(Filename: $"{strPath}Server.Input.ps");

// Convert the PostScript file into PDF
ServerDK.Results.ServerResult result =
Expand Down
53 changes: 53 additions & 0 deletions VBS/Server.AddBookmarks.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Add bookmarks to pages in the PDF
oSVR.AddPageBookmark "Parent", 1, 1, "Fit"
oSVR.AddPageBookmark "Child 1", 0, 2, "Fit"

' Add bookmarks to URLs
oSVR.AddURLBookmark "Parent URL Bookmark", 1, "http:'www.activepdf.com"
oSVR.AddURLBookmark "Child URL Bookmark", 0, _
"https:'www.activepdf.com/products/server"

' Add bookmarks pointing to pages in external PDF
' Both Local and UNC file paths are accepted
oSVR.AddLinkedPDFBookmark "Parent PDF Bookmark", 1, _
strPath & "Server.Sample.pdf", 1, "Fit"
oSVR.AddLinkedPDFBookmark "Child PDF Bookmark", 0, _
strPath & "Server.Sample.pdf", 2, "Fit"

' Add bookmarks pointing to any external file
' Both Local and UNC file paths are accepted
oSVR.AddFileBookmark "Parent File Bookmark", 1, _
strPath & "Server.PowerPoint.Input.pptx"
oSVR.AddFileBookmark "Child File Bookmark", 0, _
strPath & "Server.Word.Input.doc"

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.AddBookmarks.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
59 changes: 59 additions & 0 deletions VBS/Server.AddPDFMark.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Add PDF marks to be used in the converted PDF
' PDF Mark Reference:
' http:'www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdfmark_reference.pdf

' Notes (Page 20 - PDF Marks Reference)
oSVR.AddPDFMark "[ /SrcPg 1 /Rect [32 32 216 144] /Open false /Title (ActivePDF Comment) /Contents (Note Type Comment Example.) /Color [1 0 0] /Subtype /Text /ANN pdfmark"

' Free Text (Page 17 - PDF Marks Reference)
' Used for the text in the link created below
oSVR.AddPDFMark "[ /SrcPg 1 /Rect [262 26 350 46] /Contents (ActivePDF.com) /DA ([0 0 1] rg /Helv 12 Tf) /BS << /W 0 >> /Q 1 /Subtype /FreeText /ANN pdfmark"

' Links (Page - PDF Marks Reference)
' Add a link around the activePDF.com text created above
oSVR.AddPDFMark "[ /SrcPg 1 /Rect [262 26 350 46] /Contents (ActivePDF.com) /BS << /W 0 >> /Action << /Subtype /URI /URI (http:'ActivePDF.com) >> /Subtype /Link /ANN pdfmark"

' Bookmarks (Page 26 - PDF Marks Reference)
oSVR.AddPDFMark "[ /Count -5 /Title (ActivePDF Server - AddPDFMark) /Page 1 /F 2 /OUT pdfmark"
oSVR.AddPDFMark "[ /Page 1 /View [/Fit] /Title (AddPDFMark - Page 1) /C [0 0 0] /F 2 /OUT pdfmark"
oSVR.AddPDFMark "[ /Page 2 /View [/Fit] /Title (AddPDFMark - Page 2) /C [0 0 0] /F 2 /OUT pdfmark"

' Document Information (Page 28 - PDF Marks Reference)
oSVR.AddPDFMark "[ /Title (PDF Marks) /Author (ActivePDF Server) /Subject (PDF Marks) /Keywords (pdfmark, server, example) /DOCINFO pdfmark"

' Document View Options (Page 29 - PDF Marks Reference)
oSVR.AddPDFMark "[ /PageMode /UseOutlines /Page 1 /View [/Fit] /DOCVIEW pdfmark"

' Document Open Options
oSVR.AddPDFMark "[ {Catalog} << /ViewerPreferences << /HideToolbar true /HideMenubar true >> >> /PUT pdfmark"

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.AddPDFMark.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
40 changes: 40 additions & 0 deletions VBS/Server.AddStampImage.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Create a stamp collection for the image stamp
oSVR.AddStampCollection "IMGimage"

' Add an image stamp to the lower right corner of each page.
oSVR.AddStampImage strPath & "Server.ImageInput.jpg", 508.0, 50.0, 64.0, 64.0, True

' Set whether the stamp collection(s) appears in the background or
' foreground
oSVR.StampBackground = 0

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.AddStampImage.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
47 changes: 47 additions & 0 deletions VBS/Server.AddStampText.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Stamp Images and Text onto the output PDF
oSVR.AddStampCollection "TXTinternal"
oSVR.StampFont = "Helvetica"
oSVR.StampFontSize = 108
oSVR.StampFontTransparency = 0.3
oSVR.StampRotation = 45.0

oSVR.StampFillMode = 2
oSVR.SetStampColor 255, 0, 0, 0
oSVR.SetStampStrokeColor 100, 0, 0, 0

oSVR.AddStampText 116.0, 156.0, "Internal Only"

' Set whether the stamp collection(s) appears in the background or
' foreground
oSVR.StampBackground = 0

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.AddStampText.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
33 changes: 33 additions & 0 deletions VBS/Server.CompatibilityLevel.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Specify the PDF version for the created PDF
oSVR.CompatibilityLevel = 0

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.CompatibilityLevel.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
33 changes: 33 additions & 0 deletions VBS/Server.LinearizePDF.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Specify the PDF version for the created PDF
oSVR.LinearizePDF = True

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.LinearizePDF.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
Binary file added VBS/Server.Sample.pdf
Binary file not shown.
57 changes: 57 additions & 0 deletions VBS/Server.SendEmail.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' Add an email
oSVR.AddEMail

' Set server information
' UPDATE THIS LINE WITH YOUR SERRVER INFORMATION
oSVR.SetSMTPInfo "#.#.#.#", 0
oSVR.SetSMTPCredentials "john.doe", "activePDF", "asdfasdf"

' Set email addresses
oSVR.SetSenderInfo "John Doe", "john.doe@asdidlwenra.com"
oSVR.SetReplyToInfo "John Doe", "john.doe@asdidlwenra.com"
oSVR.SetRecipientInfo "Jane Doe", "jane.doe@asdidlwenra.com"
oSVR.AddToCC "Jim Doe", "jim.doe@asdidlwenra.com"
oSVR.AddToBcc "Janice Doe", "janice.doe@asdidlwenra.com"

' Subject and Body
oSVR.EMailSubject = "PDF Delivery from activePDF"
oSVR.SetEMailBody "<html><body style='background-color: #EEE; padding: 4px;'>Here is your PDF!</body></html>", True

' Attachments - Binary attachments can be added with
' AddEMailBinaryAttachment
oSVR.AddEMailAttachment strPath & "Server.Input.ps"

' Other email options
oSVR.EMailReadReceipt = False
oSVR.EMailAttachOutput = True

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.SendEmail.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
33 changes: 33 additions & 0 deletions VBS/Server.SetViewMode.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Dim FSO, strPath, results

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Instantiate Object
Set oSVR = CreateObject("APServer.Object")

' View settings for how the PDF shows in a PDF reader
oSVR.SetViewMode 3, 1, "Fit"

' Convert the PostScript file into PDF
Set result = oSVR.ConvertPSToPDF( _
strPath & "Server.Input.ps", _
strPath & "Server.SetViewMode.pdf")

' Output conversion result
WriteResult result

' Process Complete
Wscript.Quit

Sub WriteResult(oResult)
message = "Result Status: " & result.ServerStatus
If result.ServerStatus = 0 Then
message = message & ", Success!"
Else
message = message &", " & result.Details
End If
Wscript.Echo message
End Sub
Loading

0 comments on commit 51f5fd1

Please sign in to comment.