Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How embedded PDF in XML tag in ax 2012

(0) ShareShare
ReportReport
Posted on by 630

Hi Experts,

Using X++ code I have generated below XML file.

65143.Capture.PNG

In Data tag I have to embedded  PDF file.

Please tell me how to embedded PDF file between data tag.

Regards,

Rahul

  • ergun sahin Profile Picture
    8,816 Moderator on at
    RE: How embedded PDF in XML tag in ax 2012

    On the receiver side, they will reverse the same process and convert it back to pdf.

    container data = BinData::loadFromBase64(encoded);

    devblog.sertanyaman.com/.../

  • Suggested answer
    Martin Dráb Profile Picture
    231,837 Most Valuable Professional on at
    RE: How embedded PDF in XML tag in ax 2012

    Using a local file path obviously can't work from other machines. What you need to use is really the actual file content.

    The native X solution is using BinData class:

    BinData binData = new BinData();
    binData.loadFile(filePath);
    // Alternatively you could use a container with the data
    // binData.setData(data);
    str encoded = binData.base64Encode();

    If you had a reason to do it differently, you could also use .NET classes and methods, such as System.Convert::ToBase64String().

  • Rahul.p Profile Picture
    630 on at
    RE: How embedded PDF in XML tag in ax 2012

    Hi Martin,

    Thanks for your reply, can you please elaborate it like how to use Base64.

    By using below code i am getting .pdf file path.

    public XmlNode xmlContentNode(XmlDocument _doc)
    {
        XmlNode header;
        XmlNode senderNode;
        XmlNode node;
        xmlNode attr;
        DocuRef     addDocuRef;
    
    
    
        header = _doc.createElement2('Content', #Test);
    
        node = _doc.createElement2('Data', #Test);
        node.text(Class1::saveDocuTempFile(addDocuRef, true));
        header.appendChild(node);
    
    return header;

    Which is showing following:

    7802.Capture.PNG

    In my machine I have access but receiver don't have access to.

    Regards

    Rahul

  • Martin Dráb Profile Picture
    231,837 Most Valuable Professional on at
    RE: How embedded PDF in XML tag in ax 2012

    You can use Base64 encoding to convert the file content to text, which you can easily use as the value of the element.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,025 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans