How to streamline an SSRS web service call? - pdf

Using a 3rd party application (Tenfold) I currently call the SSRS web service methods to render a report as .pdf.
After I receive the encoded blob (5th parameter in the Render Method) I write the blob to the file system as a pdf using an internal WriteBinaryFile call, but in this form I cannot open it in a pdf reader. To solve this problem we write a .txt file with the path and file name of the pdf. Then send that to an external program Base64Decoder.exe which converts the file to a user friendly form that I can then open and view properly.
The Base64Decoder.exe is not 100% reliable and I'm looking for a better way to solve this problem. From what I've read from others the web service should return the blob in binary form which I then should be able to open without any conversion. Thanks in advance for any light that you can shed on this issue for me.

the render method returns a byte array, which is what you want to save to disk
there's an example here:
http://technet.microsoft.com/en-us/library/aa258532(v=sql.80).aspx

Related

How do I reference a hosted docx rather sending every time when creating a pdf (document generation api)

I have asked this question on https://community.adobe.com/ and have not received an answer. If I do, I will include the response here.
I am able to create a pdf using the basic approach outlined by adobe at https://developer.adobe.com/document-services/docs/overview/document-generation-api/
Ideally, I don't want to have to send the base docx word document across in the api call each time I generate a new pdf. I would rather host the docx which can be retrieved at document generation time. One approach would be a reference url to a docx hosted on acrobat.adobe.com. At the moment I have to send the docx as well as the json data which seems inefficient.
I am using https://cpf-ue1.adobe.io/ops/:create
"cpf:inputs":{
"documentIn":{
"dc:format":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"cpf:location":"InputFile0"
},
I guess if it can't be done, then that's okay, I just would like to know so I can implement accordingly.
thank you

How can I get the number of pages in a PDF file inside a Google Apps Script?

The PDF files are in my Google Drive. I just got that I can get the number of pages of a PDF sending it as a job to Cloud Print, because Cloud Print will return a JSON object with "numberOfPages" attribute.
Is there any faster and easier way? Thanks in advance.
Well, I actually did like I said.
I take my file, then send it to CloudPrint via its JSON Api. I need to send it to a dummy printer, a printer I registered in CloudPrint but actually is never connected to Internet. Then, I get the number of pages of the PDF file in the value of response's "numberOfPages" attribute. Save this number in some var. Finally, I send a delete petition to JSON Api for my file in the dummy printer, indeed isn't necessary at all.
Thanks!

Getting file from .ashx with a jQuery Post

This question is a following from another question I asked - Passing client data to server to create Excel or CSV File.
I have a client page which builds a JSON object to send to the server, and I have server code which can parse that JSON object into an SQL command and end up with a dataset of required data.
I had originally been passing the JSON object to an .asmx web service which would return a JSON object containing my data. Now I want to go in a different direction and have the data returned as a .csv file.
I understand I can try to put my JSON object into a query string and call my .ashx page, but the JSON object could get large, so I'm trying to use the Request.Form of a POST.
My question, and lack of understanding, is in how to use jQuery to post to the .ashx page and have it return the .csv file to the client. If I navigate to the .ashx page directly (and modify the page to hard code the passed data), I get the .csv file returned to me no problem (i.e I get the prompt to open/save the file). If I make a POST to the .ashx file from jQuery and send my JSON object through, I get a response which contains the data in a string, rather than getting a .csv.
So, is there something I am missing, or am I just trying to achieve something that I can't or shouldn't be doing?
I'd thought about passing my JSON object to a .asmx web service which would store the JSON object into a database and return an ID, and then use window.location to browse to the .ashx with the ID as a query string parameter to then generate the .csv file, but I thought there might be a way to avoid that middle step and do it with the POST.
Sorry if this is a little rambling and disjointed. I'll be happy to clarify on any parts that may not make sense to anyone.
I am trying to do something similar as we speak.
Take a look at this question. It might help you.
How to: jQuery post to ashx file to force download of result?

Retrieving dynamic text from a website in vb.net (VS2008)

I want to be able to retrieve dynamic data from a web page (share prices). I started out by retrieving the html code before I realised that as it is live data, the html code will be of little use. Although I am looking to capture specific data, all i wish to do is process a webpage that I specify which will return the text off that website and not the HTML code. Basically a copy and paste of the entire page would be great..
Any ideas would be really appreciated!
'Screen Scraping' by parsing HTML is so early 2000s...what I would do is read up on Amazon's Mechnical Turk. You can develop a queued architecture where you submit urls to this Mechnical Turk service. The service would automatically distribute these bits of work to users who would then do the dirty task of copying and pasting out the valuable stock quote information you require. Users around the world would anxiously await delivery of the next URL to their Mechanical Turk inbox...pinning for the opportunity to copy/paste out another share price for your application. Sure, it might take a few minutes to update your prices, but hey, they would be HAND parsed by REAL people around the globe! Just think of the possibilities!
Well, the HTML contains the text of the website, so you "just" need to parse the HTML.
EDIT: If the data is not in the HTML but loaded dynamically, the situation is different. As I can see, you have two options:
Find out how the data is loaded (i.e. read the JavaScript on the page). If it is updated via some web service, you could query the same web service in your program.
Use a web browser to get the data and then get the dynamic HTML tree of the page. Maybe the WPF Webbrowser control can help you with this, but I'm not sure since I've never done this myself.
Is it possible to find this same data provided in a ready-to-consume format rather than scraping HTML for it? It seems like there's probably public web-services for stock quotes.
For example: A quick search for "Stock price webservice" turned up http://www.webservicex.net/stockquote.asmx; an ASMX web-service that is easy to consume in .NET.
In your Visual Studio project you should be add a reference to this service via the "Add Web Reference" command; the dialog you're given varies depending on whether your project is targeting for .NET 2.0 or .NET 3.0/3.5.
I added a reference to the service named StockPriceProxy:
Public Function GetQuote(ByVal symbol As String) As String
Using quoteService As New StockPriceProxy.StockQuote
return quoteService.GetQuote(symbol)
End Using
End Function

How to get a pdf to display in a web browser before it's fully downloaded

I have a client that's been struggling with slow loading pdf files on the web.
My client has some very large pdf files that are almost 10 Mb. They take upwards of 3-4 minutes to download. The files will not display until the whole file is loaded.
We and they have seen other's sites where the pdfs load one page at a time, so the end user can start looking at the file as the rest of the page is still loading in the background. Gives the illusion that the page has loaded faster.
According to the documentation they see, IIS 6 should automatically do this if the pdf file is created with “Optimized for fast web view” checked. It is checked, and the file will still not load a page at a time.
They have searched and found nothing other than IIS will do this automatically if the file is saved correctly.
How can they "stream" the pdf? Is this because the pdf's were saved in a special way? Is this a java script that handles the download? Or is there a change that needs to happen in IIS?
Thanks
Update:
The file starts out like this:
%PDF-1.4
%âãÏÓ
171 0 obj << 0/Linearized 1
Linearized?
The PDF document isn't being served up from an aspx/asp page. (It's just posted directly to the site and linked to).
You need to lineraize the PDF and not trust IIS to do this for you.
There are a number of apps that will do this for you. I have used CVision (thier compression is 2nd to none, but the licensing and SDK are a pain), there is also some cheaper alternatives here, but I dont know how well they work.
To clarify Tony's point... (I think)
If you have actually used these tools and your pdf is linearized, try converting the PDF to a byte array and Response.Write() the byte array (with content headers, etc) to the client (in a new browser window or frame)
Would it be possible to use a third party service, like Scribd? If you go this route you can embed their streaming viewer onto your client's website. Just a thought, although I know it's not really suitable for every type of business.
This might happen if you are serving the PDF from an aspx page, to get the byte-serving that linearized pdf's need the page needs to be served directly or you need to provide the byte serving from the aspx code.
Save one of the files and open it up in a text editor. If you don't see something like
<< /Linearized 1.0 /L <number> /H [<number> <number>] /O <number> /E <number> ...
in the first couple hundred bytes or so, then you're not getting a linearized (ie, fast web) PDF.
First, the document needs to be "linearized", as others have explained; you can linearize it in Acrobat or using pdfopt from Ghostscript. Second, the web server must be able to serve byte ranges (i.e., support the Range header); I have no idea how to configure IIS for this, but even if the document is linearized, the client has to be able to read particular byte ranges.