How to serve a PDF file via a HTTP request - http

I'm working with some new SCADA software, which uses a browser environment to display everything. One component that the software has is a PDF viewer, however, since we're in a browser environment, it can only load files that are served up over HTTP. According to the forums, this means that the source of the PDF needs to be a URL.
The forum also notes that I can use one of their modules (WebDev) to "stream the PDF bytes over HTTP", and provides directions for how to do so. However, the WebDev module is outside the budget of my project (it's quite a high-powered module, I'd be paying a premium price and then using 1% of its functionality). So I'm wondering if it's possible to serve up a PDF via HTTP some other way.
I'm not an experienced programmer - I'm self taught out of necessity on a small handful of languages, and to a basic level only. As such, I don't fully understand the problem, nor do I know what search terms to use to find the sort of information I need to solve it.
If anyone's able to provide a partial solution, or even just able to help me understand what I'm asking for and where to go looking for some answers, I'd appreciate it!
The PC hosting the PDF files and the SCADA gateway is running Windows 10.

I had the same issue integrating .pdf report to our SCADA system having web interface and running node.js at backend.
The main point is:
Generate your pdf in client end (web interface)
Convert it to Base64 format as URi
Preview on DOM or send it to server!
Send excel and pdf to server side
hope that helps!

Related

Accessing a console application from web page

