# view a PDF from database

**URL:** <https://forum.xojo.com/t/view-a-pdf-from-database/31912>\
**Category:** Web\
**Created:** [June 11, 2016, 12:45pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912 "2016-06-11T12:45:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helge\_Tjelta](https://forum.xojo.com/user_avatar/forum.xojo.com/helge_tjelta/32/193_2.png) [@Helge\_Tjelta](https://forum.xojo.com/u/Helge_Tjelta)\
**Post date:** [June 11, 2016, 12:45pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/1 "2016-06-11T12:45:53Z")

</div>

Hi, I have a PDF stored in my DB (valentina), I can get the file and download it, and send it as an emailattachment… but how can I view it.

Using htmlviewer.url gives me a lot of can find file errors and stuff…

so is there another way to get the PDF on screen… the file is stored in a BLOB field, and the test PDF is uploaded into the blob using valentina studio, and can be downloaded as a PDF so file is ok into base.

I also tried to make a new PDF, import the PDF from db into this new PDF and show that one in the htmlviewer but still no go.

---

<div class="post-metadata">

**Author:** ![Helge\_Tjelta](https://forum.xojo.com/user_avatar/forum.xojo.com/helge_tjelta/32/193_2.png) [@Helge\_Tjelta](https://forum.xojo.com/u/Helge_Tjelta)\
**Post date:** [June 11, 2016, 12:54pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/2 "2016-06-11T12:54:17Z")

</div>

I only get a lot of:

404: File Not Found

The requested URL “/39412B6FD785D1E414E33B972F96328222CCAACE/files/1179-0156-1173-4985-9854/test.pdf” could not be found. Please check your request and try again.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [June 11, 2016, 1:50pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/3 "2016-06-11T13:50:45Z")

</div>

With MBS DynaPDF?  
Or at least running on Mac to use PDFKit?

I think we have a web app example for showing PDF.

---

<div class="post-metadata">

**Author:** ![Helge\_Tjelta](https://forum.xojo.com/user_avatar/forum.xojo.com/helge_tjelta/32/193_2.png) [@Helge\_Tjelta](https://forum.xojo.com/u/Helge_Tjelta)\
**Post date:** [June 11, 2016, 2:15pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/4 "2016-06-11T14:15:26Z")

</div>

I have MBSdynaPDf  
But all examples shows from a file and not from DB ?

---

<div class="post-metadata">

**Author:** ![Helge\_Tjelta](https://forum.xojo.com/user_avatar/forum.xojo.com/helge_tjelta/32/193_2.png) [@Helge\_Tjelta](https://forum.xojo.com/u/Helge_Tjelta)\
**Post date:** [June 11, 2016, 2:16pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/5 "2016-06-11T14:16:01Z")

</div>

I was looking into rendertopicture, but then I need to upgrade my dynaPDF to pro license ?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [June 11, 2016, 4:02pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/6 "2016-06-11T16:02:29Z")

</div>

Yes, pro license.  
And open import buffer function reads from string or memoryblock

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [June 11, 2016, 4:07pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/7 "2016-06-11T16:07:47Z")

</div>

The error “404: File not found” could be an indication that the file (test.pdf in this case) was deleted before the browser was able to download it.  
Please, make your file a property of your window and not a property of a method.

---

<div class="post-metadata">

**Author:** ![Helge\_Tjelta](https://forum.xojo.com/user_avatar/forum.xojo.com/helge_tjelta/32/193_2.png) [@Helge\_Tjelta](https://forum.xojo.com/u/Helge_Tjelta)\
**Post date:** [June 11, 2016, 5:03pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/8 "2016-06-11T17:03:05Z")

</div>

Hi Maurizio, I don’t want to download it. I just want my app to get it from my DB (it is stored in a blob field), and show it on screen.  
And since htmlviewer can show it when it is a file I would like to know if it can be done without having to downloading it.

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [June 13, 2016, 7:42am UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/9 "2016-06-13T07:42:20Z")

</div>

Hi Helge,  
to display the pdf file in a browser page, the browser itself must download the pdf file.

The problem you have is, possibly, that the value you set in “htmlviewer.url” is referring to a webfile that gets destroyed too early so the browser is unable to download the pdf to display.

Please, define your webfile not as a property of a method but as a property, for example, of a page.  
Doing so your webfile stay alive, the browser will be able to download it without the error “404: File not found”  
Remember also to set the “MIMEType” property of the webfile to the string value “application/pdf”.

Regards.

---

<div class="post-metadata">

**Author:** ![Helge\_Tjelta](https://forum.xojo.com/user_avatar/forum.xojo.com/helge_tjelta/32/193_2.png) [@Helge\_Tjelta](https://forum.xojo.com/u/Helge_Tjelta)\
**Post date:** [June 13, 2016, 1:07pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/10 "2016-06-13T13:07:00Z")

</div>

Hi Maurizio, you we totally right. I had to move my property to the web-page. Now I could do it… but I also had to make a new PDF and import that PDF into a new created PDF, and then send that to html viewer. I just did not managed to go directly from DB to html viewer.

But thanks!

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [June 13, 2016, 2:11pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/11 "2016-06-13T14:11:47Z")

</div>

Hi Helge,  
thank you for reporting that the problem is solved.

I don’t think that you need to duplicate or recreate a second pdf just to show it.  
Starting from the original pdf you can simply copy it’s content in the data property of the webfile.

Take a look at the [WebFile.Data](http://documentation.xojo.com/index.php/WebFile.Data) property.

Best regards.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:21pm UTC](https://forum.xojo.com/t/view-a-pdf-from-database/31912/12 "2020-10-29T18:21:23Z")

</div>


