PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 4:37 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri May 06, 2022 8:27 am 
Offline

Joined: Fri May 06, 2022 8:20 am
Posts: 3
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;
        }


Top
 Profile  
Reply with quote  
PostPosted: Fri May 06, 2022 9:38 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
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?

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri May 06, 2022 9:48 am 
Offline

Joined: Fri May 06, 2022 8:20 am
Posts: 3
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);
        }


Top
 Profile  
Reply with quote  
PostPosted: Fri May 06, 2022 9:51 am 
Offline

Joined: Fri May 06, 2022 8:20 am
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 06, 2022 10:10 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
FromFile() is not part of the original MigraDoc package which is supported here.
We cannot support all third-party ports of our library here.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group