Add Image On Page  SOLVED

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
edvschu
User
Posts: 127
Joined: Fri Jun 25, 2010 6:54 am

Add Image On Page

Post by edvschu »

Hello,

i want to insert an image into a PDF. The image should be positioned at right upper corner.

I found this https://gist.github.com/Polaringu/daa06 ... c36cbeb14d, but how can i add an image on page still exists.

An example in C# or VB would be great. Thanks.

Best Regards,
edvschu
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Add Image On Page

Post by Sasha - Tracker Dev Team »

Hello edvschu,

What other sample do you need, when you already have a needed sample?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
edvschu
User
Posts: 127
Joined: Fri Jun 25, 2010 6:54 am

Re: Add Image On Page  SOLVED

Post by edvschu »

Your documentation is sometimes hard to read, but I've got it. Here is my code. Perhaps it would help others:

Code: Select all

Private Sub AddImageOnPage()
	Dim pDoc As PDFXCoreAPI.IPXC_Document = OpenDocumentFromFile(sFileAddImage, pdfInst)
	If pDoc Is Nothing Then
		Return
	End If

	Dim sFileWithAddedImage As String = sFileAddImage & ".add.pdf"
	Dim img As PDFXCoreAPI.IPXC_Image = pDoc.AddImageFromFile(sImage)

	Dim m As PDFXCoreAPI.PXC_Matrix
	m.a = 747 / 5   'Image Width
	m.d = 601 / 5   'Image Height
	m.e = 460       'Location x
	m.f = 700       'Location y

	Dim cc As PDFXCoreAPI.IPXC_ContentCreator = pDoc.CreateContentCreator()
	cc.ConcatCS(m)
	cc.PlaceImage(img)

	Dim iPage As Integer = 1
	pDoc.Pages.Item(Convert.ToUInt32(iPage - 1)).PlaceContent(cc.Detach(), CUInt(PDFXCoreAPI.PXC_PlaceContentFlags.PlaceContent_Before))

	pDoc.WriteToFile(sFileWithAddedImage)
	pDoc.Close()
	pDoc = Nothing   
End Sub
Regards,
edvschu
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Add Image On Page

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply