在移动浏览器上生成pdf文件时,我遇到了以下问题:在某些移动浏览器中文件被损坏,但某些文件被下载但未显示文本,它只在文件中显示图像。同时,在桌面浏览器上工作时文件生成得很完美,并且下载时文件内容完美显示。我不知道背后的真实原因,因为我在开发Web应用程序方面是全新的。在移动浏览器上工作时生成pdf文件时出现问题
我使用的代码在下面给出:
Document pdfDoc = new Document(PageSize.A4, 10, 10, 10, 10);
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
string imageUrl = Server.MapPath("~/logo//bcetlogo.jpg");
iTextSharp.text.Image ImageLogo = iTextSharp.text.Image.GetInstance(imageUrl);
ImageLogo.ScaleToFit(80f, 80f);
pdfDoc.Add(ImageLogo);
Font f = FontFactory.GetFont("Arial", 15);
string title = "HelloWorld";
Paragraph text1 = new Paragraph(title, f);
pdfDoc.Add(text1);
pdfWriter.CloseStream = false;
pdfWriter.Close();
Response.Buffer = true;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=Example.PDF");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
亲爱的@AbhinandanKumar,是我的回答的事情吗?你有没有机会尝试提出的解决方案?它对你有帮助吗? –