Image from File to PDF

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Image from File to PDF

hannan
Greetings, I have art competition contestants fill out an entry form and upload a photo of their work to a folder on the file server.  I have lasso adjust the file name on the fly (to include the title of the work, the year, a random number, and .jpg).  Upload works fine.  But when I want to display the work on a PDF page (I generate .pdfs for judges and award certificates), if an entry doesn’t have a photo file (which is not required), lasso shoots an error:  PDF_Doc:(Add) Error adding Image1.  The code worked fine last year (running Lasso 7.x).  In the meantime I’ve upgraded to Lasso 8.x, and again, if the entry has an associated photo, the .pdf is correctly drawn.

The code I use to call the photo—I do it in two steps:

[var:'Image1'=(field:'Title') + ($VAYear) + (field:'EntryID') + '.jpg']

[var:'Image2'=(PDF_Image: -file='///library/Webserver/Documents/DefaultSite/MSHSLVisualArtsCompetition/VACompEntryPhotos/' + $Image1, -height=150.0, -width=150.0)]

And to display the image on the .pdf:

[$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]

I’ve tried using a simple conditional for the line:

[if:($Image2) == '']

[var:'Image2'='No Photo']
[$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]

[else]

[$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]

[/if]

but it hasn’t worked.

I’d appreciate any help.

Duane Hannan
WWG Schools
 
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Image from File to PDF

Tim Taplin
can you tell if your conditional is succeeding? or is it failing to match '' and then failing to add because the value of Image2 is not a valid image?

I havent worked with pdf_image much, but I'd think you could inspect image2 to determine if you got a valid image or not rather than asking if its an empty string. If there is no file present, what does image2 contain?

At a different level or perspective, I would be inclined to think that you would have the image name stored somewhere, so you could simply check to see if an image was provided before you start trying to build a pdf_image from something which may or may not exist.


On Apr 28, 2014, at 10:31 AM, Duane Hannan <[hidden email]> wrote:

> Greetings, I have art competition contestants fill out an entry form and upload a photo of their work to a folder on the file server.  I have lasso adjust the file name on the fly (to include the title of the work, the year, a random number, and .jpg).  Upload works fine.  But when I want to display the work on a PDF page (I generate .pdfs for judges and award certificates), if an entry doesn’t have a photo file (which is not required), lasso shoots an error:  PDF_Doc:(Add) Error adding Image1.  The code worked fine last year (running Lasso 7.x).  In the meantime I’ve upgraded to Lasso 8.x, and again, if the entry has an associated photo, the .pdf is correctly drawn.
>
> The code I use to call the photo—I do it in two steps:
>
> [var:'Image1'=(field:'Title') + ($VAYear) + (field:'EntryID') + '.jpg']
>
> [var:'Image2'=(PDF_Image: -file='///library/Webserver/Documents/DefaultSite/MSHSLVisualArtsCompetition/VACompEntryPhotos/' + $Image1, -height=150.0, -width=150.0)]
>
> And to display the image on the .pdf:
>
> [$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>
> I’ve tried using a simple conditional for the line:
>
> [if:($Image2) == '']
>
> [var:'Image2'='No Photo']
> [$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>
> [else]
>
> [$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>
> [/if]
>
> but it hasn’t worked.
>
> I’d appreciate any help.
>
> Duane Hannan
> WWG Schools
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Image from File to PDF

stevepiercy
In reply to this post by hannan
The error is not consistent with your code below.  You have an
->add method for $Image2 but none for $Image1.

$Image1 is merely a string that represents the filepath to the image.

$Image2 is a pdf_image object, and it should error out if the
image does not exist on the file system.

A couple of tips:

* When debugging, site Lasso error reporting to Full in the SiteAdmin.
* Use a conditional to test for the existence of the image on
the filesystem:

     if(file_exists('image1'));
         // do stuff
     else;
         // do something else
     /if;

* You need to set file permissions to read files from the root
of the server (that's what "///" means).  See my file
permissions guide for how to do that.
http://www.stevepiercy.com/lasso_stuff/file_perms.lasso

--steve


On 4/28/14 at 11:31 AM, [hidden email] (Duane Hannan) pronounced:

>Greetings, I have art competition contestants fill out an entry
>form and upload a photo of their work to a folder on the file
>server.  I have lasso adjust the file name on the fly (to
>include the title of the work, the year, a random number, and
>.jpg).  Upload works fine.  But when I want to display the work
>on a PDF page (I generate .pdfs for judges and award
>certificates), if an entry doesn’t have a photo file (which
>is not required), lasso shoots an error:  PDF_Doc:(Add) Error
>adding Image1.  The code worked fine last year (running Lasso
>7.x).  In the meantime I’ve upgraded to Lasso 8.x, and again,
>if the entry has an associated photo, the .pdf is correctly drawn.
>
>The code I use to call the photo—I do it in two steps:
>
>[var:'Image1'=(field:'Title') + ($VAYear) + (field:'EntryID') + '.jpg']
>
>[var:'Image2'=(PDF_Image: -file='///library/Webserver/Documents/DefaultSite/MSHSLVisualArtsCompetition/
>VACompEntryPhotos/' + $Image1, -height=150.0, -width=150.0)]
>
>And to display the image on the .pdf:
>
>[$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>
>I’ve tried using a simple conditional for the line:
>
>[if:($Image2) == '']
>
>[var:'Image2'='No Photo']
>[$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>
>[else]
>
>[$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>
>[/if]
>
>but it hasn’t worked.
>
>I’d appreciate any help.
>
>Duane Hannan
>WWG Schools
>
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Image from File to PDF

hannan
Thanks Steve and thanks Tim.  The error code # is 1.  The error is “PDF_Doc(Add:) Error Adding Image.”  Sorry.

I wasn’t aware of the [file_exists] tag.

I created another variable, Image1a, that didn’t have the “PDF_Image” tag, used  file_exists tag, and a conditional, and it worked!

Thanks again.

Duane Hannan
WWG Schools
 
On Apr 28, 2014, at 1:48 PM, Steve Piercy - Web Site Builder <[hidden email]> wrote:

> The error is not consistent with your code below.  You have an ->add method for $Image2 but none for $Image1.
>
> $Image1 is merely a string that represents the filepath to the image.
>
> $Image2 is a pdf_image object, and it should error out if the image does not exist on the file system.
>
> A couple of tips:
>
> * When debugging, site Lasso error reporting to Full in the SiteAdmin.
> * Use a conditional to test for the existence of the image on the filesystem:
>
>    if(file_exists('image1'));
>        // do stuff
>    else;
>        // do something else
>    /if;
>
> * You need to set file permissions to read files from the root of the server (that's what "///" means).  See my file permissions guide for how to do that.
> http://www.stevepiercy.com/lasso_stuff/file_perms.lasso
>
> --steve
>
>
> On 4/28/14 at 11:31 AM, [hidden email] (Duane Hannan) pronounced:
>
>> Greetings, I have art competition contestants fill out an entry form and upload a photo of their work to a folder on the file server.  I have lasso adjust the file name on the fly (to include the title of the work, the year, a random number, and .jpg).  Upload works fine.  But when I want to display the work on a PDF page (I generate .pdfs for judges and award certificates), if an entry doesn’t have a photo file (which is not required), lasso shoots an error:  PDF_Doc:(Add) Error adding Image1.  The code worked fine last year (running Lasso 7.x).  In the meantime I’ve upgraded to Lasso 8.x, and again, if the entry has an associated photo, the .pdf is correctly drawn.
>>
>> The code I use to call the photo—I do it in two steps:
>>
>> [var:'Image1'=(field:'Title') + ($VAYear) + (field:'EntryID') + '.jpg']
>>
>> [var:'Image2'=(PDF_Image: -file='///library/Webserver/Documents/DefaultSite/MSHSLVisualArtsCompetition/
>> VACompEntryPhotos/' + $Image1, -height=150.0, -width=150.0)]
>>
>> And to display the image on the .pdf:
>>
>> [$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>>
>> I’ve tried using a simple conditional for the line:
>>
>> [if:($Image2) == '']
>>
>> [var:'Image2'='No Photo']
>> [$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>>
>> [else]
>>
>> [$Scoring Forms->(Add:$Image2, -Left=36.0, -Top=312.0)]
>>
>> [/if]
>>
>> but it hasn’t worked.
>>
>> I’d appreciate any help.
>>
>> Duane Hannan
>> WWG Schools
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                  <http://www.StevePiercy.com/>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>