I would like to create a PDF of a specific sheet (not necessarily the active one) and send it as an email attachment. I've borrowed and tried several code snippets, but none work correctly. I've searched and analyzed all the forums I can find, but I can't figure out the issue. I'm a novice programmer, so I like it simple. This snippet is intuitive to me, but it gives the following error: "We're sorry, no servers are currently available. Please wait a bit and try again." Debugger says that both pdf and attach are undefined.
var pdf = SpreadsheetApp.getActive().getAs('application/pdf').getBytes();
var attach = {fileName:'test.pdf',content:pdf, mimeType:'application/pdf'};
MailApp.sendEmail(recipients, subject, body, {attachments:[attach]});
Three things:
can you help me get the pdf/attachment function working properly?
can you help me modify it for a specific sheet (say, Sheet1)?
is it possible to make a pdf out a range on a sheet rather than the whole sheet?
Thanks!
You're trying to apply methods of one Class to another that does not implement it. (e.g. getAs() isn't a Spreadsheet method.) When you're writing your script, pay attention to the autocomplete feature, which would have helped to avoid this error. See this previous answer for more details about that.
Answers:
See Google Apps Script to Email Active Spreadsheet, which demonstrates how to generate a PDF from a sheet.
To isolate a single sheet, see ajb1970's answer to the same question. The idea here is to copy the sheet you're interested in into a new, temporary, spreadsheet - and then make your PDF from that.
To do this with a range, repeat step 2, but with the range you're interested in.
Use getBlob not getBytes. Also you cant specify a specific sheet. Instead copy that sheet into a new spreadsheet, convert that one to pdf and later delete it.
Related
To preface this I'm not an ExactTarget expert.... We use ExactTarget and are interested in more archiving our email newsletters so that our subscribers can later use our articles as a reference. We have an archive folder set up in the exact target system, but that is not customer-facing and contains things like extra code.
As I understand it, the current process for archiving involves taking screenshots of the email that is sent out which is stitched together as a PDF. The PDF's are then stuck behind a password protected folder on a website.
Obviously, this is a hacky/low-tech way to do this.
Are there any ways to export these mails for archival purposes that people are using?
I am guessing from the above that you are using the premade templates and creating content using the Exact Target WYSIWYG editor. From there I am assuming also that these articles are in content boxes and HOPEFULLY each 'article' is in a single content box.
If so, then your best bet is to go to the HTML tab on this box and copy that code there and have this inserted onto your company blog (or website if you do not have a blog). Your network admin or website designer will likely know the best way to insert these snippets of code to fit the layout and navigation of the site.
If your message is not personalized, or if so you mdke a generic recipient in your list, you may be able to use the 'view as webpage' link to get the source code. Not sure if those links expire after X days or something though.I have never tried this or tested, but on most email sends there is a "view as webpage" link, maybe try taking one of these links and either hosting on your blog/site or using that link as a reference for your customers.
Using a PDF or screen shots is far from optimal as the content becomes an image and loses a lot of value.
Hope this helps.
I am using openxml to generate my word file that contains user input messages and attachment if there are any. Now, I am stuck in a situation where I don't know how to display PDF /JPEG/JPG if user attached such things with the inputted message.
Is there any way I can show the above attached in my generated word file.
Thanks
MSDN has the specific example of adding the images to the document. The sample code you could use is provided here.
http://msdn.microsoft.com/en-us/library/bb497430%28v=office.14%29.aspx
I would like to edit an existing pdf document,most probably comes from the server. My requirement is to edit the pdf document. Here editing means i want to add some text at some particular place. Whenever user clicks on a document at some place where he wishes to enter the text, keyboard should appear and can able to write some text. In the same way, he should be able to delete some of the text which he doesn't want to use in the existing document. After all these manipulations he should be able to save the document. I have been trying with fastpdfkit framework, everything is possible but entering text and deleting is not working which is the main requirement for me. Anybody who had worked with this kind of requirement could probably help me.
you can try with fastpdfkit.
Download the sample code form github and make use of it.
Try following demo of Leaves framework
I have a requirement to create a PDF file from HTML. The resulting PDF needs to have iTextSharp TextField or something similar. I need to update the PDF document with appropriate text in the text field.
Points to note:
1. The PDF length (page numbers) may vary.
2. Due to this, I may have to only know the name of the field to set value to.
OR
I could create a PDF from HTML. As the content of the PDF may vary, I do not know the exact location of a block that I need to edit. I need to stamp text exactly over the block irrespective of the location of the block (i.e. the block may exist in any page).
Example Scenario:
Create a PDF from HTML.
It is sent for approval process. Once it is approved, the name of the approver is printed at a specific place (however the signature area, mentioned as block above, may come at any page, as it depends on the content of the HTML).
Two resources which may help you:
This article details how to use asp.net & itextsharp to create a pdf.
The whole article is pretty useful for a beginner like me, but the section detailing how to create a pdf from HTML may be useful for you as a start on your problem.
https://web.archive.org/web/20211020001758/https://www.4guysfromrolla.com/articles/030911-1.aspx
I would especially pay attention to how he replaces placeholders in the HTML template he is loading. As it seems you may want to head in that direction.
Now to answer your question more directly, have you thought about using a fillable form?
Here is a related Stack Overflow post.
Creating a fillable PDF form with ITextSharp
As I said I am a beginner, so I can't do much to help you from here. But with any luck you can put those together and accomplish what you are looking for.
Let me know if that helps Good luck!
I think this might be a simple question but I cannot seem to figure it out.
I have a workflow which simply sends a mail. In the content of the mail I
have a hyperlink going back to our SAP CRM system. I pass some parameters to this hyperlink.
The workflow works fine and the email is sent, however, the hyperlink goes onto the second line of the mail and becomes in active. If I copy the entire hyperlink and paste it in a browser it works.
The issue is I don't want users to copy and paste, I simply want them to click on the hyperlink.
Here is a screen print of what I am talking about
http://img402.imageshack.us/img402/9471/38348167.png
And here is a screen print of the actual email that is sent:
http://img210.imageshack.us/img210/6424/14370746.png
I tried going into transaction PFTC (Task Maintain) I entered my task and opened it up. I went to the tab description
and hit the edit button and I changed the tag column to continuous text but that didnt work, and then I tried extended line
and that too didn't make a difference.
Here is a screen shot of that:
http://img341.imageshack.us/img341/6254/37776438.png
My question is, is there any way to get the hyperlink on one line or even to have it be clickable on 2 lines?
Thanks so much.
From what I can see, that's a limitation of SAPconnect when sending plain-text emails. You could reconfigure the system to send HTML mails, but this would affect EVERY outgoing mail and should be handled extremely cautious. I'd suggest you write a small class to assemble and send the HTML mail and call it from the step. I'd use the BCS for sending the mail - it has an excellent online documentation and comes with several demo programs (BCS_EXAMPLE_*). You could assemble the HTML body using ABAP, although this usually yields rather messy code. Cleaner ways of ding this would be to either put all of the input data into a structure and use a simple transformation or dynamic documents (see for example report DD_ADD_LINK).