Post videos to twitter [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I got success to post photos to Twitter. But how do i post videos to Twitter using my C# application?. For posting pictures i used Tweetsharp. Can we use Tweetsharp's SendTweetWithMediaOptions to share video? if yes How?
This is sample i used to share picture to twitter
Bitmap img = new Bitmap(Server.MapPath(#"~/Images/Special/" + Convert.ToInt32(offerId) + "/" + specialOffer.Picture));
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Seek(0, SeekOrigin.Begin);
Dictionary<string, Stream> images = new Dictionary<string, Stream> { { "mypicture", ms } };
var tweet = tweetservice.SendTweetWithMedia(new SendTweetWithMediaOptions { Status = urlTextToShare, Images = images });
and what i need is something like below image

You cannot upload videos to Twitter. If you read their documentation, it says:
Supported image formats are PNG, JPG and GIF, including animated GIFs of up to 3MB
You choices are either to upload an animated GIF or include a URL to a video (such as YouTube / Vimeo)

Related

How do I convert an html web page into image using C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
How to convert a dynamic link which is a html web page into an Image format. Remember the link is dynamic which contains html content in string format. I have tried a lot of ways like reading the html content using converting to base64 first then visa versa.
var htmlToImageConv = new HtmlToImageConverter();
byte[] jpegBytes = htmlToImageConv.GenerateImage(html, ImageFormat.Jpeg); System.Drawing.Image image; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(strOg))
{
image = System.Drawing.Image.FromStream(ms); string path = Server.MapPath("~/images/");
}
I have tried this code in c# for converting html webpage to image.
You can use a headless browser to render the html and then take a snapshot.
Have a look at PuppeteerSHarp: https://github.com/kblok/puppeteer-sharp
You could use Selenium to render the page and save a screenshot as a png image.
Add the following packages to your project:
Selenium.WebDriver
Selenium.Chrome.WebDriver
Use the following code to save a screenshot:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://google.com");
Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
ss.SaveAsFile("screenshot.png");
}
}
}
That what you need is a conversation from a html containing string to an image, which is already discussed in the answers of this Question.

How to convert PDF page to c# Bitmap object (not to file)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Is there a way to convert a PDF page to bitmap in c#? I tried with Ghostscript but I think it is file based. Thanks in advance.
LibPdf
This library converts converts PDF file to an image. Supported image formats are PNG and BMP, but you can easily add more.
using (FileStream file = File.OpenRead(#"..\path\to\pdf\file.pdf")) // in file
{
var bytes = new byte[file.Length];
file.Read(bytes, 0, bytes.Length);
using (var pdf = new LibPdf(bytes))
{
byte[] pngBytes = pdf.GetImage(0,ImageType.BMP); // image type
using (var outFile = File.Create(#"..\path\to\pdf\file.bmp")) // out file
{
outFile.Write(pngBytes, 0, pngBytes.Length);
}
}
}
Read this article: PDF to bmp Images (12 pages = 12 images)

Convert MVC 4 View To Pdf using Itextsharp [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am trying to Convert a MVC 4 View to a PDF. I have no idea where to start, after searching google i found ItextSharp and have been playing around with it.
My View is fairly Simple it has a Map and a Table. i would like to just call an action in the controller and have it print my web page.
Any Advice would be greatly Appreciated
You can use Rotativa
public ActionResult TestViewWithModel(string id)
{
var model = new TestViewModel {DocTitle = id, DocContent = "This is a test"};
return new ViewAsPdf(model);
}
public ActionResult PrintIndex()
{
return new ActionAsPdf("Index", new { name = "Giorgio" }) { FileName = "Test.pdf" };
}
It uses wkhtmltopdf under the hood.
wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line
tools to render HTML into PDF and various image formats using the QT
Webkit rendering engine. These run entirely "headless" and do not
require a display or display service.

Reading barcodes from pdf [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I was just wondering if anyone has experience reading barcodes from a pdf file. I googled and found this bytescout reader and used the program like this
Reader barcodeReader = new Reader();
barcodeReader.BarcodeTypesToFind.Code39 = true;
Console.WriteLine("Reading barcode(s) from PDF");
FoundBarcode[] barcodes = barcodeReader.ReadFrom("Sample.pdf");
foreach (FoundBarcode barcode in barcodes)
Console.WriteLine("Found barcode with type '{0}' and value '{1}'", barcode.Type, barcode.Value);
This doesn't output any barcodes.
Please suggest any other library I could use?
DataMatrix is a C# library that can decode barcodes from image files and I believe it can read them from PDFs too. Here is an example of usage:
private string DecodeText(string sFileName)
{
DmtxImageDecoder decoder = new DmtxImageDecoder();
System.Drawing.Bitmap oBitmap = new System.Drawing.Bitmap(sFileName);
List<string> oList = decoder.DecodeImage(oBitmap);
StringBuilder sb = new StringBuilder();
sb.Length = 0;
foreach (string s in oList)
{
sb.Append(s);
}
return sb.ToString();
}
You pass in an image filename and it will decode the barcode and return the string. If DataMatrix does not read from PDFs, then you'll have to also download iTextSharp which is a library for manipulating PDFs. Using iTextSharp, you can extract the barcode from the PDF, save it as an image, then use the function above to interpret the barcode.

Custom graphic in WPF application? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have a WPF application which has a picture box with a graphic in it, I need a way to be able to change this graphic in a simple straightforward manner (like replacing an image file in the programs install directory).
I'm not sure if this is what you want, but...
You could do something like this:
Source="pack://siteoforigin:,,,/Images/someimage.png"
and use images off of your bin/app folder. Take a look at this link for more info...
What is application's site of origin and when to use it
Define a function that loads an image from an external image file
public static ImageSource LoadImage(string fileName)
{
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri("file:///" + fileName.Replace("\\", "/"));
bitmap.EndInit();
return bitmap;
}
You can then assign an image controls source to this functions return value.
someImageControl.Source = LoadImage(#"d:\\images\\image.png");

Categories

Resources