I've recently created two C# console applications. The first transforms a bunch of command outputs into an XML, and the second transforms the XML into a Word document using a template.
I'd like to know how I could get this onto the web, i.e having a web page where the command output can be uploaded, the two step conversion executed, and finally the Word document made available for download.
Should the web page be created in ASP.NET or are there other (better) options? Do I need to rewrite the console applications in some other format?
This question is fairly broad, with plenty of room for novel sized explanations, but here's a brief highlevel walk through of what likely needs to happen to achieve the proposed results (language agnostic):
Get a hosting provider that allows users to spin up their own machine (i.e. AWS).
Spin up a machine that is compatible with the "console" programs in question.
Install "console" programs on machine.
Install a programming language (i.e. Node.js, PHP, ASP.NET, even C# could do) on the machine.
Install a web server (i.e. NGINX, Apache) on machine, configure it to serve public requests and run with chosen language.
On server request, execute appropriate commands from within the chosen language. Languages typically come with a exec method (i.e. in node.js: require('child_process').exec(command,options,callback))
Get the results of said commands and send it back to the client. Alternatively (for downloads), write the result to a path on the system that is publicly available to the internet and redirect the user to that url (additional configuration might be required to make sure the browser downloads the file as oppose to just serving it).
The steps above should get you pretty close to that you want. As for your questions:
Should the web page be created in ASP.NET or are there other (better)
options?
The "better" options is whatever you feel most comfortable with at the moment, you could always change it later with reasonable effort (assuming that your "console" apps are not unsuspecting unicorns).
Do I need to rewrite the console applications in some other format?
No, unless you have strong reasons to do so (i.e. multi environment compatibility). You could also rewrite to significantly simplify (i.e. bypass working with a CLI and do everything in C#).
Try thinking through these high level steps, begin working on a implementation, and post more specific questions here on StackOverflow when you get stuck.
I hope that helps!

How to Open a Browser and connect to a website then parse that website using jsoup in java?

I have a project which needs a little bit of web-scraping. The main requirement is to let the user enter his data on a java application. Then the application will connect to a data entry website then it will automatically inputs the data entered by the user to that website. I haven't started to code it since I don't know where to start. I already conducted some research about this and it points me to jsoup and desktop api(jsoup for webscraping and desktop api for opening a browser). Hope to receive a reply from the Java experts here.
Thanks!
JSoup will certainly do the scraping for you. However you need to handle HTTP (GETs/POSTs etc.) and for that I would recommend Apache Http Components.
I'm not sure you want to open a browser. Rather I would expect you to ask the user for input (perhaps via a Swing UI, or a browser-based UI) and then talk directly to the website using HTTP. I don't think you'd need to open a browser to the destination website. If you do, then check out Watij, which allows you to drive a browser directly from Java.

Build an Offline website - Burn it on a CD

I need to build a website that can be downloaded to a CD.
I'd like to use some CMS (wordpress,Kentico, MojoPortal) to setup my site, and then download it to a cd.
There are many program that know how to download a website to a local drive, but how to make the search work is beyond my understanding.
Any idea???
The project is supposed to be an index of Local community services, for communities without proper internet connection.
If you need to make something that can be viewed from a CD, the best approach is to use only HTML.
WordPress, for example, needs Apache and MySQL to run. And although somebody can "install" the website on his own computer if you supply the content via a CD, most of your users will not be knowledgeable enough to do this task.
Assuming you are just after the content of the site .. in general you should be able to find a tool to "crawl" or mirror most sites and create an offline version that can be burned on a CD (for example, using wget).
This will not produce offline versions of application functionality like search or login, so you would need to design your site with those limitations in mind.
For example:
Make sure your site can be fully navigated without JavaScript (most "crawl" tools will discover pages by following links in the html and will have limited or no JavaScript support).
Include some pages which are directory listings of resources on the site (rather than relying on a search).
Possibly implement your search using a client-side technology like JavaScript that would work offline as well.
Use relative html links for images/javascript, and between pages. The tool you use to create the offline version of the site should ideally be able to rewrite/correct internal links for the site, but it would be best to minimise any need to do so.
Another approach you could consider is distributing using a clientside wiki format, such as TiddlyWiki.
Blurb from the TiddlyWiki site:
TiddlyWiki allows anyone to create personal SelfContained hypertext
documents that can be published to a WebServer, sent by email,
stored in a DropBox or kept on a USB thumb drive to make a WikiOnAStick.
I think you need to clarify what you would like be downloaded to the CD. As Stennie said, you could download the content and anything else you would need to create the site either with a "crawler" or TiddlyWiki, but otherwise I think what you're wanting to develop is actually an application, in which case you would need to do more development than what standard CMS packages would provide. I'm not happy to, but would suggest you look into something like the SalesForce platform. Its a cloud based platform that may facilitate what you're really working towards.
You could create the working CMS on a small web/db server image using VirtualBox and put the virtual disk in a downloadable place. The end user would need the VirtualBox client (free!) and the downloaded virtual disk, but you could configure it to run with minimal effort for the creation, deployment and running phases.

Any tool for WebDAV load testing?

I want to generate WebDAV traffic (to reproduce a bug in an open source server).
I know WebDAV is a layer over HTTP so I could generate such traffic by reading the protocol specification and sending tens of hand-crafted HTTP requests, but I don't want to re-invent the wheel, I guess someone has already written such a tool?
Ideally the tool would:
Log in at a URL
Randomly navigate directories
Download/upload files from time to time.
Bonus if it is free/open source.
This discussion suggests JMeter does not have this feature.
I found a tool called "Prestan" on Sourceforge. It's based on this paper by Teng Xu
There was no such tool, so I wrote one.
Mecadaver logs in at a WebDAV URL, and starts navigating directories at random, sometimes downloading documents, sometimes going back to the root.
Runs as as many users as you want (you provide a list of usernames/passwords in a CSV file)
Various parameters to make the load more intensive or less intensive.
Open source
Note: Silk Performer can do WebDAV test loads as well, but it is very expensive.

Best Upload for web application FTP or HTTP?

We have a web application where the users from whole world would upload there file at a same time. We want an effecient, robust upload system. Max file size would be 50 MB.
There would be atleast 1lac users uploading at same time.
Please suggest which is the better upload system, FTP or HTTP?
Currently we have http based upload where in we do get some errors like connection problem, session time out, time out error, etc...
Even suggest me for any 3rd party ftp upload tools if you come accross.
I will suggest you yo go with HTTP, because it is much favorable in terms of user convenience.
If you are having critical issues with Large file upload then Please have a look at Darren johnstone's Large File upload library for ASP.Net.
Still If you have to go with FTP then I will suggest you to go with using some Client Side reach technology which runs under browser like FLASH, JAVA Applets ( or might be SilverLight )
Depends on what you're doing.
every user I ever met knew how to use a browser, but the standard random user doesn't even have an FTP client installed. So usually HTTP uploads aren't really problematic. I wouldn't wanna upload huge files, but 50megs isn't that bad yet. If you want an FTP upload you probably would go for a java applet, so your users are guaranteed to have even the software needed to upload their files. Any PHP/WebFTP things will just run you into the same problems again.
Sometimes if I don't know if things I want to do work well, its a good time to look at how others are doing it. Gmail for example has a fabulous upload system. imageshack, millions and millions of users are uploading their stuff their, basically thats all the page does, and all of them use "normal" HTTP, with a little bit of JavaScript sugar to display the progress.
edit: here is an example with PHP: (although u seem to be using asp, it might still help)
http://www.devpro.it/upload_progress/

Resources