reactJS从外部存储库打开一个.pdf文件

时间:2018-11-29 16:22:58

标签: reactjs pdf

我有一个S3实例托管在AWS上的reactJS应用程序。我还在不同的S3实例中在AWS上托管了一个网站。在该网站上,我托管了一堆.pdf文件。假设我有3个.pdf文件位于:

  

https://www.mywebsite.com/pdffiles/file001.pdf   https://www.mywebsite.com/pdffiles/file002.pdf   https://www.mywebsite.com/pdffiles/file003.pdf

我是否可以为我的reactJS应用程序用户提供一系列指向外部.pdf文件的链接?我尝试了以下代码:

renderDocuments = () => {  
    return (
        <div>
            <div className="documents_background">
                <div className="row">
                    <div className="col-12 text-left text_14">
                        <label>Below are the links to the participant forms we have available for download.&nbsp;&nbsp;The forms are
                        in .pdf format.&nbsp;&nbsp;You will need to have Adabe Acrobat Reader installed in order to view these files.</label>
                    </div>
                </div>
                <div className="row">
                    <div className="col-9 text-left text_14">
                        <label>Form 1</label>
                    </div>
                    <div className="col-2 text-right text_14">
                        <a href="https://www.mywebsite.com/pdffiles/file001.pdf" Target="_blank" >Download</a>
                    </div>
                    <div className="col-1">
                    </div>
                </div>
                <div className="row">
                    <div className="col-9 text-left text_14">
                        <label>Form 2</label>
                    </div>
                    <div className="col-2 text-right text_14">
                        <a href="https://www.mywebsite.com/pdffiles/file002.pdf" Target="_blank" >Download</a>
                    </div>
                    <div className="col-1">
                    </div>
                </div>
                <div className="row">
                    <div className="col-9 text-left text_14">
                        <label>Form 3</label>
                    </div>
                    <div className="col-2 text-right text_14">
                        <a href="https://www.mywebsite.com/pdffiles/file003.pdf" Target="_blank" >Download</a>
                    </div>
                    <div className="col-1">
                    </div>
                </div>
            </div>
        </div>
    )
}

当我单击表格1的超链接时,会在console.log中得到以下内容:

  

资源被解释为文档,但以MIME类型application / pdf传输:“ https://www.accurecord-direct.com/dotnet/PDFFILES/VSTA/vstm_enrollment_form.pdf

.pdf文件无法打开,应用程序只是在那儿等待。

谢谢。

0 个答案:

没有答案