Automatically Printing Page, then directing to next page - asp.net-mvc

I am updating an old application, and have been asked to change the old Print routine (which just invoked the print command via javascript, and printed out the html), to one that prints out a pdf (the theory being that we then have more control of the pdf / how it looks etc across all printers.)
Using the Rotativa library, I can generate my pdf's, either on the fly or to a file.
After doing some reading, it appears impossible to stream a pdf from memory, and it has to be created as a file first, sent to the browser, and then deleted.)
the last line of my controller is;
return File(#"D:\Development\Source\Workspaces\ConsumerCreditLicenseSystem\Code\ConsumerCreditSystem\CCLSystem\_Idd\1.pdf", "application/pdf");
What I am strugglign with is getting that page to invoke the Print Dialog. If I send it to a new view with javascript to do this, then I am back to square one as the page is html not my pdf. Is there any way I can mark that my pdf is for printing, or combine it with some html so I can have the old faithful of
window.print();
in the document?

A PDF is not a webpage; it's a binary. When you send the PDF as a response to the user, you have no control over what happens on their end. If their browser is capable of viewing a PDF in place, it will display it; otherwise, it will prompt the user to download it. Either way, it will be up to the user whether they want to print it or not, and it will also be up to them to go back or whatever. You cannot redirect the user automatically at this point.
A slightly better option would be to redirect the user to another page, with a link to a view that will send the PDF down to them. Then, you can do things like force the PDF to download (so it's not rendered inside the same tab/window, effectively taking the user away from your site), or force the link to open in a new tab or window. However, you still will not be able to prompt the user to print.

Related

Using script or Automator to set page settings, margins and page wrap automatically on Text Edit files

I'm putting together an installation using Processing, where users type and their text is printed on a receipt printer.
I've got Processing saving out time-stamped text files to a folder, and a folder action in Automator watching that folder and sending to print.
My problem is that these .txt files need some intervention...
Format > Wrap to page
Change margins
Select 80mm receipt roll in Page Setup
I think I have the margins thing figured out by adding some code to the file header on the Processing side. With the rest, I'm drawing a complete blank.
I've tried setting the receipt roll as the default page size in 'Print and scan' in system prefs, but the receipt page size doesn't show in the list in system prefs, only shows on the page size list from within Text Edit application.
I suppose what I'm asking - is there a way of setting TextEdit's default to page wrap, certain page size, certain printer - then a folder action can just print away (I hope).
The idea is that these text files spit out of the receipt printer automatically with no intervention. Does anyone have any ideas? Thanks in advance.
Have you experimented with the settings available for TextEdit in AppleScript? If you look under the print settings section (in TextEdit's Script dictionary), there are a number of options available, which may help you achieve something pretty close to what you want. You could then drop the AppleScript into a Run AppleScript action in your Automator folder action.
Alternatively, you could go completely nuts and design a template in Pages that meets your criteria, and then extract your text, paste into your Pages template, and print that out. A whole lot more work, but once it became functional, you would only need to change the Pages template in the future to meet changing needs.

How to expand or embed the contents of a URL in Microsoft Word?

I need to create a Word document that includes information I also have on a web page. Ideally, I want to prevent duplicating the information, so would like to put the URL of the web page, and have Word "expand" the URL into the actual text from the web page.
If the Word file is opened offline, then the reader sees the contents of the web page as they were when the word file was created.
IF the Word file is opened online, than attempt to update the contents with those that are on the web page.
Sure its possible, but I think you'd need to write and install a VSTO AddIn (or possibly a macro) to do it.

What is the best way to manipulate an existing PDF-Document under iOS?

I need to individualize documents within an iOS-App. I could provide the origin-documents as DOCX, PDF, PPT etc. The output-format has to be PDF.
My minimun requirement is to fill some text-fields. Nice to have would be to replace an image, too.
I´m quite used to generate PDFs programmatically using UIGraphicsBeginPDFContextToFile etc. But in my current case I don´t want to create the whole document programmatically, I just want to replace some content.
Any hints / tipps?
Thank you in advance.
DOCX is a zip - format file so you can process the contents programmatically and the reconstruct the zip file. PPT is a binary format though newer versions of PowerPoint might also construct zip-oriented versions that you can programmatically process. You mentioned though that you need don't want to programmatically process these documents - which I would probably also do only as a last resort.
For your DOCX origin/source documents (or doc,odt,rtf but not ppt/pdf) you could use Docmosis cloud services if your app can have the external dependency. You would upload your DOCX origin documents with placeholders for text-fields or images as a one-off/occasional task. Your iOS app then calls Docmosis sending instructions and data to create the output PDF and either stream it back to the app or email/store it or both.
The upside is it takes all the load and coding away from the iOS application (there is an SDK). The downside is it is an external depdendency. Please note I work for the company the created Docmosis.
Hope that helps.
Why not just load a page in a webView modal that points to a URL of a page you create? The main parts of the page would be static, and then the fields you need to customize would be populated via Javascript or PHP.
For example, we have a contact form in our app that gives you an option to view the details of your completed form after you submit. When the user clicks on the button to view the Contact Confirmation, it loads example.com/confirmation.php in a modal view within the iOS App.
On the confirmation.php page (on the web), I use PHP to pull in $_GET variables from the URL parameters which then populates the page with my static content, and their customized information that they entered into the form.

Safari URL to PDF-page workaround?

I'm trying to link from an URL to a specific page within a PDF document being viewed using the Preview.app built in Safari (using iOS on iPad2).
I know that Sarafi does not support (hopefully in the near future) the PDF parameters like for example:
www.mywebsite.com/information.pdf#page17
or
www.mywebsite.com/information.pdf#page=17
Which should result in the PDF being viewed on page 17 when opened.
But as we know Safari opens it at the first page instead.
However!
When I am displaying the PDF in Safari and I change the pagenumber (in the URL bar) into a different pagenumber, IT WORKS.
It jumps to the correct page, and I'm changing it again and again and it works flawlessly.
So I figured, alright maybe it's because the PDF needs to be loaded the first time viewing, so I preloaded the PDF in cache, but no succes.
How can I get it to work, so that it goes to the correct page when opening the PDF?
Is there a script for changing the page number after loading or is there a different solution?
You can find the PDF I'm talking about here:
http://www.michaelmaasdam.nl/mobile/new/pagina/begroting/begroting2012.pdf?page=14
Is this link being shown from a native app?
If so, you could opt to use QuickLook instead and you may have a little more control over this kind of thing from within that.

How do I ensure that an Infopath form remains linked to the original form template (MOSS 2007)?

I have an infopath form template at
https://mysite/Shared%20Documents/MyForm.xsn
If you click on the xsn file in your browser and hit "open" it opens up the template and allows you to fill it in and then hit a submit button which saves an xml file to
https://mysite/administrator/In%20Process/filledOutForm.xml
Then if an admin comes into sharepoint and clicks the filled out infopath form, it opens up fine.
However if the user first saves https://mysite/Shared%20Documents/MyForm.xsn locally, then the link to the form template appears to be stripped (i think because the actual form template is actually local now, rather then being viewed from the sharepoint). thats fine and dandy, they can still submit the form, and it gets saved to https://mysite/administrator/In%20Process/filledOutForm.xml but now its missing the href link to the form template. now when an admin tries to open the filled out form, they get an error saying infopath cant find the form template.
I can follow the instructions listed here:
http://blogs.msdn.com/b/infopath/archive/2006/11/01/relinking-forms-and-form-templates.aspx
to "relink" the form to the form template, and that fixes the issue, but I want to fix the underlying issue. How do i make it so that users either cant save it locally (breaking the href to the form template) or make it so that the link to the form template stays there, even if they save the form locally?
Sadly it is more due to training and configuration. We end up "fixing" this all the time (funny it is the same users that seem to have the problem). Some helpful ideas.
Remind your users that the XSN is a template and the XML is their data. They should never really need to save the template. A good analogy is Word dotx and docx - you open the dotx (template) but when you save it defaults to docx (data) - InfoPath does the same thing.
Usually when you "open" an XSN it opens in data mode. When a user clicks save the default is to save as XML. They have to "design" or "open in design mode" (or switch to design mode once open) to actually modify the XSN itself. Remind the users that when they go to save - if it is trying to save as XSN something is wrong and to back up a step.
We also tried to protect the XSN either by security or location so that the common users don't have rights to write/overwrite it - they can only save XML. That way even if they do mess up the system will block the save. Of course that doesn't keep them from local copies.
Just be open minded about it - there will always be cases where you have to go back and relink the template. The more you can reduce the better but they still happen ("but I wanted to keep the template locally so I didn't have to keep going to the website").

Resources