Page 1 of 1

PDFDocumentService > Element image > file attribute

Posted: Tue Dec 13, 2022 6:54 pm
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

Re: PDFDocumentService > Element image > file attribute

Posted: Wed Dec 14, 2022 1:20 am
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.

Re: PDFDocumentService > Element image > file attribute

Posted: Wed Dec 14, 2022 12:14 pm
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

Re: PDFDocumentService > Element image > file attribute

Posted: Thu Dec 15, 2022 1:03 am
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