Alaska Software Inc. - Quickpdf add image
Username: Password:
AuthorTopic: Quickpdf add image
Rudolf ReinthalerQuickpdf add image
on Mon, 23 Jan 2012 13:46:12 +0100
Hello, I would like to add an image to a pdf file, but have no success. 
Maybe someone can help. There is no error reported when generating the 
pdf. What I am missing ?
regards
Rudolf


function replimage()
******************************************************************
local cFile := "test.pdf",cFile2 := "test2.pdf"
local nPageID,nPages
WITH OBJECT ( oPdf := TQuickPdf():New() )
      nPageID := .:LoadFromFile(cFile)
      nPages := .:PageCount()
      nImage := .:AddImageFromFile("logo.bmp")
      if nImage > 0
           nTmp := .:selectimage(nImage)
           nTmp := .:drawimage(0,0,596,200)
           //nTmp := .:Fitimage(0,0,596,200 ,0,0,0)
           nTmp := .:SaveToFile(cFile2)
      endif
      .:Destroy()
END WITH
if fexists(cFile2)
      winapiopen(cFIle2)
endif
return .t.
Rudolf ReinthalerRe: Quickpdf add image
on Wed, 25 Jan 2012 09:05:33 +0100
Hello,
found it, maybe someone else can use it. With this code I cut the top of 
a pdf, add a logo and make a new pdf.The rendering for the new page is 
needed, becaus the text in the top of the resulting pdf is still 
markable in pdf reader.
regards
Rudolf


function replimage(cFile,cFile2,cLogo)
******************************************************************
local nWidth := 0,nHeight := 0
local nPageID,nPages
default cFile  to "test.pdf"
default cFile2 to "test2.pdf"
default cLogo  to "logo.jpg"
altd()
WITH OBJECT ( oPdf := TQuickPdf():New() )
      nPageID := .:LoadFromFile(cFile)
      nPages := .:PageCount()
      nImage := .:AddImageFromFile(cLogo,1)
      .:SetPageSize("A4")
      .:SetOrigin(1)
      .:SetMeasurementUnits(1)
      nWidth  := .:PageWidth()
      nHeight := .:PageHeight()
      if nImage > 0
           nTmp := .:SelectPage(1)
           nTmp := .:selectimage(nImage)
           nTmp := .:drawimage(0,0,nWidth,100)
           .:RenderDocumentToFile(300,1,1,1,"tmprender.jpg")
           .:NewPage()
           .:SelectPage(2)
           nImage := .:AddImageFromFile("tmprender1.jpg",1)
           nTmp   := .:selectimage(nImage)
           nTmp   := .:drawimage(0,0,nWidth,nHeight)
           nTmp := .:SaveToFile(cFile2+".tmp")
           .:SelectPage(1)
           nTmp   := .:deletepages(1,1)
           nTmp := .:SaveToFile(cFile2)
      endif
      .:Destroy()
END WITH
if pcount() = 0
if fexists(cFile2)
      winapiopen(cFIle2)
endif
endif
return .t.