Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Create PDF with restrictions web


Required plugins for this example: MBS DynaPDF Plugin

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, 5th Nov 2022.

Project "Create PDF with restrictions web.xojo_binary_project"
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 Pressed() 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 Pressed() dim PDFData as MemoryBlock = MakePDF w = new WebFile w.Data = PDFData w.Filename = "test.pdf" w.ForceDownload = false w.MIMEType = "application/pdf" HTMLViewer1.LoadURL 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.kcpUnicode call pdf.WriteFText pdf.ktaCenter, "My first Xojo output!" call pdf.SetFont "Times", pdf.kfsItalic, 20.0, true, pdf.kcpUnicode 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
Sign
End Sign
End Project

See also:

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


The biggest plugin in space...