Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Create PDF with restrictions web
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Create PDF with restrictions web
This example is the version from Sun, 23th Sep 2017.
Project "Create PDF with restrictions web.rbp"
Class App Inherits WebApplication
End Class
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
End Class
Class WebPage1 Inherits WebPage
Control Button1 Inherits WebButton
ControlInstance Button1 Inherits WebButton
EventHandler Sub Action() dim PDFData as MemoryBlock = MakePDF w = new WebFile w.Data = PDFData w.Filename = "test.pdf" w.MIMEType = "application/pdf" w.ForceDownload = true call w.Download End EventHandler
End Control
Control OpenPassword Inherits WebTextField
ControlInstance OpenPassword Inherits WebTextField
End Control
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control Label2 Inherits WebLabel
ControlInstance Label2 Inherits WebLabel
End Control
Control OwnerPassword Inherits WebTextField
ControlInstance OwnerPassword Inherits WebTextField
End Control
Control Button2 Inherits WebButton
ControlInstance Button2 Inherits WebButton
EventHandler Sub Action() dim PDFData as MemoryBlock = MakePDF w = new WebFile w.Data = PDFData w.Filename = "test.pdf" w.ForceDownload = false w.MIMEType = "application/pdf" HTMLViewer1.URL = w.URL End EventHandler
End Control
Control HTMLViewer1 Inherits WebHTMLViewer
ControlInstance HTMLViewer1 Inherits WebHTMLViewer
End Control
Function MakePDF() As MemoryBlock dim pdf as new MyDynapdfMBS dim d as new date pdf.SetLicenseKey "Lite" // For this example you can use a Lite, Pro or Enterprise License call pdf.CreateNewPDF nil call pdf.SetDocInfo pdf.kdiSubject, "My first Xojo output" call pdf.SetDocInfo pdf.kdiProducer, "Xojo test application" call pdf.SetDocInfo pdf.kdiTitle, "My first Xojo output" // We want to use top-down coordinates call pdf.SetPageCoords pdf.kpcTopDown call pdf.Append call pdf.SetFont "Times", pdf.kfsItalic, 40.0, true, pdf.kcp1252 call pdf.WriteFText pdf.ktaCenter, "My first Xojo output!" call pdf.SetFont "Times", pdf.kfsItalic, 20.0, true, pdf.kcp1252 call pdf.WriteText 50.0, 180.0, "File created: " + d.LongDate call pdf.EndPage dim flags as integer flags = BitwiseOr(flags, pdf.krsPrint) // forbit printing flags = BitwiseOr(flags, pdf.krsModify) // forbit modifying flags = BitwiseOr(flags, pdf.krsAddObj) // forbit adding annotations flags = BitwiseOr(flags, pdf.krsCopyObj) // forbit copying content call pdf.CloseFileEx(OpenPassword.text, OwnerPassword.text, pdf.kkl128bit, flags) dim PDFData as MemoryBlock = pdf.GetBufferMemory Return PDFData End Function
Property w As WebFile
End Class
Class MyDynaPDFMBS Inherits DynaPDFMBS
EventHandler Function Error(ErrorCode as integer, ErrorMessage as string, ErrorType as integer) As integer // output all messages on the console: System.DebugLog str(ErrorCode)+": "+ErrorMessage Return 0 End EventHandler
Property IgnoreWarnings As Boolean
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS DynaPDF Plugin.

MBS Xojo blog