I have a string that is a base64 encoded bitmap that I captured from a signature pad and stored in a custom table in the Acumatica database. I have a DAC for the table and I'm able to access it from the report designer.
The issue I'm having is how to get this base64 encoded image on to the report in Acumatica. There is a PictureBox control that would appear to be what I want except it doesn't seem to handle the encoded image data, only links to the database, an embeded file or URL.
I tried:
Setting the Source to "Database", the Mime Type to image/bmp and the
value to the base64 encoded string field. This produced an error that the base64 wasn't a valid link. I expected that because it's not a link to a file stored in the database.
Setting the source to "External" and the value to the base64 also produced a similar error
Is there any way to handle this in Acumatica's report designer?
Because this is a hosted environemnt, I can't host a temp file so the best solution would be one that allowed the encoded bitmap from the database to be used inside the report somehow. However, any solution that gets the job done is welcome other than a local temp file as that's been ruled out.
You need to save base64 string as file attachment in Acumatica. You could use Encoding.ASCII.GetBytes(<Base64String>) to convert base64 string to byte[] and utilize UploadFileMaintenance Graph to save the image as file attachment.
//Graph for file management
UploadFileMaintenance upload = PXGraph.CreateInstance<UploadFileMaintenance>();
//Set filename
string fileName = string.Format(<FileName>, <FileExt>);
//Convert Base64 String to byte[]
byte[] data = System.Text.Encoding.ASCII.GetBytes(<Base64String>);
//Create file info, you may check different overloads as per your need
FileInfo file = new FileInfo(fileName, null, data);
upload.SaveFile(file, FileExistsAction.CreateVersion);
//To Attach file to Entity
PXNoteAttribute.SetFileNotes(<PXCache>, <EntityData>, file.UID.Value);
You could refer this KB for full file attachment Example. Once you have file as an attachment you should be able to use it in report by referring logo display in out-of-box Sales Order report (SO641010).
Related
I have a JSON document having some properties including attachment(abc.txt).
How to save attachments in couchbase using Node.JS?
Take a look at the Couchbase Node.JS SDK
You have two choices in how to store the attachment:
Inline with the document. If the attachment is small and/or easily embedded into JSON (the attachment is valid JSON itself) then you can simply add a element to your JSON document containing the attachment body, for example:
{attachment_name: "abc.txt",
attachment_body: "The quick brown fox jumps over the lazy dog\n"
...
}
As a separate document, referenced from the first. If the document is large / you don't want to serialize it inline, then create a field which just refers to the key of the actual attachment:
{attachment_name: "abc.txt",
attachment_ref: "attachment::document1_attachment1"
...
}
Then you'd have a second document named attachment::document1_attachment which was the actual attachment document.
I'm trying to save a XML file in DocumentDb in Json format. I have no problem in converting it and saving. All the conversion and saving are working fine.
However when I store my Xml file the DocumentDB provides its own file name to the file. Eg; 8756b9b9-41ac-47ca-9f4c-abec60b318be.
But I want to save the file with my own custom name Eg; MyXmlFile1 or MyXmlFile2 etc;
How do I pass my custom name when saving the file? That is MyXmlFile1 or MyXmlFile2.
"jsontoStore" has the content of the file I want to store into DocumentDB.
Code1: Storing without passing any file name.
await client.CreateDocumentAsync(documentCollection.SelfLink, jsontoStore);
Code2: Storing with custom file name but here I'm not able to pass my content that is "jsontostore"
document = await client.CreateDocumentAsync(documentCollection.SelfLink,
new Document
{
Id = "sample1"
});
I believe you are referring to the id of a document, since you mentioned the auto-generated GUID.
All documents must have an unique value in the id property (it is the primary key for the document). If an id is not provided at the time of document creation, DocumentDB will generate one for you.
The solution here is to simply set the id field with the name of your choice (e.g. MyXmlFile1, MyXmlFile2) after you convert your XML to JSON.
I'm using Javascript API for Office to get ooxml of parts of the document using Binding.getDataAsync. The result is that I have ooxml text which represent part of the document:
Now what I want is to alter this XML for example to put a table around the contents or to show a comment then save it back using Binding.getDataAsync.
How can I use OpenOffice SDK to parse this xml to a document or a document part and do this processing?
I tried to use all the following:
var doc = new DocumentFormat.OpenXml.Wordprocessing.Document(ooxmlText);
//var part = new DocumentFormat.OpenXml.Wordprocessing.DocPart(ooxmlText);
//var parts = new DocumentFormat.OpenXml.Wordprocessing.DocParts(ooxmlText);
But I get back an error each time saying:
The XML has invalid content and cannot be constructed as an element.
I want to attach a file to an existing PDF document using iTextSharp and I can able to do it using pdfStamper.AddFileAttachment(...) method. Now I want to make the attachment hidden/secure in a way that no one able to see the attachment and even not able to retrieve it directly from PDF. It should only be retrieved from code.
I wouldn't store anything that has to be hidden in a File Attachment. That's a public, well-known mechanism that is understood and supported by multiple pieces of software (through UI).
If it has to be hidden and secure, I would protect the file by encrypting it in some way and then store all of it in a private CosStream somewhere in the document. The best way to do this would likely be the "Page-Piece Dictionaries" which provide a way to store product private data inside a PDF file. Private data can be attached to forms, pages or the document as a whole.
In my version of the PDF specification, this is paragraph 14.5, Page-Piece Dictionaries.
To include the concern of the OP and mkl's subsequent comment, there is no set expectation that Page-Piece data is encoded in any set way. The Page-Piece Dictionary contains a "Private" key that can have anything as value (so the value can be a string for smaller data, could be a dictionary containing multiple pieces of private information, or could be a stream that is compressed to keep it small).
From the PDF specification: "Private (key) : (Optional) Any private data appropriate to the conforming product, typically in the form of a dictionary". Remark the "typically" in the description. Further explanation in the PDF specification clarifies that the type of data stored may be anything you want.
On SalesForce ,
I've got a word document as an attachment of a custom object, i can get it as blob by selecting the body of the attachment with a SOQL query :
Attachment att = [ SELECT Body FROM Attachment WHERE PARENTID = '**' and ContentType='application/msword'] ;
Blob b = att.body ;
I tried to use the b.toString() function to have the content, but it didn't work.So is there any other way to convert the blob into a string that represent the text written in my word document.
thanks
Document bodies are saved as Blobs and are base64Encoded. Please use the EncodingUtil class and bas64Encode/base64Decode methods to achieve the desired results.
Documentation: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_encodingUtil.htm
What exactly are you trying to achieve with this?
If you are trying to display the doc. content and let the user edit/save it. This is not possible unless ActiveX controls are used which is another different level.
Please post the code if any coding help is required!
The b.toString() method should return a string of the blob. But keep in mind that it isn't translating the proprietary format of the word document into plain text. It's still going to be a string with some ugliness because it represents the word document format and not the text you would see when viewing from word.