PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Put an image from camera with migradoc or pdfsharp
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4340
Page 1 of 1

Author:  Zamoree [ Fri May 06, 2022 8:27 am ]
Post subject:  Put an image from camera with migradoc or pdfsharp

Hi, i have a problem that i cant put an image from the camera to the pdf. It put the same error "Image could not read". How can i do it?
This is the path they gave me when i take a photo = "/storage/emulated/0/Android/data/com.companyname.atecresacalculator/files/Pictures/fotoparapdf_12.jpg"

Code:
Code:
//CompartirInformacion is SharedInformation
namespace AtecresaCalculator.Service
{
    public class CompartirInformacion
    {
        public static string x;

        public static string y;
    }
}


Code:
            Row row = table.AddRow();
            table.Rows.HeightRule = RowHeightRule.Auto;
            row.Cells[0].AddParagraph(text);
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[1].AddParagraph(texto);
            row.Cells[1].AddImage(FromFile(CompartirInformacion.y));
            row.Cells[1].VerticalAlignment = VerticalAlignment.Center;



Code:
        private async void sacarFoto_Clicked(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();
            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("Error en la cámara", "Activa los permisos para usar cámara", "Ok");
                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small,
                Name = "fotoparapdf.jpg",
                CompressionQuality = 100,
                DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Rear,
            });

            if (file == null)
                return;

            await DisplayAlert("Ruta de la foto", file.Path, "Ok");

            CompartirInformacion.y = file.Path;
        }

Author:  TH-Soft [ Fri May 06, 2022 9:38 am ]
Post subject:  Re: Put an image from camera with migradoc or pdfsharp

Are you using Xamarin?
If so, then maybe the authors of your port of our library can help you.
http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

What is "FromFile()" doing?

Author:  Zamoree [ Fri May 06, 2022 9:48 am ]
Post subject:  Re: Put an image from camera with migradoc or pdfsharp

TH-Soft wrote:
Are you using Xamarin?
If so, then maybe the authors of your port of our library can help you.
http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

What is "FromFile()" doing?



1. Yes, im using xamarin forms.

2. Is this method from ImageSource

Code:
        public static IImageSource FromFile(string path, int? quality = 75)
        {
            return ImageSourceImpl.FromFileImpl(path, quality);
        }

Author:  Zamoree [ Fri May 06, 2022 9:51 am ]
Post subject:  Re: Put an image from camera with migradoc or pdfsharp

Zamoree wrote:
TH-Soft wrote:
Are you using Xamarin?
If so, then maybe the authors of your port of our library can help you.
http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

What is "FromFile()" doing?



1. Yes, im using xamarin forms.

2. Is this method from ImageSource

Code:
        public static IImageSource FromFile(string path, int? quality = 75)
        {
            return ImageSourceImpl.FromFileImpl(path, quality);
        }


The method will get the file(CompartirImage.y) where the img are and put it in the row as an image.

Author:  TH-Soft [ Fri May 06, 2022 10:10 am ]
Post subject:  Re: Put an image from camera with migradoc or pdfsharp

FromFile() is not part of the original MigraDoc package which is supported here.
We cannot support all third-party ports of our library here.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/