使用 migradoc 或 pdfsharp 使用 xamarin forms 放置来自相机的图像

Put an image from camera with migradoc or pdfsharp with xamarin forms

我有一个问题,我无法将相机中的图像转换为 pdf。它放了同样的错误"Image could not read"。我该怎么做? 这是拍照时他们给我的路径=

"/storage/emulated/0/Android/data/com.companyname.atecresacalculator/files/Pictures/fotoparapdf_12.jpg"

来自 CompartirInformacion(SharedInformation) 的代码:

namespace AtecresaCalculator.Service
{
    public class CompartirInformacion
    {
        public static string x;
        public static string y;
    }   
}

我在 pdf 中添加的地方:

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;

点击拍照:

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;
}

目前你不能用这个包做你想做的事。如果你需要这样做,你应该尝试使用 Syncfusion pdf 包,缺点是它是付费的,但你可以免费创建一个社区帐户