Simple Print to PDF question

Yes, that’s when using the enumeration values.

Odd. Running perfectly here with the aforementioned changes on Linux Mint. What distribution are you using?

Is your image holding multiple resolutions? I tried with an image dropped in the Navigator and with only 1x resolution.

Yes - it’s a HiDPI app

Aha! That’s is a bug that needs to be fixed for 2022r3.

Meanwhile, you can change the offending line to: g.DrawPicture(SafeMigrateMain_MasterHeader.ImageAt(0), 0, 464)

My advice: take the image with the 2x resolution —ImageAt(1), for example— and use the additional parameters of DrawPicture to set the desired output size… always such size is less or equal to the 2x image. That way you’ll get crispier images in the resulting PDF file.

1 Like

Thanks @Javier_Menendez !

1 Like

giphy

Too many arguments - got 1, expectes 0.

Duh?

Var p As Picture = SafeMigrateMain_MasterHeader.ImageAt(1)
g.DrawPicture(p, 0, 464,100,50,0,0,p.Width,p.Height)

Works both on 2022r2 and 2022r3(beta)

2 Likes

Ahh - Picture not an Image directly :slight_smile:

This also works:

g.DrawPicture(SafeMigrateMain_MasterHeader.ImageAt(1), 0, 464,100,50,0,0,SafeMigrateMain_MasterHeader.ImageAt(1).Width,SafeMigrateMain_MasterHeader.ImageAt(1).Height)

1 Like

victory-winning

I prefer the separate Picture object since I need to deal with the user’s selection for the Image.

For posterity - the finalized working code for the example project is:

Dim ps As New PDFDocument(PDFDocument.PageSizes.Letter)
Dim g As PDFGraphics
Dim PDFLogFile As FolderItem
Dim leftmargin, margin, curY As Integer


g = ps.Graphics
If g = Nil Then
  Return
Else
  leftmargin = 24
  margin = 36
  Dim p As Picture =  SafeMigrateMain_MasterHeader.ImageAt(1)
  g.DrawPicture(p, 0, 464, 584, 135, 0, 0, p.Width, p.Height)
  g.FontName = "Liberation Sans"
  g.Bold = True
  g.FontSize = 24
  g.DrawText "Safe Migrate Job Log", leftmargin, 48
  g.FontSize = 9
  g.DrawText("Safe Migrate Job Results:", leftmargin, 2*72)
  curY = 2.3*72
  g.FontName = "Liberation Mono"
End If
PDFLogFile = SpecialFolder.Documents.Child("Safe Migrate Logs").Child("Test PDF Save.pdf")
ps.Save(PDFLogFile)
ps = Nil
2 Likes