I have one HTML page shows map which i want to display in BrowserField.
Here is my code.
BrowserFieldConfig _bfConfig = new BrowserFieldConfig();
_bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
_bfConfig.setProperty( BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE );
_bfConfig.setProperty(BrowserFieldConfig.USER_AGENT, "MyApplication 1.0");
BrowserFieldRequest request = new BrowserFieldRequest("page.html");
BrowserField myBrowserField = new BrowserField(_bfConfig);
add(myBrowserField);
myBrowserField.requestContent(request);
If the "page.html" is local file then,
Everything is OK, except here:
BrowserFieldRequest request = new BrowserFieldRequest("page.html");
Change here like:
BrowserFieldRequest request = new BrowserFieldRequest("local:///page.html");
you are calling the local file, that why we are giving like this.
Related
I have an Angular application that downloads a file to open in a new tab. It works perfectly on any plateform except on IOS where nothing happens. I make the call in the subscribe because during the download I display a spinner before opening the document on a new tab
this.myservice.dowloadFile(id).subscribe((res) =>
{
let blob = new Blob([file], {type: "application/pdf"});
const url = window.URL.createObjectURL(blob);
let anchor = document.createElement("a");
anchor.href = url;
anchor.target = '_blank';
anchor.click();
this.loadData = false;
});
}
I don't understand the problem.
I am new to this library but I couldn't find anything about downloading to the filestream with this library, I could only find a document.Save(filepath) option which is not always allowed.
I would like to create a filestream so the file gets downloaded to the directed Downloads folder.
Could someone point me in the right direct?
There is a Save overload that takes a MemoryStream object instead of path to a file.
The PDFSharp website has an example showing how to do this:
private void Page_Load(object sender, System.EventArgs e)
{
// Create new PDF document
PdfDocument document = new PdfDocument();
this.time = document.Info.CreationDate;
document.Info.Title = "PDFsharp Clock Demo";
document.Info.Author = "Stefan Lange";
document.Info.Subject = "Server time: " +
this.time.ToString("F", CultureInfo.InvariantCulture);
// Create new page
PdfPage page = document.AddPage();
page.Width = XUnit.FromMillimeter(200);
page.Height = XUnit.FromMillimeter(200);
// Create graphics object and draw clock
XGraphics gfx = XGraphics.FromPdfPage(page);
RenderClock(gfx);
// Send PDF to browser
MemoryStream stream = new MemoryStream();
document.Save(stream, false);
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", stream.Length.ToString());
Response.BinaryWrite(stream.ToArray());
Response.Flush();
stream.Close();
Response.End();
}
I am managing to send mails just fine with send grid, attachment too no issues. But I am having problems embedding images into the body of the HTML mail
Here is the code that I am using, put together after reading various examples on this issue. Anyone know where I am going wrong, regards...
MemoryStream msLogo = new MemoryStream(obj.logo);
Bitmap b = new Bitmap(msLogo);
ImageConverter ic = new ImageConverter();
Byte[] ba = (Byte[])ic.ConvertTo(b, typeof(Byte[]));
MemoryStream logo = new MemoryStream(ba);
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(sBody, null, "text/html");
LinkedResource imageResource = new LinkedResource(logo);
var imagelink = new LinkedResource(logo, "image/png");
imagelink.ContentId = string.Format("logo", myMessage);
imagelink.TransferEncoding = TransferEncoding.Base64;
b.Save(logo, ImageFormat.Jpeg);
logo.Position = 0;
I am trying to do this on ASP.NET MVC 4:
MemoryStream mem = new MemoryStream();
using (WordprocessingDocument wordDoc =
WordprocessingDocument.Create(mem, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true))
{
// instantiate the members of the hierarchy
Document doc = new Document();
Body body = new Body();
Paragraph para = new Paragraph();
Run run = new Run();
Text text = new Text() { Text = "The OpenXML SDK rocks!" };
// put the hierarchy together
run.Append(text);
para.Append(run);
body.Append(para);
doc.Append(body);
//wordDoc.Close();
///wordDoc.Save();
}
return File(mem.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ABC.docx");
However the ABC.docx opens as corrupted and it wouldn't open even after fixing it.
Any ideas?
Linked Qs:
Streaming In Memory Word Document using OpenXML SDK w/ASP.NET results in "corrupt" document
Apparently the problem comes from missing this 2 lines:
wordDoc.AddMainDocumentPart();
wordDoc.MainDocumentPart.Document = doc;
Updated the code to below and it now works flawlessly, even without any extra flushing, etc necessary.
MemoryStream mem = new MemoryStream();
using (WordprocessingDocument wordDoc =
WordprocessingDocument.Create(mem, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true))
{
wordDoc.AddMainDocumentPart();
// instantiate the members of the hierarchy
Document doc = new Document();
Body body = new Body();
Paragraph para = new Paragraph();
Run run = new Run();
Text text = new Text() { Text = "The OpenXML SDK rocks!" };
// put the hierarchy together
run.Append(text);
para.Append(run);
body.Append(para);
doc.Append(body);
wordDoc.MainDocumentPart.Document = doc;
wordDoc.Close();
}
return File(mem.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ABC.docx");
I have a program with a button to login via GET method, it works perfectly, but when I log in, the form appears zoomed out far and little. I wanted to know if there is any option with WebSettings.ZoomDensity, or WebView class, to scale the form size to the screen of the device.
The button code is this:
public void IniciSessio_BTN_Click(View Target) {
if (U.getText().length() <= 0)
Toast.makeText(getApplicationContext(), "Username", Toast.LENGTH_SHORT).show();
else if (K.getText().length() <= 0)
Toast.makeText(getApplicationContext(), "Password", Toast.LENGTH_SHORT).show();
else
{
DadesUsuari = U.getText().toString();
DadesClau = K.getText().toString();
DadesDesar = Desar_CB.isChecked();
Uri uri = Uri.parse( "http://www.mypage.com/?U="+U.getText().toString()+"&K="+K.getText().toString() );
startActivity( new Intent( Intent.ACTION_VIEW, uri ) );
}
}
I tryed to do this:
webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
But it doesn't works. It make me to create the WebView class and it crashes the app.
Also tryed this:
private WebView Navegador = null;
Navegador = new WebView(this);
Navegador.setVisibility(View.GONE);
Navegador.setPadding(0, 0, 0, 0);
Navegador.setInitialScale(73);
Uri uri = Uri.parse( "http://stats.serhstourism.com/?U="+U.getText().toString()+"&K="+K.getText().toString() );
startActivity( new Intent( Intent.ACTION_VIEW, uri ) );
WebSettings webSettings = Navegador.getSettings();
webSettings.setJavaScriptEnabled(true);
You should take a look at this article.
I think you have to set the viewport size in your html. Something like this ...
<meta name="viewport" content="width=100px, height:100px" />
Obviously you're going to have to change the pixel values. For more information how this works look at the article mentioned above.