DynaPDFMBS insert or draw picture fail (iOS)?

I’m using common code from a desktop project where I can get an image to show in a pdf.
However when I use this on iOS the picture never shows up.

I’ve tried from by using DynaPDFMBS.insertPicture and p DynaPDFMBS.insertPicture DynaPDFMBS.insertPicture.PageGraphics.DrawPicture. Neither work.

I initially thought it had do do with the image I was drawing containing a mask, but I flattened it and still no joy.

Is this my flaw or a bug?

Version 21.2 of DynaPDF plugin?

I thought so… may 17?

I tried it and it works fine:

Sub Pressed() Handles Pressed
  Dim d As New DynapdfMBS
  Dim file As FolderItem
  
  d.SetLicenseKey "Starter" // For this example you can use a Starter, Lite, Pro or Enterprise License
  
  file=SpecialFolder.Documents.Child("PDF with picture direct.pdf")
  
  Call d.CreateNewPDF file
  Call d.Append
  
  // no recompressing
  Call d.SetSaveNewImageFormat(False)
  Call d.SetJPEGQuality(90)
  
  // get picture
  Dim p As Picture=LogoMBS(500)
  
  Dim x,y,w,h As Integer
  Dim f As Double
  Dim dw As Integer = d.GetPageWidth-100
  Dim dh As Integer = d.GetPageHeight-100
  
  // scale to fit the page size
  f=Min(dw/p.Width, dh/p.Height)
  
  w=f*p.Width
  h=f*p.Height
  
  x=50+(dw-w)/2
  y=50+(dh-h)/2
  
  // add image to pdf without mask
  Call d.InsertPicture(p,x,y,w,h)
  
  Call d.EndPage
  
  
  Call d.CloseFile
  
  MessageBox file.NativePath
  
End Sub

gives

Yeah, this works for me too.
So I dug a bit more. The image I was trying to add was dragged into the project. No good.
When I load it on-demand from the file system it works correctly.

I even tried using all three sizes in my project, and calling bestResolution. I have a picture object, but even in the XOJO IDE I can’t see its contents.

The same behavior isn’t happening on desktop, and I believe is is NOT an MBS bug.

Once again, thank you Christian.

1 Like

Thanks for checking.

If you have a file on disk, better just insert with passing file path.
That uses less memory.

Didnt someone report that dragging an image into the project changes the file format silently?

I may change the image sometime and I need to make sure I have the dimensions right in the software so it’s worth opening it.