Show pdf, tif or jpg in a block of a form

I have made a form with several blocks and fields inside. The fields are “the metadata” of an image (PDF,TIF or JPG)

I one of the blocks of the same form I want to present a pdf, tif or jpg
The name of the pdf (or tif or jpg) is one of the fields in the record of the mysql database connected.

What is the best way to go?
Better not with master/detail and a second form inside because of the spaces around the detailform in the masterform.

I tried with a labelfield and inside the textfield of the labelfield the html-tag:
<iframe src = “/docs/document.pdf” width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>
This works fine, but how to make the “document.pdf” as a variabele.

I tried with:
<iframe src = “/docs/”<?php echo $variablename; ?>" " width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>

I donot know this is the right way.

But how to get the $variablename in this textfield of the labelfield. With java script?
Who can help?

Regards Bert

1 Like

are you using an echo in your code? (simple example)
OnRecord
$variablename=‘12345.jpg’;
echo “<iframe src = ‘/docs/’”.$variablename." width=‘800’ height=‘540’ align=‘left’ allowfullscreen webkitallowfullscreen></iframe>";
Basically you have to echo the name of your picture.

If it is a pdf you have to take case that not all browsers wil display pdf so then youneed to use pdf.js
Check here: https://blog.oio.de/2014/04/11/integrating-pdf-js-pdf-viewer-web-application/

Hallo rr,

Unfortunatly there is no “OnRecord” as an event in the Form (Yes in a grid, but this is a Form). bUt besides of that:
In this form there are 3 blocks. See the attached image.
In one of these blocks (i called the block image) I put an extra field (not a database field, but made with new)
I made the field as a labelfield.
In the text I put:

<iframe src = “…/docs/doc2.pdf” width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>

(no echo in front of it. this is html enviroment).

Works fine…see exampleform01.png attached.

The only thing left is to make doc2.pdf as an variabele.
I replaced the text with:

<iframe src = “…/docs/”<?php echo $docx; ?>" " width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>

So I have to have $docx with the right value from a field in the mysql database. The field is called doc_bestandsnaam and is represented in the examplescreen on the bottom.

Hope you understand…

Regards Bert

exampleform01.png

labelfield01.png

I havent tried it but this function is what you would use normally…
http://www.w3schools.com/php/func_filesystem_fpassthru.asp

Ok rr and others. I want to share the solution I found:

I made a form with several blocks. I use mysql as database, but others will do also.
One of the fields I named “image”.

I filled the records of this field with:
<iframe src = “…/docs/doc1.pdf” width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>
<iframe src = “…/docs/doc2.pdf” width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>
<iframe src = “…/docs/doc3.pdf” width=‘800’ height=‘540’ align=“left” allowfullscreen webkitallowfullscreen></iframe>
etc…

The variable is “doc1.pdf”, “doc2.pdf” etc… and I build this string in the field image with a concate in a small php script with the field in which the name of the document is.
In this case doc1.pdf etc…

Smart guys could also make the width and height as a variable to play with it, but for me its ok.

Now I go back to scriptcase.
Made the field “image” a label field and placed it in the block where the PDF (or TIF or PNG) should appear. (show)

That’s it…

And because every browser shows a pdf, tif or jpg, you do not have to build in a viewer or what…

Great system this scriptcase…

Regards Bert

example.png

Hi,
Apologize for my English.
Great help, thanks.
But I can understand the way you use to access the relative path for your PDF files.

p.e. : "…/docs/doc2.pdf

Can replicate, I use “standard” file/doc path in application settings but seems I’m the bug. :wink:
Is this method already active ?

Thanks in advance
Regards
Herve