Hi
I'm trying TMSFNCWXPDFViewer inside a webcore app consuming an xdata API implementation to retrieve PDF in base64
Value is well retrieve and content is checked from a memo with Base64 to PDF | Base64 Decode | Base64 Converter | Base64
Base64 string content a well formated PDF
But when I'm trying to load base64 inside TMSFNCWXPDFViewer with LoadFromBase64 I get an error
Is the PDF prefix (data:application/pdf;base64,) part of your base64 string? If yes, then you'll need to remove that first and only pass the raw base64 data to the component.
The decoded text won't contain the prefix, this prefix is part of the base64 string. Does the base64 represented PDF you get through XData start with data:application/pdf;base64,?
In other words, what does your sBase64_render variable look like?
string PDFbase64 is collected and sent directly to LoadFromBase64
Same string copy paste and decoded by https://www.base64decode.org/ is displayed perfectly
That indeed seems to be the correct representation that should be passed to the TTMSFNCWXPDFViewer. If you take a look at the WEB Core demo of the TTMSFNCPDFViewer, you'll see it shows a base64 represented PDF when the application starts.
Can you save your XData response to a text file and attach it here so we can investigate what goes wrong with the loading of your specific PDF?
In the example you sent, there are multiple \r\n instances in your base64. Is this something added when you were saving the JSON to a file or was it part of it before? If it is part of it then most likely that is the problem because the string will be cut off at the newlines leaving you with an incomplete base64 string.
Other than that, we've seen when you add a TMS FNC WX component to your web form, an extra empty script tag is added to your project.html.
It was part of base64 data provided by service (carbone.io)
It's well decoded by all tests I did but it seems pdf.js b64 decoder doesn't work fine with it.
Thanks for tips about empty script line in project. It solves the other ticket
Depending on how you extract the PDFbase64 from the incoming JSON, it's possible the \r and \n values are replaced by CR and LF. When a string that contains CR/LF is being sent to the embedded browser that hosts the PDF viewer the string is cut off at the first newline instance.
This is a possible explaination as why it was not working for you in VCL but was fine when saving to a file and loading it back. When it's being loaded form a file, the component handles the base64 conversion, and it won't have any CR/LF.