We have a problem with a webservice while generating a local site. It has a problems with a html converter. Then we wanted to save our website at a local disc, but it is working and working and nothing is done(after using threading). I tried this threads, but they don't help. Here is the code:
[
WebMethod]public void go()
{
float itsHeight = -1; PdfPage itsPage = null; PdfDocument doc = new PdfDocument(PdfConformanceLevel.Pdf_A1B);doc.PageSettings.Orientation =
PdfPageOrientation.Portrait;itsPage = doc.Pages.Add();
HtmlConverter html = new HtmlConverter();html.AutoDetectPageBreak =
true;html.EnableHyperlinks =
true;html.EnableJavaScript =
true; PdfUnitConvertor convertor = new PdfUnitConvertor(); float itsWidth = convertor.ConvertToPixels(itsPage.GetClientSize().Width, PdfGraphicsUnit.Point); HtmlToPdfResult result = html.Convert(textBox1.Text.ToString(), ImageType.Metafile, (int)itsWidth, (int)itsHeight, AspectRatio.KeepWidth); PdfMetafile mf = new PdfMetafile(result.RenderedImage as Metafile);mf.Quality = 100;
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();format.Break =
PdfLayoutBreakType.FitPage;format.Layout =
PdfLayoutType.Paginate;mf.Draw(itsPage,
new PointF(0, 0), format);doc.Save(
"MojPDF.pdf");doc.Close(
true);}
}
Thank you for help!
Ok. It was my fault. I tried to use thread in my app, not at this line as it should be. Now everything works fine.
Only one more question:
We use VS 2008, and when I create a web service, i have problem with this line(it works fine in web application):
doc.save(fileName, Response, HttpReadType.Save)
"Response" is not visible, it is impossible to use it. Can I ask why?
MJ
Ok, fine. I realised that I had made a few mistakes, but now everything is working fine. Thanks!