PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Add Image to an existing PDF
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1679
Page 1 of 1

Author:  Pee-Wee [ Fri Jun 03, 2011 8:28 am ]
Post subject:  Add Image to an existing PDF

Hi all!!!
I'm having problems when trying to add an image to an existing PDF file. It appears the next error:

"Object type transformation must not be done with direct objects"

Here is my piece of code:

Code:
Dim documento As PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open("path\file_name.pdf")

 If documento.Version <= 14 Then
       documento.Version = 14
 End If

 Dim pagina As PdfPage = documento.Pages(0)
 Dim gfx As XGraphics = XGraphics.FromPdfPage(pagina)
 Dim imagen As XImage = XImage.FromFile(System.AppDomain.CurrentDomain.BaseDirectory & "qr.jpg")

 gfx.DrawImage(imagen, 470, 720)

 documento.Save("new_path\new_file_name.pdf")


I have launched a Release version of the program but that error message still appears ... what am I doing wrong???

Thanks on advance!!!!

Author:  Thomas Hoevel [ Mon Jun 06, 2011 7:13 am ]
Post subject:  Re: Add Image to an existing PDF

Pee-Wee wrote:
I have launched a Release version of the program but that error message still appears ... what am I doing wrong???

Use a release version of the PDFsharp DLLs.

Author:  Pee-Wee [ Tue Jun 07, 2011 6:12 am ]
Post subject:  Re: Add Image to an existing PDF

Thanks a lot, that was the point!!!!!!!

Thanks again!!!!! :D

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/