0

first of all I would like to wish everyone a happy 2015 and be prosperous for all of you. I would like to help me with a problem I have with a cookie and Winnovative, the problem is that I correctly the data in a cookie but when the process for the dll and reaches the window that gets data to the cookie comes in white with no data. not then I'm doing wrong. Annex code to Confinued:

            string apo = String.Empty;
            apo = Request.Cookies["dApoderados"].Value;
            HttpCookie datosApoderados = new HttpCookie("datosApoderados");

            string cadenaPDF = String.Empty;
            string ruta = String.Empty;
            ruta = ObtenerDireccionInformeSalida();
            ruta = ruta.Replace("../", "");
            GenerarQueryString();

            Response.Cookies["datosApoderados"].Value = apo;
            ruta = "http://localhost:10458/" + ruta;

            byte[] bytes = ObtenerPdfBytes(ruta);

That's when I want to process, then passes through an intermediate product which is:

 public byte[] ObtenerPdfBytes(string ruta)
    {
        string datosClientes = Request.Cookies["datosCliente"].Value;
        string datosApoderados = Request.Cookies["datosApoderados"].Value;
        datosClientes = "?DATOS=" + datosClientes;

        ruta = ruta + datosClientes;

        PdfConverter pdfConverter = new PdfConverter();

        HttpCookie prueba = new HttpCookie("prueba");
        Response.Cookies["prueba"].Value = datosApoderados;

        if (Context.Request.Cookies[FormsAuthentication.FormsCookieName] != null)
        {
            pdfConverter.HttpRequestHeaders = String.Format("prueba : {0}={1}",
            FormsAuthentication.FormsCookieName, Request.Cookies[FormsAuthentication.FormsCookieName].Value);
        }

        pdfConverter.LicenseKey = ClaveGeneradorPdf;
        pdfConverter.PdfDocumentOptions.ShowFooter = true;

        pdfConverter.PdfFooterOptions.PageNumberText = TextoPagina;
        pdfConverter.PdfFooterOptions.PageNumberTextFontType = PdfFontType.HelveticaBold;
        pdfConverter.PdfFooterOptions.PageNumberTextFontSize = 8;
        pdfConverter.PdfFooterOptions.ShowPageNumber = true;
        pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.Legal;
        pdfConverter.PdfFooterOptions.FooterHeight = AltoPie;
        pdfConverter.PdfDocumentOptions.LeftMargin = MargenIzquierdo;
        pdfConverter.PdfDocumentOptions.RightMargin = MargenDerecho;
        pdfConverter.PdfDocumentOptions.TopMargin = MargenSuperior;
        pdfConverter.PdfDocumentOptions.BottomMargin = MargenInferior;
        pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
        pdfConverter.PdfFooterOptions.FooterText = "texto";
        pdfConverter.PdfFooterOptions.FooterTextFontType = PdfFontType.HelveticaBold;
        pdfConverter.PdfFooterOptions.FooterTextFontSize = 8;
        pdfConverter.PdfDocumentOptions.ShowHeader = false;

        byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(ruta);
        return pdfBytes;
    }

when I get to the next line is where the cookie is lost: byte [] pdfBytes = pdfConverter.GetPdfBytesFromUrl (path);

public override void Pagina_PrimeraCarga(object sender, EventArgs e)
    {
        string prueba = Request.Cookies["prueba"].Value;
        string datosRequest = Request.QueryString["DATOS"];
        char delimitadores = ';';
        string[] datos = datosRequest.Split(delimitadores);

        imgBanco.Attributes.Add("ImageUrl", "~/App_Themes/Imagenes/Logo.gif");
        DateTime fechaHoy = DateTime.Now;
        lblDia.Text = Convert.ToString(fechaHoy.Day);
        lblMes.Text = Convert.ToString(fechaHoy.Month);
        lblAno.Text = Convert.ToString(fechaHoy.Year);

loading data from the cookie in the latter code: string test = Request.Cookies ["test"] Value.; This goes empty and no data

1 Answers1

0

The converter has a HttpRequestCookies collection you can use. There is a complete example for cookies in Winnovative website. Here is the relevant code copied from there:

// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();

// Set license key received after purchase to use the converter in licensed mode
// Leave it not set to use the converter in demo mode
htmlToPdfConverter.LicenseKey = "fvDh8eDx4fHg4P/h8eLg/+Dj/+jo6Og=";

// Add custom HTTP cookies

if (cookie1NameTextBox.Text.Length > 0 && cookie1ValueTextBox.Text.Length > 0)
    htmlToPdfConverter.HttpRequestCookies.Add(cookie1NameTextBox.Text, cookie1ValueTextBox.Text);

if (cookie2NameTextBox.Text.Length > 0 && cookie2ValueTextBox.Text.Length > 0)
    htmlToPdfConverter.HttpRequestCookies.Add(cookie2NameTextBox.Text, cookie2ValueTextBox.Text);

if (cookie3NameTextBox.Text.Length > 0 && cookie3ValueTextBox.Text.Length > 0)
    htmlToPdfConverter.HttpRequestCookies.Add(cookie3NameTextBox.Text, cookie3ValueTextBox.Text);

if (cookie4NameTextBox.Text.Length > 0 && cookie4ValueTextBox.Text.Length > 0)
    htmlToPdfConverter.HttpRequestCookies.Add(cookie4NameTextBox.Text, cookie4ValueTextBox.Text);

if (cookie5NameTextBox.Text.Length > 0 && cookie5ValueTextBox.Text.Length > 0)
    htmlToPdfConverter.HttpRequestCookies.Add(cookie5NameTextBox.Text, cookie5ValueTextBox.Text);

// Convert the HTML page to a PDF document in a memory buffer
byte[] outPdfBuffer = htmlToPdfConverter.ConvertUrl(urlTextBox.Text);

// Send the PDF as response to browser

// Set response content type
Response.AddHeader("Content-Type", "application/pdf");

// Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=HTTP_Cookies.pdf; size={0}", outPdfBuffer.Length.ToString()));

// Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer);

// End the HTTP response and stop the current page processing
Response.End();
EvoPdf
  • 523
  • 3
  • 9