Stamp PDF with PDF

With Aloaha it is not only possible to render text on a PDF Page or to stamp PDF Documents with Images (Render Image). It is also possible to place an existing PDF document on a page of an other PDF document. You can use a PDF document to stamp it on a different PDF.

This functionality can be usefull if a PDF should be assembled out other PDF blocks.

Please see and try the sample code below!


Dim pdf
Dim newpdf
Dim pdfstamp
Dim x
Dim y
Dim page
Dim r_left
Dim r_top
Dim r_width
Dim r_height
Dim savepath

savepath = "d:\newpdf.pdf"
newpdf="d:\bla.pdf"
pdfstamp1="d:\07FO02G1x.pdf"
pdfstamp2="d:\image4.bmp.pdf"

Set pdf = CreateObject("aloahapdf.edit") 

'Create a blank PDF in A4 Format (default)
'Syntax create_new_pdf(clng(PointsX), clng(pointsY), cstr(PDF_Author), cstr(PDF_Subject), cstr(PDF_Keywords), cstr(PDF_Title)) As Boolean

If pdf.create_new_pdf(0,0, "", "", "", "") = true Then
       Call pdf.save_pdf_to_file(CStr(newpdf))
End If

If pdf.load_pdf_to_mem(CStr(newpdf)) = true Then 
  'work with first page
   page = CLng(1) 


  'read x/y dimensions of loaded PDF document
  x=CDbl(pdf.XDimension(CLng(page)))
  y=CDbl(pdf.YDimension(CLng(page)))

  'define x/y position of pdf to be placed (in points)
   r_left=300
   r_top=300
   r_width=100
   r_height=100


   If pdf.Place_PDF_as_Image(CStr(pdfstamp1), CLng(page), CDbl(r_left), CDbl(r_Top), CDbl(r_width), CDbl(r_height)) = true Then 


      'continue to work with the following page
      page=pdf.totalpages+1 

      'append blank page to PDF document
      Call pdf.append_blank 

      'define new position
      r_left=200
      r_top=500
      r_width=150
      r_height=150 

      If pdf.Place_PDF_as_Image(CStr(pdfstamp2), CLng(page), CDbl(r_left), CDbl(r_Top), CDbl(r_width), CDbl(r_height)) = true Then 
         Call pdf.save_pdf_to_file(CStr(savepath))
      End If
   End If
End If

Set pdf = nothing




Aloaha Software / Knowledge Base / PDF SDK / Stamp PDF with PDF
create PDF Software

Stamp PDF with PDF

Any questions?
Aloaha Software - Knowledge Base / PDF SDK / Stamp PDF with PDF
ProductsKnowledge BaseShopSupportPress
Deutsche VersionEnglish version