Free Support Forum - aspose.com

Getting error while opening PDF file

Hi ,

I'm using Aspose.PDF v4.0. After executing the below code and try to open the PDF...I could able to open but whn I scroll the page getting exception "An error exists on this page. Acrobat may not display this page correctly....."

//Open document
Document pdfDocument = new Document("input.pdf");
//Get particular page
Page pdfPage = (Page)pdfDocument.Pages[1];

//Create text fragment
TextFragment textFragment = new TextFragment("main text");
textFragment.Position = new Position(100, 600);

//Set text properties
textFragment.TextState.FontSize = 12;
textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");
textFragment.TextState.BackgroundColor = Color.LightGray;
textFragment.TextState.ForegroundColor = Color.Red;

//Create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);

//Append the text fragment to the PDF page
textBuilder.AppendText(textFragment);

//Save document
pdfDocument.Save("output.pdf");

Hi Ponraj,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 7.8.0 where I have used following code snippet in Visual Studio 2010 application and I am unable to notice any issue while viewing the resultant PDF in Adobe Reader 11.0.2. Can you please share which version of Aspose.Pdf for .NET you are using.

We are sorry for this inconvenience.

[C#]

//Open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/Multilie_Field_output.pdf");

//Get particular page

Page pdfPage = (Page)pdfDocument.Pages[1];

//Create text fragment

TextFragment textFragment = new TextFragment("main text");

textFragment.Position = new Position(100, 600);

//Set text properties

textFragment.TextState.FontSize = 12;

textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");

textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);

textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

//Create TextBuilder object

TextBuilder textBuilder = new TextBuilder(pdfPage);

//Append the text fragment to the PDF page

textBuilder.AppendText(textFragment);

//Save document

pdfDocument.Save(“c:/pdftest/OutputWithText_output.pdf”);