On Sat, 2013-08-24 at 10:54 +0200, Tobias Boege wrote: > On Sat, 24 Aug 2013, Willy Raets wrote: > > On Sat, 2013-08-24 at 03:19 +0200, Willy Raets wrote: > > > Hi All, > > > > > > Been struggling with inserting an existing .png file onto a > > > CairoPdfSurface (gb.cairo). > > > > > > Done some extensive reading in the documentation but do not seem to find > > > a method get the job done. Is this not possible or am I misunderstanding > > > the documentation? > > > > > > Piece of the code of the project: > > > > > > Public Sub MakePdf() > > > > > > Dim hPdfProjectFile As CairoPdfSurface > > > Dim sPdfPath, sPicPath As String > > > Dim iX, iY As Float > > > sPicPath = User.Home & "/MyFolder/mypicture.png" > > > sPdfPath = User.Home & "/MyFolder/project.pdf" > > > hPdfProjectFile = New CairoPdfSurface(sPdfPath, 210, 297) > > > Cairo.Begin(hPdfProjectFile) > > > '--Draw title -- > > > iY = 250 > > > '-- Some code to determine X co??rdinate iX -- > > > ... > > > ... > > > Cairo.Font.Bold = True > > > Cairo.Font.Size = 18 > > > Cairo.MoveTo(iX, iY) > > > Cairo.DrawText(Start.ProjectLoadedTitle) > > > Cairo.Font.Bold = False > > > ' > > > '--Draw project logo -- > > > iY = 285 > > > ... '<== stuck right here!! > > > ' > > > '--Draw Document Version-- > > > iY = 500 > > > ... > > > ... > > > Cairo.End > > > > > > End > > > > > > Anyone any ideas, suggestions, links? > > > > > > > Just to clarify, I need the .png in sPicPath = User.Home & > > "/MyFolder/mypicture.png" do be drawn underneath the Title at > > section '--Draw project logo -- > > > > Maybe you could (ab)use Cairo.ImagePattern()? Load the image, call that > method and assign the result to Cairo.Source. Cairo.Paint() then does the > job.
I already tried the Cairo.ImagePattern, but didn't know about having to assign the result to Cairo.Source. so I have tried this now, but still no result. I am new to cairo and not completely understand all that it does (my lack of insight). This is the code I tried now but it doesn't give me a result. What am I doing wrong? Public Sub MakePdf() Dim hPdfProjectFile As CairoPdfSurface Dim sPdfPath, sPicPath As String Dim picImage As Image Dim iX, iY As Float sPicPath = User.Home & "/MyFolder/mypicture.png" sPdfPath = User.Home & "/MyFolder/project.pdf" hPdfProjectFile = New CairoPdfSurface(sPdfPath, 210, 297) Cairo.Begin(hPdfProjectFile) '--Draw title -- .. .. '--Draw project logo -- iX = 230 iY = 235 If Exist(sPicturePath) Then picImage.Load(sPicturePath) Cairo.MoveTo(iX, iY) Cairo.Source = Cairo.ImagePattern(picImage) Cairo.Paint '<-- nothing gets painted on PdfSurface Endif .. End > > I don't know Cairo but this seems like how it's done here[0]. It works in my > test case. Don't know much C but I'll analyse and see if I get any wiser. Thanks > > Regards, > Tobi > > [0] http://zetcode.com/gfx/cairo/cairoimages/ -- Kind regards, Willy (aka gbWilly) http://gambasshowcase.org/ http://howtogambas.org http://gambos.org ------------------------------------------------------------------------------ Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user