We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

mender.AddText results in PDF Error

I am using the following code to add some text to
an existing pdf. The resulting pdf shows an error (“An error exists on this
page…”) when opened in adobe acrobat Pro 9.4.6. I have attached the input (“C.pdf”)
and the output (“C.pdf”). System info – windows 7 64bit, visual studio 2010.<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

Dim strFilePath_MeetingPackage2 As String = "M:\temp\TestProgrammingFiles\B.pdf"

Dim strFilePath_MeetingPackage3 As String = "M:\temp\TestProgrammingFiles\C.pdf"

Dim mender As New PdfFileMend(strFilePath_MeetingPackage2, strFilePath_MeetingPackage3)

Dim TextHeader_Centre As New FormattedText("Agenda", System.Drawing.Color.Black, Aspose.Pdf.Facades.FontStyle.TimesRoman, EncodingType.Winansi, True, 10)

mender.IsWordWrap = True

mender.WrapMode = WordWrapMode.Default

mender.AddText(TextHeader_Centre, 1, 20, 770)

mender.Close()

I run into even more problems if I try to use “ScannedDoucment2.pdf” (attached) as the input. In this situation I get a missing object error (“Object reference not set to an instance of an object”) when the “mender.AddText(TextHeader_Centre, 1, 20, 770)” line is run.

Thanks

Hi Dan,

Thanks for using our products.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-30840. We will investigate this
issue in details and will keep you updated on the status of a correction.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;
font-family:“Arial”,“sans-serif””>

We apologize for your inconvenience.

I am trying to find a work around for adding text to an existing pdf. I have tried the code from here. Which works with the attached AddText_InputA.pdf, however, i get an error when using AddText_InputB.pdf. See code below.

Dim pdfDocument As New Document("M:\temp\TestProgrammingFiles\AddText_InputB.pdf")
Dim pdfPage As Page = CType(pdfDocument.Pages(1), Page)
Dim textFragment As New Aspose.Pdf.Text.TextFragment("main text")
textFragment.Position = New Aspose.Pdf.Text.Position(10, 10)
textFragment.TextState.FontSize = 12
textFragment.TextState.Font = Text.FontRepository.FindFont("TimesNewRoman")
textFragment.TextState.BackgroundColor = Drawing.Color.LightGray
textFragment.TextState.ForegroundColor = Drawing.Color.Red
Dim textBuilder As New Aspose.Pdf.Text.TextBuilder(pdfPage)
textBuilder.AppendText(textFragment) 'Error thrown when using AddText_InputB.pdf
pdfDocument.Save("M:\temp\TestProgrammingFiles\AddText_OutputB.pdf")

Is it possible to validate/modify/process the attached AddText_InputB.pdf so that it will work with this code?

Hi Dan,

I have managed to reproduce the same problem that text is not being added to AddText_InputB.pdf document. For the sake of correction, the problem has been logged in our issue tracking system as PDFNEWNET-30990. We will further investigate the reasons of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We apologize for this inconvenience.

Any updates on PDFNEWNET-30840v or PDFNEWNET-30990 ?

Thanks,

Dan

The issues you have found earlier (filed as 30990) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

I still get an error when opening a pdf that has been edited with mender.addtext and contains a rotated page. The error as shown in Acrobat Pro 9.4.6 is "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document o correct the problem.An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document o correct the problem."

I am using apose.pdf version 6.5 with visual studio 2010.

I have uploaded an example input pdf - AddText_InputA.pdf and the resultant output file. the code that i am using is below.

'create PdfFileMend object to add text
Dim strinput As String = "M:\temp\TestProgrammingFiles\AddText_InputA.pdf"
Dim stroutput As String = "M:\temp\TestProgrammingFiles\Output" + Format(Now, "MMddTHHmm") + ".pdf"
Dim mender As New PdfFileMend(strinput, stroutput)
'create formatted text
Dim text As New FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.AliceBlue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, True, 14)
'set whether to use Word Wrap or not and using which mode
mender.IsWordWrap = True
mender.WrapMode = WordWrapMode.Default
'add text in the PDF file
mender.AddText(text, 1, 100, 200, 200, 400)
mender.AddText(text, 2, 100, 200, 200, 400)
'close PdfFileMend object
mender.Close()
System.Diagnostics.Process.Start(stroutput) 'create PdfFileMend object to add text
Dim strinput As String = "M:\temp\TestProgrammingFiles\AddText_InputA.pdf"
Dim stroutput As String = "M:\temp\TestProgrammingFiles\Output" + Format(Now, "MMddTHHmm") + ".pdf"
Dim mender As New PdfFileMend(strinput, stroutput)
'create formatted text
Dim text As New FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.AliceBlue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, True, 14)
'set whether to use Word Wrap or not and using which mode
mender.IsWordWrap = True
mender.WrapMode = WordWrapMode.Default
'add text in the PDF file
mender.AddText(text, 1, 100, 200, 200, 400)
mender.AddText(text, 2, 100, 200, 200, 400)
'close PdfFileMend object
mender.Close()
System.Diagnostics.Process.Start(stroutput)

Hi Dan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template files and sample code.

I am able to reproduce your mentioned issue. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-32675. You will be notified via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-32675) have been fixed in Aspose.Pdf for .NET 7.8.0update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as PDFNEWNET-30840) have been fixed in Aspose.Pdf for .NET 9.9.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.