Aspose.Pdf.DOM.Matrix

Hi

Im am evaluating your product .Net PDF an I am look how to insert images in a PDF.

I have used this example


http://www.aspose.com/docs/display/pdfnet/Add+Image+to+Existing+PDF+File

But what I dont grasp is how the

Dim rectangle As New Aspose.Pdf.Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY)
Dim matrix As New Aspose.Pdf.DOM.Matrix(New Double() { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY })

'Using ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed
page.Contents.Add(New Operator.ConcatenateMatrix(matrix))
Dim ximage As XImage = page.Resources.Images(page.Resources.Images.Count)

is working.

There is no explanation in class for the Aspose.Pdf.DOM.Matrix and no explanation of the parameters.

Can you help ?

Cheers

Christian


Hi Christian,


Thanks for using our API’s.

The Matrix class object initialization takes rectangle object as an argument and its used to add image inside PDF file. However, I suggest you to please try using following simple code snippet to add image inside PDF file.

[C#]

// instantiate Document object<o:p></o:p>

Document pdfDocument = new Document();

// add page to pages collection of PDF file

pdfDocument.Pages.Add();

// create image object

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

// specify the file for image object

image.File = "c:/pdftest/sample.png";

// add image to paragraphs collection of first page of PDF document

pdfDocument.Pages[1].Paragraphs.Add(image);

// save resultant file

pdfDocument.Save(“c:/pdftest/Image_in_PDF_File.pdf”);

Hi

Thanks for the Answer.

But I need to put the image always on the to right corner maximised to the page width for each page (1 to 10 pages with its own image, one image per page)
This I can not do with the paragrah image add or ?


Cheers

Christian

Hi Christian,


Thanks for sharing the details.

As per my understanding, you need to add the image to complete page area inside PDF document. If so is the case, then please set image dimensions equal to page dimensions and in order to add 10 images to 10 pages inside PDF file, you need to iterate through individual page inside PDF document.

[C#]

//
instantiate Document object
<o:p></o:p>

Document pdfDocument = new Document();

// add page to pages collection of PDF file

pdfDocument.Pages.Add();

// create image object

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

// specify the file for image object

image.File = "c:/pdftest/gg_EdiblePerks_Issue.png";

image.FixWidth = pdfDocument.Pages[1].PageInfo.Width;

image.FixHeight = pdfDocument.Pages[1].PageInfo.Height;

// add image to paragraphs collection of first page of PDF document

pdfDocument.Pages[1].Paragraphs.Add(image);

// save resultant file

pdfDocument.Save("c:/pdftest/Image_in_PDF_File.pdf");