.Net MAUI moves along

Rasmus Lerdorf : PHP Frameworks all suck !

:+1:

1 Like

Interesting…

My issue was how abstracted the frameworks I looked at. I couldn’t understand what the heck it was doing.

In my head, I have a DB Table and just want to place Column values as a Label or as an Input with auto massaging of numbers and dates.

The card below is created using this code… I’d love to find a framework that is similar.

Apologies. I assumed that you were referring to the cost of the DynaPDF library. The DynaPDF MBS plugin is roughly the price you quoted.

Wrong again. The code at the bottom of this reply (which I created in just over an hour) shows how to use the pre-built shared library for macOS to render a page into a Xojo picture. It is not great code but it shows that it can be done.

Hah! So you want to get me banned because I don’t agree with you.

Code…

Const kLibPath = "../../../libpdfium.dylib"

Soft Declare Sub FPDF_InitLibraryWithConfig Lib kLibPath (config As Ptr)
Soft Declare Sub FPDF_DestroyLibrary Lib kLibPath
Soft Declare Function FPDF_CreateNewDocument Lib kLibPath As Ptr
Soft Declare Function FPDF_LoadDocument Lib kLibPath (file_path As CString, password As CString) As Ptr
Soft Declare Function FPDF_GetLastError Lib kLibPath As Integer
Soft Declare Sub FPDF_CloseDocument Lib kLibPath (doc As Ptr)
Soft Declare Function FPDF_GetPageCount Lib kLibPath (doc As Ptr) As Integer
Soft Declare Function FPDF_GetPageSizeByIndex Lib kLibPath (doc As Ptr, pageindex As Integer, ByRef width As Double, ByRef height As Double) As Integer
Soft Declare Function FPDF_LoadPage Lib kLibPath (doc As Ptr, pageindex As Integer) As Ptr
Soft Declare Sub FPDF_ClosePage Lib kLibPath (page As Ptr)
Soft Declare Function FPDFBitmap_CreateEx Lib kLibPath (width As Integer, height As Integer, format As Integer, firstscan As Ptr, stride As Integer) As Ptr
Soft Declare Sub FPDFBitmap_Destroy Lib kLibPath (bitmap As Ptr)
Soft Declare Sub FPDFBitmap_FillRect Lib kLibPath (bitmap As Ptr, left As Integer, top As Integer, width As Integer, height As Integer, colour As Integer)
Soft Declare Sub FPDF_RenderPageBitmap Lib kLibPath (bitmap As Ptr, page As Ptr, startx As Integer, starty As Integer, sizex As Integer, sizey As Integer, rotate As Integer, flags As Integer)

'initialise
Dim fpdfConfig As MemoryBlock

fpdfConfig = New MemoryBlock(4 + 8 + 8 + 8 + 4)
fpdfConfig.UInt32Value(0) = 3

FPDF_InitLibraryWithConfig(fpdfConfig)



'load a pdf
Dim doc As Ptr
Dim err As Int32

doc = FPDF_LoadDocument(GetFolderItem("Xojo Documentation.pdf").NativePath, "")
If doc = Nil Then
  err = FPDF_GetLastError
  break
End If



'get the page count
Dim pageCount As Int32
pageCount = FPDF_GetPageCount(doc)



'get the page dimensions
Dim pageWidth, pageHeight As Double

If FPDF_GetPageSizeByIndex(doc, 0, pageWidth, pageHeight) = 0 Then
  err = FPDF_GetLastError
  break
End If



'load the page
Dim page As Ptr
page = FPDF_LoadPage(doc, 0)

If page = Nil Then
  err = FPDF_GetLastError
  break
End If



'create a bitmap to hold the rendered page
Const FPDFBitmap_Unknown = 0 'Unknown or unsupported format.
Const FPDFBitmap_Gray = 1 'Gray scale bitmap, one byte per pixel.
Const FPDFBitmap_BGR = 2 '3 bytes per pixel, byte order: blue, green, red.
Const FPDFBitmap_BGRx = 3 '4 bytes per pixel, byte order: blue, green, red, unused.
Const FPDFBitmap_BGRA = 4 '4 bytes per pixel, byte order: blue, green, red, alpha.
Dim pixelBuffer As MemoryBlock
Dim pageBitmap As Ptr
pixelBuffer = New MemoryBlock(pageWidth * pageHeight * 4)

pageBitmap = FPDFBitmap_CreateEx(pageWidth, pageHeight, FPDFBitmap_BGRx, pixelBuffer, 0)

If pageBitmap = Nil Then
  err = FPDF_GetLastError
  break
End If



'fill the bitmap white
FPDFBitmap_FillRect(pageBitmap, 0, 0, pageWidth, pageHeight, &hFFFFFFFF)



'render the page
FPDF_RenderPageBitmap(pageBitmap, page, 0, 0, pageWidth, pageHeight, 0, 0)



'convert the pixel buffer to a xojo picture
'note. this isn't an efficient way to perform the conversion but it proves that rendering works
Dim output As Picture
Dim r As RGBSurface
Dim x, y As Int32
Dim pixelBufferIndex As Int32

output = New Picture(pageWidth, pageHeight)
r = output.RGBSurface

pixelBufferIndex = 0
For y = 0 To pageHeight - 1
  For x = 0 To pageWidth - 1
    r.Pixel(x, y) = RGB(pixelBuffer.UInt8Value(pixelBufferIndex + 2), pixelBuffer.UInt8Value(pixelBufferIndex + 1), pixelBuffer.UInt8Value(pixelBufferIndex))
    
    pixelBufferIndex = pixelBufferIndex + 4
  Next
Next



'dispose of the page bitmap
FPDFBitmap_Destroy(pageBitmap)



'close the page
FPDF_ClosePage(page)



'close the pdf
FPDF_CloseDocument(doc)



'destroy the library
FPDF_DestroyLibrary

Break
2 Likes

So passive psychology wins: you’ve done what I wanted: served an example. Thanks for that. You could prevent this discussion in doing that directly. While most of the Xojo programmers can’t do that acting like you have done is not worth of reading for them. This here is a nice Idea.

But nicer would be. Xojo Project where you show that this is working. Should not be any problem for you also to show for windows and Linux. As you are now providing this for MacOS only. Users having not all MacOS. Possibly you did not get that. Happy that with Java all of this is never platform related. So for me there is no need for a Library working with Xojo. But for others is. That’s why I wanted you to provide that. It would help not me but Xojo Users. Like you were doing first it is not helping anybody. That’s why I don’t like the wise you are doing stuffs. Bad thinking always and meaning that you are the more intelligent one. Use it. For good things.

and no: I don’t want to get you banned because of not agreeing. I want to get you banned because of your behavior. And the next is: this entire shit is off topic and has nothing to do with the question from beginning. Posting one between okay bit the amount you produce…but neat, you provided the example you don’t wanted to provide in the beginning. Possibly you are a bit too aggressive. Learn to control that. For me it is not a bit from interest if you are here or not.

Thanks for the example but if you restrict yourself to macOS then you can do the same much simpler with macOSlib

But I didn’t get into Xojo 20 years ago to do Mac only apps, so my question is does this work cross-platform?

If you can create a Xojo plugin to display PDFs then there certainly seems to be a need (and therefore a market) for it …

And as speaking as someone who was banned from here for 3 months and told a permanent ban might be in the cards I would hope people here have the balls to NOT ban dissenting voices.

And just for the record: if someone is an idiot I will still tell them so. :stuck_out_tongue:

1 Like

If there is a good open source package that can create pictures of PDF, maybe Bjorn (Einhugur) could create one.

I agree that DynaPDF Pro is too expensive when you are only missing the ability to display and/or print PDFs directly in your apps…

I used to just launch the PDF once created… not great UI but usable.

1 Like

