We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Showing images in a PdfLightTable cell

Thread ID:

Created:

Updated:

Platform:

Replies:

117606 Nov 14,2014 04:05 PM UTC Nov 27,2014 06:27 AM UTC Xamarin.Forms 12
loading
Tags: PDF
Ali Ben Zarrouk
Asked On November 14, 2014 04:05 PM UTC

Hi,

Can you please tell me how to put an image in a cell of a PdfLightTable ?

table.Style.ShowHeader = true;
            table.BeginCellLayout += (object sender2, BeginCellLayoutEventArgs args) => {
            if ((args.RowIndex > -1) && (args.CellIndex == 2))
               args.Graphics.DrawImage(elements[args.RowIndex].signature, args.Bounds);
            };


elements.Add(new TableUnit() {name = "Name", value= "Value", signature = PdfImage.FromStream(ToStream("Signature.png"))});

public static Stream ToStream(string filePath) {
         var stream = new System.IO.MemoryStream();
         return new UIImage(filePath).AsJPEG().AsStream();
         stream.Position = 0;
         return stream;
         }


This did not work ... :/

Any clue ?

Praveenkumar H [Syncfusion]
Replied On November 17, 2014 11:16 AM UTC



Hi Ali,


Thank you for using syncfusion products,


We have created the sample to draw the “Png” image in PdfLightTable cell and attached for your reference,


if (args.CellIndex % 2 == 0 && !string.IsNullOrEmpty(args.Value))


{


//Drawing the image


args.Skip = true;


PdfImage image = PdfImage.FromStream (ToStream("pdf.png"));


Syncfusion.Drawing.RectangleF rect = args.Bounds;


args.Graphics.DrawImage (image, new Syncfusion.Drawing.RectangleF (rect.X + 2, rect.Y + 2, rect.Width - 2, rect.Height - 2));


}


 


 


public Stream ToStream(string path)


{


Stream stream = new MemoryStream();


stream =  UIImage.FromBundle(path).AsJPEG().AsStream();


//stream.Position = 0;


return stream;


}


 


Please let us know if you need further assistance.


With Regards,


Praveen




Attachment: PdfLightTableTesting_634e57cc.zip

Ali Ben Zarrouk
Replied On November 17, 2014 12:16 PM UTC

It works thanks !

Ali Ben Zarrouk
Replied On November 17, 2014 03:16 PM UTC

Can you please assist me with something else :

Do I necessarily need Xamarin.Forms for operations like :
- Load PDF file
- Show PDF file
- Add pages to PDF file

Can I do these without Xamarin.Forms

Praveenkumar H [Syncfusion]
Replied On November 18, 2014 12:21 PM UTC

Hi Ali,

Our Syncfusion xamarin pdf will work in following platforms.

  1. Xamarin.Android

  2. Xamarin.IOS

  3. Xmarin.WindowsPhone

  4. Xamarin.Forms.

So you can use the all PDF related operations in all other platform also there is no necessary to use only xamarin.Forms.

With Regards,

Praveen


Praveenkumar H [Syncfusion]
Replied On November 18, 2014 12:37 PM UTC

Hi Ali,

A quick note on our previous update. Our Pdf library for Xamarin is a portable library and can be used in any kind of xamarin app. It doesnt require a Xamarin.Forms dependency.

Please let me know if there is any other concerns.

With Regards,

Praveen


Ali Ben Zarrouk
Replied On November 18, 2014 01:54 PM UTC

Hi,

Thanks for the info.
Is it possible to customise a cell ? Like for example having a table of elements like in attached picture.



Attachment: custom_cell.png_6f600bda.zip

KarthikeyanC [Syncfusion]
Replied On November 20, 2014 11:50 PM UTC

Hi Ali,

Thank you for your interest in Syncfusion Products.

 

We are analysing the feasibility of your requirement, we will provide you the details shortly.

 

Regards,

Karthikeyan.C


Ali Ben Zarrouk
Replied On November 24, 2014 09:28 AM UTC

Hello,

Thanks for your responsiveness.
I personally do not need the custom cells no more as I'll work with your classic cells.

I would like to know something else please. How to load a PdfDocument from a path in Xamarin. Couldn't do it ! Is it because I have a trial version that I don't find those methods as I saw methods to load from filepath in your documentation.

Thanks !!!!



Ali Ben Zarrouk
Replied On November 24, 2014 09:36 AM UTC

Sorry but should it be like this ?

PdfDocument doc = new PdfDocument();
            Stream file2 = new FileStream("sample.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);    
            // Load the stream
            PdfLoadedDocument loadedDoc = new PdfLoadedDocument(file2);
            doc.ImportPageRange(loadedDoc, 0, loadedDoc.PageCount - 1);


Praveenkumar H [Syncfusion]
Replied On November 25, 2014 08:54 AM UTC

Hi Ali,

Thank you for your update,

Currently we do have support to load the pdf document from stream.

Please refer the following code snippet.

Stream PdfStream = typeof(DetailViewController).GetTypeInfo().Assembly.GetManifestResourceStream("PdfLightTableTesting.Products.pdf");

PdfLoadedDocument document = new PdfLoadedDocument(PdfStream);

Please let us know if you need further assistance.

With Regards,

Praveen


Ali Ben Zarrouk
Replied On November 26, 2014 09:48 AM UTC

Hi,

Using assembly resources is not an option for me. I download PDf files during runtime and process them !

Is it the only option ?

Praveenkumar H [Syncfusion]
Replied On November 27, 2014 06:27 AM UTC

Hi Ali,

Thank you for your update,

Currently we do support to load the documents only from the stream using PdfLoadedDocument class.

We can load the document from the application documents folder as follow, please refer the below code snippet.

var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

FileStream file = File.OpenRead(path + "/Invoice.pdf");

byte[] data = new byte[file.Length];

file.Read(data, 0, (int)file.Length);

MemoryStream stream = new MemoryStream(data);

PdfLoadedDocument document = new PdfLoadedDocument(stream);

MemoryStream save = new MemoryStream();

document.Save(save);

document.Close(true);

Save("table.pdf", "application/pdf", save);

Please ensure the requested file present in the MyDocuments folder before get the stream from the file.

Please let us know if you need further assistance.

With Regards,

Praveen


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;