Exemplo n.º 1
0
    protected void btn_exportpdf_Click(object sender, EventArgs e)
    {
        System.Web.HttpResponse httpcurrent = System.Web.HttpContext.Current.Response;
        try
        {
            pdfcrowd.Client client = new pdfcrowd.Client("kiris", "aa2ac029eefa6cb805effd56c022e9d9");
            MemoryStream    memo   = new MemoryStream();

            string url = HttpContext.Current.Request.Url.AbsoluteUri;
            client.convertURI(url, memo);

            Response.Clear();
            Response.AddHeader("Content-Type", "application/pdf");
            Response.AddHeader("Cache-Control", "max-age=0");
            Response.AddHeader("Accept-Ranges", "none");
            Response.AddHeader("Content-Disposition", "attachment; filename=mens_hoadon.pdf");

            memo.WriteTo(Response.OutputStream);
            memo.Close();
            Response.Flush();
            Response.End();
        }
        catch (Exception)
        {
        }
    }
Exemplo n.º 2
0
    static void Main()
    {
        try
        {
            FileStream fileStream;

            // create an API client instance
            pdfcrowd.Client client = new pdfcrowd.Client("egor", "281dcd338e127d30472ea7e82b77ccad");

            // convert a web page and save the PDF to a file
            //fileStream = new FileStream("google_com.pdf", FileMode.CreateNew);
            //client.convertURI("http://www.google.com", fileStream);
            //fileStream.Close();

            //// convert an HTML string and store the PDF into a memory stream
            //MemoryStream memStream = new MemoryStream();
            //string html = "<head></head><body>My HTML Layout</body>";
            //client.convertHtml(html, memStream);

            // convert an HTML file
            fileStream = new FileStream(@"C:\Users\Egor\Desktop\cv\resume.pdf", FileMode.CreateNew);
            client.convertFile(@"C:\Users\Egor\Desktop\cv\resume.html", fileStream);
            fileStream.Close();

            // retrieve the number of tokens in your account
            //int ntokens = client.numTokens();
        }
        catch (pdfcrowd.Error why)
        {
            System.Console.WriteLine(why.ToString());
        }
    }
Exemplo n.º 3
0
    protected void btn_exportpdf_Click(object sender, EventArgs e)
    {
        System.Web.HttpResponse httpcurrent = System.Web.HttpContext.Current.Response;
        try
        {
            pdfcrowd.Client client = new pdfcrowd.Client("kiris", "aa2ac029eefa6cb805effd56c022e9d9");
            MemoryStream memo = new MemoryStream();

            string url = HttpContext.Current.Request.Url.AbsoluteUri;
            client.convertURI(url, memo);

            Response.Clear();
            Response.AddHeader("Content-Type", "application/pdf");
            Response.AddHeader("Cache-Control", "max-age=0");
            Response.AddHeader("Accept-Ranges", "none");
            Response.AddHeader("Content-Disposition", "attachment; filename=mens_hoadon.pdf");

            memo.WriteTo(Response.OutputStream);
            memo.Close();
            Response.Flush();
            Response.End();
        }
        catch (Exception)
        {

        }
    }
Exemplo n.º 4
0
        public Tests(string[] args)
        {
            m_args = args;

              if (args.Length == 5) {
            Client.HTTP_PORT = int.Parse(args[3]);
            Client.HTTPS_PORT = int.Parse(args[4]);
              }

              client = getClient(false);

              client.setPageMode( Client.FULLSCREEN );

              string this_dir =
            System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
              Directory.SetCurrentDirectory (this_dir);
              Directory.CreateDirectory("../test_files/out");
        }
Exemplo n.º 5
0
        private Client getClient(bool use_ssl)
        {
            Client client;
              if (m_args.Length > 2)
            {
              client = new Client(m_args[0], m_args[1], m_args[2]);
            }
              else
            {
              client = new Client(m_args[0], m_args[1]);
            }

              if (use_ssl)
            client.useSSL(use_ssl);

              return client;
        }