问题
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