Free Support Forum - groupdocs.com

Need help in PDF Creation

Hi,


I am working on .net MVC application. I need to convert the rendered Page into PDF document.
Do you have any example to do this? I see examples to convert to PDF when we provide an Input file. If you could provide me an example to convert the HTML page that would be really helpful.

Thanks & Regards
Balarka DSRK

Hi Balarka,

Thank you for coming back.

Yes we have an example to achieve your desired output from Html file. Please click here to explore the code where you just need to set the input file name and convert it to PDF, Image, Words etc…




public ActionResult Index(ConvertModel model)



{



// your input file to be converted



model.inputGUIDFile = DOCXsample.docx;








return View(model);
}


If you will need any help or you will have any other questions please feel free to ask.

Warm Regards,

Hi,


I don’t have any input file. I just need to convert the rendered page into PDF. I have a page which contains some text boxes for the use to fill. once he fills he will click on export to pdf button. which i need to convert the rendered html with user input data to PDF.

Thanks & Regards
Balarka DSRK

Hi,


Thank you for the clarification,

As per your requirement, you need to handle this in your own application to read the HTML after user input, once you have final html that you can read into a stream and use GroupDocs.Conversion for .NET API to create PDF output file.

Please click here to see more detail about input and output as an IOStream to PDF.

If you will need any help or you will have any other questions please feel free to ask.

Warm Regards,

Hi,


While generating the PDF from HTML content i am getting the below error.

Unable to cast object of type ‘System.IO.MemoryStream’ to type ’ ​ '. Could you please help me in fixing this issue.

And also my Html content is more and it is not rendering properly in portrait format. Is there any option to generate the pdf in landscape.

Thanks & Regards
Balarka DSRK

Hi ,

Kindly share the code snippet where you are getting this error and kindly also share the exception details generating in code.

Thank you for your cooperation.

Warm Regards,

Hi Below is the code which i am using to generate the pdf.



private string GeneratePDF(Stream stream, string fileName)
{
ApplyLicense(licensePath);
ConversionHandler handler = GetConversionHandler();
return handler.Convert(stream, new PdfSaveOptions { OutputType = OutputType.String, CustomName = fileName });
}

Its failing at the last step.
return handler.Convert(stream, new PdfSaveOptions { OutputType = OutputType.String, CustomName = fileName });

Please find the attachment for the screen shot.

Let me know if you need more details.

Thanks & Regards
DSRK Balarka

Hi,

Sorry for the inconvenience,

We have re-produced this issue at our end and also notified to product team for the solution, once we have any update from product team, we will update you here.

Thank you for your patience.

Warm Regards,