Platforms to show: All Mac Windows Linux Cross-Platform
/DynaPDF/Web Edition/Cards Web1
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Web Edition/Cards Web1
This example is the version from Mon, 16th Jan 2022.
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Web Edition/Cards Web1
This example is the version from Mon, 16th Jan 2022.
Project "Cards Web1.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Open(args() as String)
'LoadImageFolder
LoadImageRemote
End EventHandler
Function FindFile(name as string) As FolderItem
// Look for file in parent folders from executable on
dim parent as FolderItem = app.ExecutableFile.Parent
while parent<>Nil
dim file as FolderItem = parent.Child(name)
if file<>Nil and file.Exists then
Return file
end if
parent = parent.Parent
wend
End Function
Function LoadFile(name as string) As FolderItem
// load image from MBS Website
Static tempfolder As FolderItem
if tempfolder = nil then
tempfolder = SpecialFolder.Temporary.Child("Cards")
tempfolder.CreateAsFolder
End If
Dim file As FolderItem = tempfolder.Child(name)
// e.g. https://www.monkeybreadsoftware.de/xojo/images/Cards/thumb4.jpg
If Not file.Exists Then
Dim URL As String = "https://www.monkeybreadsoftware.de/xojo/images/Cards/"+name
Dim c As New CURLSMBS
c.OptionURL = url
Call c.CreateMTOutputFile(file)
Dim e As Integer = c.Perform
If e <> 0 then
Dim DebugLog As String = c.DebugData
// got error? Check log!
Break
End If
End If
Return file
End Function
Sub LoadImageFolder()
// Please provide your own Cards folder with files:
// thumb*.jpg for little thumbnails of pictures
// pic*.jpg for actual pictures
// back*.jpg for backgrounds as thumbnail pictures
// back*.pdf for actual backgrounds as PDF
// back*small.pdf for actual backgrounds as PDF with lower resolution
Dim f As FolderItem = FindFile("Cards")
While Not f.Exists
If f.parent.parent = Nil Then
Print "Failed to find Cards folder"
Break
Quit
End If
f = f.parent.parent.Child("Cards")
Wend
If f = Nil then
Break
end if
Thumbnails.Append New WebPicture(Picture.Open(f.Child("thumb1.jpg")), Picture.FormatJPEG)
Thumbnails.Append New WebPicture(Picture.Open(f.Child("thumb2.jpg")), Picture.FormatJPEG)
Thumbnails.Append New WebPicture(Picture.Open(f.Child("thumb3.jpg")), Picture.FormatJPEG)
Thumbnails.Append New WebPicture(Picture.Open(f.Child("thumb4.jpg")), Picture.FormatJPEG)
pictureFiles.Append f.Child("pic1.jpg")
pictureFiles.Append f.Child("pic2.jpg")
pictureFiles.Append f.Child("pic3.jpg")
pictureFiles.Append f.Child("pic4.jpg")
BackPictures.Append New WebPicture(Picture.Open(f.Child("back1.jpg")), Picture.FormatJPEG)
BackPictures.Append New WebPicture(Picture.Open(f.Child("back2.jpg")), Picture.FormatJPEG)
BackPictures.Append New WebPicture(Picture.Open(f.Child("back3.jpg")), Picture.FormatJPEG)
BackPictures.Append New WebPicture(Picture.Open(f.Child("back4.jpg")), Picture.FormatJPEG)
backs.Append f.Child("back1.pdf")
backs.Append f.Child("back2.pdf")
backs.Append f.Child("back3.pdf")
backs.Append f.Child("back4.pdf")
backsmall.Append f.Child("back1small.pdf")
backsmall.Append f.Child("back2small.pdf")
backsmall.Append f.Child("back3small.pdf")
backsmall.Append f.Child("back4small.pdf")
End Sub
Sub LoadImageRemote()
// Please provide your own Cards folder with files:
// thumb*.jpg for little thumbnails of pictures
// pic*.jpg for actual pictures
// back*.jpg for backgrounds as thumbnail pictures
// back*.pdf for actual backgrounds as PDF
// back*small.pdf for actual backgrounds as PDF with lower resolution
// load from MBS Website
Thumbnails.Append New WebPicture(Picture.Open(LoadFile("thumb1.jpg")), Picture.FormatJPEG)
Thumbnails.Append New WebPicture(Picture.Open(LoadFile("thumb2.jpg")), Picture.FormatJPEG)
Thumbnails.Append New WebPicture(Picture.Open(LoadFile("thumb3.jpg")), Picture.FormatJPEG)
Thumbnails.Append New WebPicture(Picture.Open(LoadFile("thumb4.jpg")), Picture.FormatJPEG)
pictureFiles.Append LoadFile("pic1.jpg")
pictureFiles.Append LoadFile("pic2.jpg")
pictureFiles.Append LoadFile("pic3.jpg")
pictureFiles.Append LoadFile("pic4.jpg")
BackPictures.Append New WebPicture(Picture.Open(LoadFile("back1.jpg")), Picture.FormatJPEG)
BackPictures.Append New WebPicture(Picture.Open(LoadFile("back2.jpg")), Picture.FormatJPEG)
BackPictures.Append New WebPicture(Picture.Open(LoadFile("back3.jpg")), Picture.FormatJPEG)
BackPictures.Append New WebPicture(Picture.Open(LoadFile("back4.jpg")), Picture.FormatJPEG)
backs.Append LoadFile("back1.pdf")
backs.Append LoadFile("back2.pdf")
backs.Append LoadFile("back3.pdf")
backs.Append LoadFile("back4.pdf")
backsmall.Append LoadFile("back1small.pdf")
backsmall.Append LoadFile("back2small.pdf")
backsmall.Append LoadFile("back3small.pdf")
backsmall.Append LoadFile("back4small.pdf")
End Sub
Property BackPictures() As WebPicture
Property Backs() As folderitem
Property Thumbnails() As WebPicture
Property backsmall() As folderitem
Property pictureFiles() As folderitem
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 pdf as new MyDynapdfMBS
create pdf
CurrentFile = new WebFile
CurrentFile.Filename = "test.pdf"
CurrentFile.MIMEType = "application/pdf"
CurrentFile.Data = pdf.GetBuffer
HTMLViewer1.URL = CurrentFile.URL
info.Text = Format(lenb(CurrentFile.Data)/1024, "0")+" KB"
End EventHandler
End Control
Control HTMLViewer1 Inherits WebHTMLViewer
ControlInstance HTMLViewer1 Inherits WebHTMLViewer
End Control
Control Button2 Inherits WebButton
ControlInstance Button2 Inherits WebButton
EventHandler Sub Action()
dim pdf as new MyDynapdfMBS
create pdf
CurrentFile = new WebFile
CurrentFile.Filename = "test.pdf"
CurrentFile.MIMEType = "application/pdf"
CurrentFile.Data = pdf.GetBuffer
CurrentFile.ForceDownload = true
info.Text = Format(lenb(CurrentFile.Data)/1024, "0")+" KB"
showurl(CurrentFile.url)
End EventHandler
End Control
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control TextField1 Inherits WebTextField
ControlInstance TextField1 Inherits WebTextField
End Control
Control Label2 Inherits WebLabel
ControlInstance Label2 Inherits WebLabel
End Control
Control PreviewImage Inherits WebImageView
ControlInstance PreviewImage Inherits WebImageView
End Control
Control RadioImage Inherits WebRadioGroup
ControlInstance RadioImage Inherits WebRadioGroup
EventHandler Sub SelectionChanged()
dim n as integer = val(me.SelectedTag)
PreviewImage.Picture = app.Thumbnails(n)
End EventHandler
End Control
Control Label3 Inherits WebLabel
ControlInstance Label3 Inherits WebLabel
End Control
Control RadioBack Inherits WebRadioGroup
ControlInstance RadioBack Inherits WebRadioGroup
EventHandler Sub SelectionChanged()
dim n as integer = val(me.SelectedTag)
PreviewBack.Picture = app.BackPictures(n)
End EventHandler
End Control
Control PreviewBack Inherits WebImageView
ControlInstance PreviewBack Inherits WebImageView
End Control
Control Label4 Inherits WebLabel
ControlInstance Label4 Inherits WebLabel
End Control
Control TextField2 Inherits WebTextField
ControlInstance TextField2 Inherits WebTextField
End Control
Control Label5 Inherits WebLabel
ControlInstance Label5 Inherits WebLabel
End Control
Control CheckBox1 Inherits WebCheckBox
ControlInstance CheckBox1 Inherits WebCheckBox
End Control
Control info Inherits WebLabel
ControlInstance info Inherits WebLabel
End Control
Control Label6 Inherits WebLabel
ControlInstance Label6 Inherits WebLabel
End Control
Control Link1 Inherits WebLink
ControlInstance Link1 Inherits WebLink
End Control
EventHandler Sub Open()
PreviewBack.Picture = app.BackPictures(0)
PreviewImage.Picture = app.Thumbnails(0)
End EventHandler
Sub Create(pdf as dynaPDFMBS)
dim d as new date
dim f as FolderItem = SpecialFolder.Desktop.Child("Create PDF.pdf")
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 REAL Studio output"
call pdf.SetDocInfo pdf.kdiProducer, "REAL Studio test application"
call pdf.SetDocInfo pdf.kdiTitle, "My first REAL Studio output"
dim file as folderitem
if CheckBox1.Value then
// reduce quality
call pdf.SetJPEGQuality(50)
call pdf.SetResolution(100)
call pdf.SetCompressionFilter(pdf.kcfJPEG)
call pdf.SetSaveNewImageFormat(true)
file = app.backsmall(val(RadioBack.SelectedTag))
else
// maximum quality
call pdf.SetJPEGQuality(80)
call pdf.SetResolution(300)
call pdf.SetCompressionFilter(pdf.kcfFlate)
call pdf.SetSaveNewImageFormat(false)
file = app.Backs(val(RadioBack.SelectedTag))
end if
// We want to use top-down coordinates
call pdf.OpenImportFile(file, 0, "")
call pdf.ImportPDFFile(1, 1.0, 1.0)
call pdf.EditPage(1)
call pdf.SetFont "Times", pdf.kfsItalic, 30.0, true, pdf.kcpUnicode
call pdf.SetTextRect 0, 750, pdf.GetPageWidth, 100
call pdf.WriteFText pdf.ktaCenter, TextField1.Text
call pdf.SetFont "Times", pdf.kfsItalic, 30.0, true, pdf.kcpUnicode
call pdf.SetTextRect 0, 130, pdf.GetPageWidth, 100
call pdf.WriteFText pdf.ktaCenter, TextField2.Text
dim picfile as folderitem = app.pictureFiles(val(RadioImage.SelectedTag))
dim w as Double = 500
dim h as Double = 375
dim x as Double = (pdf.getpagewidth-w)/2
dim y as Double = (pdf.getpageheight-h)/2
call pdf.InsertImageEx(x,y,w,h, picfile, 1)
call pdf.SetFont "Times", pdf.kfsNone, 10.0, true, pdf.kcpUnicode
call pdf.WriteText 20.0, 20.0, d.LongDate+" "+d.LongTime+", Made with REAL Studio Web Edition and MBS DynaPDF Plugin."
call pdf.EndPage
call pdf.CloseFile
End Sub
Property CurrentFile 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
WebPage1.MsgBox ErrorMessage
Return 0 // ignore
End EventHandler
Property IgnoreWarnings As Boolean
End Class
End Project
See also:
- /DynaPDF/Web Edition/Cards Web2
- /DynaPDF/Web Edition/Clickable Links in Web Edition/Clickable Links in Web Edition
- /DynaPDF/Web Edition/Create PDF Web1
- /DynaPDF/Web Edition/Create PDF Web2
- /DynaPDF/Web Edition/Web RTF to PDF Web1
- /DynaPDF/Web Edition/Web RTF to PDF Web2
- /DynaPDF/Web Edition/WebPDF Web1
- /DynaPDF/Web Edition/WebPDF Web2
- /DynaPDF/Web Edition/WebPicture from PDF Page Web1
- /DynaPDF/Web Edition/WebPicture from PDF Page Web2
The items on this page are in the following plugins: MBS DynaPDF Plugin.
Feedback: Report problem or ask question.