I have a submit only XPage based form that has an inputRichText field for storing screenshots and a multi file upload (using the XPages Multiple File Uploader from OpenNTF) for uploading one or more attachments. When submitted I need both the screenshots and the attachments to appear in a single rich text field which will be accessed via the Notes Client only (non XPages).
Currently the form stores the attachments and screenshots in separate fields. I have tried appending one field to the other on save (using SSJS in the submit button, however because the Screenshots are stored as MIME and the attachments as NotesRichText, it is not letting me do it.
Is there some way (preferably in SSJS) that I can convert either the MIME to RichText or vice versa so that I can append one field to the other? I have tried searching for various solutions to no avail, as well as trying different file upload controls from OpenNTF.
Ideally I need something like this to work:
var rtItemAttachments:NotesRichTextItem = docTo_Backend.getFirstItem("attachments"); //This is the field I want everything in
var rtItemFiles:NotesRichTextItem = docTo_Backend.getFirstItem("uploadedFiles");
rtItemAttachments.appendRTItem(rtItemFiles); //Fails on this line
docTo_Backend.removeItem("uploadedFiles");
Speak after me: there is no RichText in the web, all there is is MIME.
You can set the RT field to store its content in MIME (a property). This makes things much easier.
To stitch things together you need to stick with MIME. These are roughly the steps
Get the text and images as MIME
Get your attachments as stream (the embeddedObjects has a method for that)
Convert the stream to BASE64 and create a new mime-part with it. (Looking at an attachment eMail source someone sent through the internet should give you a pretty good idea how it looks like)
You end up with:
MimeHeader
MimePart for Text (HTML)
MimePart for Screenshots (if they are not inline images in html)
MimeParts for attachments
The special effect: if you add to the HTML with links to the attachments, it looks nicer.
Of course the BIG question: WHY?
You could simply design a Notes form that has two fields, no need to fold it into one. Hope that helps.
A good piece of code to look at to understand the MIME stuff is the OpenNTF eMail bean
Related
I have a download control bound to a rich text field. My users are finding that some documents cause errors. Right now, I have an XPage that has little more than the rich text field on it. For example, when I attach a certain .docx file to a document using the Notes client, then try to download the attachment via the Web using the download control on an xpage, I get a runtime error stating that there is an invalid date. I actually get the error just by trying to open the XPage, before I even get a chance to click on the link within the download control. But neither the xpage nor the attachment have any date field on them. Other attachments don't cause the error, even other .docx documents. And if I convert the .docx to .doc, the problem goes away. But I can't tell my users to never attach .docx documents. Does anyone have any idea why some .docx (not all, though) documents attached to a Notes document would cause such a runtime error in XPages?
So, here's the thing, we have a bunch of pdf forms for users on our website to fill out, we have a submission button inside every pdf form that sends the filled data through a http post method. We are already doing a pre-filled form, where the user fill general information on a html form, data that are used to generate a partially filled multiple pdf files, so whatever the pdf form the user has selected to fill, all of them will be regenerated having the pre-filled information that he just typed on the html form. I accomplish this by using pdftk (http://www.pdflabs.com/docs/pdftk-man-page/) that enables me to just do that. But we get to a point that to make this more efficient, the user must be able to draw their signature on the html side at the pre filled form stage, so we are using signature-pad for this (http://thomasjbradley.ca/lab/signature-pad/), than we create an image from the canvas that the plugin generates. But as each pdf has its own position for the signature, we must insert a placeholder into the pdf that'll be replaced for the signature image. So I came up with the idea to create a disabled text field on the pdf with the name of "signature", so through a nodejs application with the pdf2json module (https://github.com/modesty/pdf2json) I can parse the pdf form and get the position (x,y,w,h) of that particular field, being able to attach an image over the text field placeholder. So the problem is that pdftk don't give me support to attach an image to an existing pdf or even attach it in a certain position, I tried to find a nodejs module that would enables me to do that, but the only worthing nodejs module that I found was pdfkit (http://pdfkit.org/) but it only works creating a new pdf, not editing an exiting one, I looked into pdfkit source code and I discarded it because I realize that it wont work to my case of an existing pdf. So I came to a long way, got to the final stage of this implementation, came to the last step to get this working, and I'm just stack.
This is the output that I have from the pdf2json module for nodejs that is helping with the placeholder approach.
{
page: 7,
index: 317,
name: 'signature',
type: 'alpha',
x: 43.806640625,
y: 14.64195833333333,
w: 30.546828125000005,
h: 1.9339166666666756
}
If someone know any server application that I could run through an unix command at my server to attach an image over an existing pdf document, it'll fit my needs, don't need to be an exclusively nodejs module.
Obs.: I already checked it out the adobe echosign product, but it doesn't fit our needs, it's not free and don't solve our problem of attaching a signature to multiple pdf files from a single html form.
I realize that I could use the nodejs module pdfkit to generate a new blank PDF with the signature in the right position and just over the two pdfs, having the blank pdf with the signature image on the top like a stamp. I could do this with pdftk by command line:
pdftk form.pdf stamp signature.pdf output form-signed.pdf
There's another free application tool like pdftk that I just found out, and it's pdfjam. Also, if you can't use nodejs module pdfkit (different from the application pdfkt) to generate a new pdf with an image to the right spot, you have the stampTK tool (http://www.pdflabs.com/tools/stamptk-the-pdf-stamp-maker/) where you can parse through command line the image to be a stamp in an existing pdf, but this tool is paid (not much, and its worth it), but as I have the pdfkit module for nodejs that enables me to do just that along side the pdfkt application for free, I'm using that, and I also have more control of multiple signatures on the pdfkit module for nodejs. Hope this answer helps someone.
I've created a html formatted email containing a table and want attachments to appear in rows in the table. I can't manage to get the attachments to appear in the body of the email at all, instead they come through (in our Lotus Notes 8.5.3 client) as attachments all grouped in the header under the attachment twistie.
Is there any way for the attachments to display in the body of the email instead of the header?
(Updated Jan 20, 2014)
For reference, I looked for sample methods for adding attachments. Mark Leusink here and Tony McGuckin here posted great snippets for building HTML/MIME emails, so I used these as a starting point, but couldn't find anything to get the attachment into the body. Stephan has clarified why that is in his response below.
Mime doesn't contain attachments in message bodies, so they won't show up. However with a little trickery you can get what you want:
add another attachment containing an icon to be shown for the attachment. One generic or one each
in your table construct a href followed by img src pointing to image and attachment
you can read more about the URL format here
http://en.m.wikipedia.org/wiki/MIME
Bonus track: there is a notes item to stop attachments to be shown (can recall which one) If you smuggle that in as header...
Stephan has already pointed you in the right direction, but I'll just add a bit more detail in case others stumble upon this question.
You need to create a multipart MIME structure -- specifically multipart/related -- containing an HTML part (Content-Type: text/html) and one or more attachment parts. Each attachment part should have a Content-ID header with a unique identifier.
Your HTML part will usually have at least one anchor element corresponding to each of the attachment parts. The href attribute can refer to the attachment by Content-ID. Here's an example:
someFile.ext
It's important the substring after "cid:" is an exact match of the Content-ID header of the corresponding attachment part. That's how the anchor and the attachment part are tied together.
As Stephan said, http://en.wikipedia.org/wiki/MIME is a good reference. However, the MHTML page (http://en.wikipedia.org/wiki/Mhtml) might be a better starting point. MHTML is a subset of MIME that focuses on multipart/related and HTML.
I want a file download on my page where I look up the attachemnts to be displayed from another document based on the value of a field.
I tried a couple of things including returning the value obtained from NotesRichTextItem.GetEmbeddedObject but everyting I try I get the error java.util.Vector incompatible with [Lcom.ibm.xsp.model.FileRowData
What do I need to call to return a proper value to my file download control?
I realize I could proably display the attachment links using a repeat control but was hoping there was an easier way.
The FileDownload control requires a NotesDocumentDataSource. There's no way around that. So you could add a panel to you page, add a Notes Document DataSource to that panel that computes the UNID of that document, add a file download control bound to that panel and you are good to go. The FileDownload control will show all files in that document.
Keep in mind: an XPage is not bound to a (one) document and can contain as many data sources as needed.
If you want to construct the URLs yourself, check the cheatsheet
I am working on a Data extract from a Lotus Notes Application. It stores legal documents which may have attachments and images (not mails). I want to convert notes documents to HTML. While importing the data using java API I am able to extract Text, Attachments etc but when it comes to images I am not able to extract them. I did some research and found about two approaches
1) To extract the document using generateXML() method. But the generated document contains a picture tag which has a referenece of location on Notes Domino server. But I want the image so that it can be included in the HTML document.
2) By extractinh as MIME Entity. When I try to get images using getMIMEEntity("Body") or any other field I do not get any image and It always return null.
There is question (Extract inline images from Lotus Notes using Lotus Notes Java API) which deals with this but It does not answers conclusively and its dormant for a long time.
Please help, I am working on it for a couple of days still I cannot import images. Thanks in advance.
In Lotusscript you can first Extract file to your local system/ Server and than export in excel by using that code below.
' Loop through all attachment/document (By creating attachment object)and save Image to some path on server/local 'system(strSaveasPath)
Call object.ExtractFile( strSaveAsPath)
' Now Activate excel row:column range where you wnat to insert image
xlApp.Range("1:1").Activate
xlApp.ActiveSheet.Pictures.Insert(strSaveAsPath)