PDFDocumentService > Element image > file attribute

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
faridah.belandres
Posts: 11
Joined: Wed Jul 13, 2016 1:57 pm

PDFDocumentService > Element image > file attribute

Post by faridah.belandres »

Hi,

Good day! I would like to ask if there is a way to use an absolute URL for the <image> file attribute?

Ex. in the template xml file:

Code: Select all

<image x1="{W_TEXTX1}" y1="{W_LINE1}"  file="https://images.pexels.com/photos/614484/pexels-photo-614484.jpeg?auto=compress&amp;cs=tinysrgb&amp;w=1260&amp;h=750&amp;dpr=1"  width="200" height="65" />    
I tried to hard-code the absolute url of an image in the xml template but in the log trace, it seems to append the value of file attribute to the jsm instance folder. [attached a screenshot]

Thank you in advance,
Faridah
Attachments
log trace for image file.PNG
log trace for image file.PNG (13.3 KiB) Viewed 5521 times
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: PDFDocumentService > Element image > file attribute

Post by Dino »

Hi,

From this previous post:
viewtopic.php?f=3&t=2643&p=7887&hilit=q ... vice#p7887

I think the answer will work here as well like this.

Code: Select all

Define_Com Class(#XPRIM_HttpRequest) Name(#Request) Scope(*Application)
#VF_ELTXTX := 'https://images.pexels.com/photos/614484/pexels-photo-614484.jpeg?auto=compress&amp;cs=tinysrgb&amp;w=1260&amp;h=750&amp;dpr=1'
#Request.DoPost Url(#VF_ELTXTX)
* The response is an image file, lets move it to a file
#STD_BLOB := #Request.Response.AsFile
#STD_STRNG := #STD_BLOB.FileName
then use #STD_STRNG for the image in your xml document and it will be pointing to the image in a temporary folder.
faridah.belandres
Posts: 11
Joined: Wed Jul 13, 2016 1:57 pm

Re: PDFDocumentService > Element image > file attribute

Post by faridah.belandres »

Hi Dino,

Thank you for your response.
I have tried the solution you mentioned.
The weird thing is, when I use the #request.DoPost in a test form, I get a value for the filename.
But when I add the same code to the actual function or reusable part, I am getting a blank value for the filename.
Could there be an authority issue in Integrator with regards to the domain being used in the URL I pass to #rerquest.DoPost?


Thank you and regards,
Faridah
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: PDFDocumentService > Element image > file attribute

Post by Dino »

notice that the full validation of the execution of that have more possibilities, maybe you are having an error:

Code: Select all

Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
Define_Com Class(#XPRIM_ErrorInfo) Name(#ErrorInfo)
Define_Com Class(#XPRIM_HttpRequest) Name(#Request) Scope(*APPLICATION)

#Request.DoGet Url('http://xyz/a/aaaaaa')

* Check if the server returned a response
If (#Request.Response.IsSuccessfulRequest)
If (#Request.Response.IsSuccessHttpStatusCode)
#Reader.SetSourceHttpResponse HttpResponse(#Request.Response) ErrorInfo(#ErrorInfo)
(... your logic here....)
Else
Message Msgtxt(#Request.Response.ErrorCode.AsNativeString + ' / ' + #Request.Response.ErrorMessage.AsNativeString)
Endif
Else
Message Msgtxt(#Request.Response.ErrorCode.AsNativeString + ' / ' + #Request.Response.ErrorMessage.AsNativeString)
Endif
Endroutine
End_Com
Post Reply