I’m creating an app that will generate a balance statement that includes an image on the PDF. I use the IText7 on the following sample: https://dev.to/davidelegbede/create-pdf-in-net-core-using-itext7-3k2i
Here is where I have the problem, finding that path where the Android package stores the image created with build actions “MauiAsset”, “MauiImage” and “Resource”.
public class PDFHeaderEventHandler : IEventHandler
{
public void HandleEvent(Event currentEvent)
{
try
{
PdfDocumentEvent docEvent = (PdfDocumentEvent)currentEvent;
string logoPath = "Assets/logo.png"; **Here is the path i need to know**
var logo = ImageDataFactory.Create(logoPath);
PdfPage page = docEvent.GetPage();
The location returns I/O Exception “File not found”, I tried using FileSystem.AppDataDirectory without luck.
System.IO.Path.Combine(FileSystem.AppDataDirectory, “images/logo.png”); System.IO.Path.Combine(FileSystem.AppDataDirectory, “assets/logo.png”);
System.IO.Path.Combine(FileSystem.AppDataDirectory, “/images/logo.png”); System.IO.Path.Combine(FileSystem.AppDataDirectory, “/assets/logo.png”);