using Paroxe.PdfRenderer;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PdfManager : BaseFilePrefabItem
{
    private PDFViewer pdfview;

    public override void Init(FileConfig fileConfig)
    {
        base.Init(fileConfig);
        if (!string.IsNullOrEmpty(fileConfig.Url))
        {
            string url = fileConfig.Url;
            if (!fileConfig.Url.Contains("http"))
            {
                url = "https://" + fileConfig.Url;
            }
            showPDF(url);
        }
    }

    public void showPDF(string url)
    {
        //this.transform.localPosition = new Vector3(0,0,0.69f);
        pdfview = this.GetComponent<PDFViewer>();
        pdfview.FileURL = url;
        pdfview.LoadDocument();
    }

    public override void OnScaleStopped()
    {
        if (transform.localScale.x < 0.0001f)
        {
            transform.localScale = new Vector3(0.0001f, 0.0001f, 0.0001f);
        }
    }
}