This is a great clip. Although his critique of the big frameworks seems more about poor design of those frameworks (or some inherent limitation of PHP? IDK) than it does about the idea of a large framework. I am not claiming to be an expert or to have built a large general purpose framework but I am quite certain that I would never construct one so that it has to stupidly check which DB you are using on each an every call, as he describes.

I have been mostly a consumer of a large general purpose framework called .NET since the mid-2000’s and it does seem as though there’s a lot of backtracking and rethinking over time. Some things I can think of:

3 different remote procedure call sub-frameworks over the years

3 major revisions to ASP.NET (original ASP.NET – itself an evolution of “classic ASP” – ASP.NET MVC and ASP.NET MVC Core)

4 major revisions to the flagship desktop app dev technology (WinForms, WPF, Xamarin, .NET Maui)

On the other hand you can still choose to use any of the listed technologies above even today, though the oldest are getting pretty neglected / deprecated. I had to use original ASP.NET for an existing client project as recently as last year, although it hasn’t been maintained for years by MSFT.

My approach to Xojo has been to do minimalist extension of built in classes myself; I think I have 3 minor ones in a fairly large app. I’m reluctant to start buying plugins, in part because of the cost and in part because now I have to deal with the possibility of plugins breaking with each new Xojo release, and the constant irritating nattering about “please unload all your plugins to see if the problem goes away” as if I have that kind of time at my disposal.

My approach to .NET has been to avoid dependence on 3rd party libs for cost reasons and due to having limitations on upgrading to the latest .NET release because I have to wait on 3rd party lib updates. I have a very large system that relies only on the Aspose Excel lib, and we have not updated that in a few years. It would be fairly easy to update or replace a different one. But on the UI side, that team uses Telerik and some other control vendors, and I know they had some headaches over the years being held back waiting for new releases.

oh I know exactly that it will not be happened. For sure. But I know also: after provocation he presented a solution for macOS. I hope the he will do also for Windows and Linux. As you said: Xojo is not for single platform use only.

Great example. what is wrong with the lazy divas? the only change needed to be cross platform is the path :rofl:

2 Likes

Prebuilt versions of pdfium for different targets is available here:

I only tested macOS because I couldn’t be arsed to boot up my Windows VM. However, I see no reason why it wouldn’t work.

1 Like

Downloading a different library and changing the path is obviously too difficult for them.

:man_facepalming:

Hi Karen

Checkout the declare based sample code I posted in another reply. My code uses the pdfium library which is available for different targets so should work cross platform.

Running a PCR isn’t difficult, but I’ll guess you might struggle with it.

Actually most things are easy if you know how.

Being condescending to those who don’t know and ask is a poor show of character.

Still - thanks for the answer.

I am quite confused as to why this discussion is even taking place… Or perhaps I misunderstood the latest release of Xojo (disclaimer : I stopped Xojo in 2019)

But doesn’t Xojo now contain built in functions to create PDF files? rendering most of the above solutions possibly unnecessary any more?

I do know that years ago I wrote gPDF, a 100% Xojo code class that created PDF files using the same syntax as the existing Xojo Graphics features. Which is what I beleive the internal methods now do

1 Like

Dave, I haven’t needed PDF functionality nor paid much attention to it yet but the notes for the releases this year suggest they put a lot of effort into that part of the product.

Create? Yes.

Display? No.

If you want to display a PDF in your cross-platform app it is $1,100 for DynaPDFMBS Professional - the Starter and Lite editions do not support that.

For Mac Only macOSlib has a nice PDF viewer window pretty much ready to use.

As I’m not a wiz with declares, I am not sure it would be a good long term solution for me…

That said, if the library can output PNGs , prefereably in a way you don’t have to write an actual file to disk, that would likely to be a lot more efficient.

If that is a pretty full featured library, If Bjorn comprehensively adapted that to a plugin, having the ability to render PDF to Xojo Pictures would make his plugin set a lot more attractive than the buying DynaPDF plugin alone for many (depending on featured needed).