PDF text show in Google Chrome but not in Adobe Acrobat

老子叫甜甜 提交于 2019-12-25 01:26:46

问题


I have a very strange problem. Documents i create using iTextSharp appears empty when i open them in Adobe acrobat, but works fine in Google Chrome. Here is some basic code that i use to generate my files:

mDocument = new iTextSharp.text.Document(PageSize.A4, 0, 0, 0, 0);
mStream = new MemoryStream();
var writer = PdfWriter.GetInstance(mDocument, mStream);
var font = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
mDocument.Open();
mContent = writer.DirectContent;
mContent.SetFontAndSize(font, 12);
mContent.SetTextMatrix(200, 200);
mContent.ShowText(value);
mDocument.Close();

Have anyone else run into this problem or see anything that I am missing that might cause this problem.

BR
Andreas


回答1:


Just found the solution to the problem. Adobe Acrobat requires this small change to work.

mContent.BeginText(); // New line!!!
mContent.ShowText(value);
mContent.EndText(); // New line!!!


来源:https://stackoverflow.com/questions/8301631/pdf-text-show-in-google-chrome-but-not-in-adobe-acrobat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!