Viewing 1 post (of 1 total)
  • Author
    Posts
  • #27002

    Hi Team,

    I am using .NET trial version of PD4ml and following code:

    public static void savePDF()
    {
    String path = null;
    PD4ML PDFcreator = new PD4ML();
    PDFcreator.PageSize = PD4Constants.A5;
    byte[] bytes = Encoding.UTF8.GetBytes(template);

    MemoryStream ms_reader = new MemoryStream(bytes);
    MemoryStream ms_writer = new MemoryStream(bytes);

    StreamReader reader = new StreamReader(ms_reader);

    SaveFileDialog saveFileDialog = new SaveFileDialog();
    saveFileDialog.InitialDirectory = “%UserProfile%/Desktop”;
    saveFileDialog.Filter = “pdf files (*.pdf)|*.pdf”;
    saveFileDialog.FilterIndex = 1;
    saveFileDialog.RestoreDirectory = true;
    StreamWriter writer = null;

    Stream myStream = ms_writer;

    try
    {
    if (saveFileDialog.ShowDialog() == DialogResult.OK)
    {
    path = saveFileDialog.FileName;
    writer = new StreamWriter(path);
    //PDFcreator.render(ms_reader, writer);
    PDFcreator.render(reader, writer);
    //PDFcreator.render(ms, myStream);
    //PDFcreator.render(reader, myStream);
    }
    }

    catch (Exception ex)
    {
    MessageBox.Show(ex.StackTrace);
    }

    finally
    {
    if (ms_reader != null)
    {
    ms_reader.Close();
    }
    if (reader != null)
    {
    reader.Close();
    }
    if (writer != null)
    {
    writer.Close();
    }
    }
    }

    I am getting an exception whenever I render this PDF. The exception reads as “Cannot read from Closed stream”; but I am not closing stream before render().

    There are 5 render() overloaded methods to writehtml template to a PDF file and I used all of them; but still no luck.

    And also I would like to understand is PD4ml trial version not letting me to render HTML as PDF or is PD4ml very strict to HTML tags…

    Please suggest.

Viewing 1 post (of 1 total)

The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.