Showing pdf file in dhtmlxTabbar - pdf

How to load a pdf file for viewing in a dhtmlxTabbar? I tried attachObject, but it doesn’t work

You need attachURL method:
tabbar.tabs("t1").attachURL("../__docs/LR1160_US.pdf");

Related

Uploading pdf file with cypress

I need to create automatic test that as part of the flow i need to upload pdf file in my main application.
But i didnt find a way to do that...
Thanks in advance !
Uploading file works in Cypress when target "input" element is of "type="file"
cy.get("#myFile").selectFile("cypress/fixtures/dummy.pdf")
where ID of the input of type file= #myFile" and path of pdf file="cypress/fixtures/dummy.pdf"
Please refer to Cypress Docs: https://docs.cypress.io/api/commands/selectfile

How can i generate and download PDFs in Flask without saving them in my Webapp?

im trying to get a PDF with the ReportLab Module which works fine so far. My problem is that im saving the PDF with the .build()-method in my Webapps directory. What i want is that i can send the PDF for downloading without saving it before. That is somehow possible with the wkhtmltopdf module, but i dont want to use any other servers for this.
The process would be like: User presses a button 'download as pdf', a pdf is generated and instant returned as a download without saving it first.
Do you know if this is possible?
You want to create the PDF server side, return it to the client, without saving the PDF (for example, in S3)?
Yes, this is possible, you create the PDF in memory using
buffer = io.BytesIO()
myPDF = canvas.Canvas(buffer, pagesize=letter)
Then after creating your pdf you save it using
myPDF.save()
buffer.seek(0)
Then when you are ready to return the PDF as a reponse you can return it with:
response = HttpResponse(buffer, content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="{}"'.format("myFile.pdf")
return response

Access MHT File from Solution Directory in Windows 8.1 App

I have an MHT (Microsoft web archive) file that I have added to my project folder. I need this file to display in a WebView on a help page. I have set the file's build action to "Content," like this question reccomended. I then use this code in the page's Loaded event handler.
Try
Dim strHelpNavigate = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.ToString(), "\MyAppsHelp.mht")
webHelp.Navigate(New Uri(strHelpNavigate))
Catch ex As Exception
webHelp.NavigateToString("<html><head><style>body {font-family: segoe ui; color: white; background-color: black;}</style></head><body><h2>Sorry, the help page is currently unavailable.</h2></body></html>")
End Try
This code produces an exception: {"Invalid URI: The format of the URI could not be determined."}
I have also tried passing "\MyAppsHelp.mht" to the Navigate method like this question reccomended, but this produces the same exception, and I see from the Local window that the string passed to the Navigate method is the same either way.
Does anyone have any advice on how to display this file in the WebView?
WebView does not natively support HTML archive files, but you can do the work convert these files to html + images if you're so inclined.
Open the .mht file in notepad, and you'll see that there are separate sections for each part of the HTML file - you can parse these sections to get the HTML out, then the base64 encoded images, then save them in your local app folder and use WebView.NavigateToLocalStreamUri to load them. See http://blogs.msdn.com/b/wsdevsol/archive/2014/06/20/a-primer-on-webview-navigatetolocalstreamuri.aspx for details on how to use this method.
OF course, if it's a static file that you will be using all of the time, it would be far easier to just convert it before packaging the app.

Detecting corrupted jpg files before or during upload

I have an ASP application that uses ASPImage.Image to resize the uploaded image and then save the file to the server and save it in the database. However, it appears that if a user uploads a corrupted file the resulting image is blank white image.
I need a way to check if the file is corrupted before the image is passed to ASPImage.Image, that will then inform the user that the file is corrupted.
Can this be done with javascript, vbscript or ASPImage.Image itself?
Any assistance would be greatly appreciated.
Best Regards,
Paul Jacobs
There is no way to detect a corrupt image in either javascript or vbscript - you will need to try using ASPImage.Image directly.
It has an Error property, this will probably have an error detailing that a corrupt file has been loaded - did you try that? That is, if it is populated, chances are that the file was corrupt.
Additionally, the LoadImage method returns a boolean - I assume it will return false if the image couldn't be loaded due to corruption.
You can use the code here: http://forums.aspfree.com/code-bank-54/pure-asp-upload-script-with-additional-features-94647.html
Then check the image Width and Height - if 0 it means the uploaded file was not a valid image.
This is pure classic ASP code without third party components.

view .doc, .docx, .rtf, .ppt file in iphone using Webview

I want to view .doc, .docx, .rtf, .ppt file in iphone.
But I guess something is going wrong at my side and its not working for the above formats but my code is working fine for .txt and .pdf files.
I have the read the document regarding Webview it states it supports viewing of the above document.
below is my snippet for .doc
[webView loadData:requestData MIMEType:#"application/msword" textEncodingName:#"UTF-8" baseURL:nil];
for .ppt I am using MIME type as "application/vnd.ms-powerpoint"
Note: If I am making MIME type as "text/html" for .doc/.rtf then it displays some garbage data So I think there is something missing in MIME type from my side.
Any help is highly appreciated.
Waiting for your reply.
Update:........
It seems there is some issue with NSData for opening these type of file formats.
My data is encrypted so I cannot use
requestWithURL directly and other thing is I need to pass credentials to get the file and the credentials doesnt work proplerly if I save the credentials using
[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential
forProtectionSpace:protectionSpace];
and then make the request using below
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] ]
Is there any way I can use NSData for the above formats so that I can make async call and pass my credentials and then decrypt the data and show it in WebView.
Try using a QuickLook Framework which is an amazing feature given by Apple. If you have seen this that when you select ANY FILE on MAC System and click SPACE BAR then you will a quick preview of your file it may be any thing... *.pdf, *.doc, *.docx or any thing... Even if you have not installed those softwares for same files you will get a PREVIEW for those files...
QuickLook framework also gives same functionality... Please go through some of the links for the same..
http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html
https://github.com/rob-brown/Demos
https://github.com/rob-brown/RBFilePreviewer
http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html
(Recommended..) http://iosdevelopertips.com/data-file-management/preview-documents-with-qlpreviewcontroller.html
Not all of those formats (docx) are supported. This looks like the official word. In the example Apple does not specify a mime type.
This question suggests that you must use an NSURLRequest instead of loadData.
Edit:
As far as I have seen, you cannot directly pass data to loadData for these types.
The easy work around is to write to a temporary file. You can delete it in webViewDidFinishLoad or, technically, as soon as the the file has been opened.
The hard work around is to use NSURLCache. You should be able to implement a custom NSURLCache and have WebKit use it via setSharedURLCache. Your cache would basically know how to get your local encrypted files and pretend that they are cached. I have not tried this, but I think it is your best bet. This approach may be blocked just like loadData is.
You need to supply something to baseURL:. For example:
[webView loadData:requestData MIMEType:#"application/msword" textEncodingName:#"UTF-8" baseURL:[NSURL URLWithString:#"http://localhost/"]];
Works for me now.
Try it on an iPhone instead of Simulator