Free Support Forum - aspose.com

How do you use TextBoxField.AddImage?

I can’t find an example and the simple code below generates an error (in Save):

Document pdfDocument = new Document(@“C:\Document\input.pdf”);
PdfForms.TextBoxField textBoxFiled = pdfDocument.Form[“Logo”] as PdfForms.TextBoxField;
System.Drawing.Image image = System.Drawing.Bitmap.FromFile(@“C:\Document\logo.png”);
textBoxFiled.AddImage(image);
pdfDocument.Save(@“C:\Document\output.pdf”);
Or is there a better way?
Thanks.

Hello Jean-Christophe,

Thanks for using our products and sorry for replying you late.

I have tested the scenario using Aspose.Pdf for .NET 6.0.0 where I have tried adding a sample image file to TextBoxField and as per my observations, I am unable to notice any problem. Can you please share the source PDF form that you are using so that we can test it in our environment. We are really sorry for your inconvenience.

Here are the documents, PDF and Image.
Please replace:

PdfForms.TextBoxField textBoxFiled = pdfDocument.Form[“Logo”] as PdfForms.TextBoxField;
by:
PdfForms.TextBoxField textBoxFiled = pdfDocument.Form[“Colours”] as PdfForms.TextBoxField;

Details of the Error:
at Aspose.Pdf.Engine.IO.SaveStrategies.LinearizedSaveStrategy.CreatePageOffsetHintTable(LinearizationInfo info, IRegistrar registrar, PageOffsetHeaderSection& poHeader, PageOffsetEntry[]& entries)
at Aspose.Pdf.Engine.IO.SaveStrategies.LinearizedSaveStrategy.CreateHintTable(IRegistrar registrar, IDocumentTree documentTree, ITrailerable trailerable, Int64 offset)
at Aspose.Pdf.Engine.IO.SaveStrategies.LinearizedSaveStrategy.Save(IPdfDocumentStructure documentStructure, IDocumentTree documentTree, ILinearize linearize, IRegistrar registrar, IPdfStreamWriter streamWriter, Int32 firstPageNumber)
at Aspose.Pdf.Engine.IO.SaveStrategies.LinearizedSaveStrategy.Save(IPdfStreamWriter streamWriter, IPdfDocumentStructure documentStructure)
at Aspose.Pdf.Engine.IO.PdfWriter.Save()
at Aspose.Pdf.Engine.IO.PdfFile.Save(Stream stream)
at Aspose.Pdf.Engine.PdfDocument.Save(Stream stream)
at Aspose.Pdf.Document.Save(Stream output)
at Aspose.Pdf.Document.Save(String outputFileName)

Sorry about the Image!

Hello Jean-Christophe,

Thanks for sharing the resource files.
<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 <span style=“font-family:“Arial”,“sans-serif””>PDFNEWNET-29589. We will
investigate this issue in details and will keep you updated on the status of a
correction.<span style=“font-size: 10pt; font-family: “Arial”,“sans-serif”;”>

<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>We
apologize for your inconvenience.

Thanks. I need to have this working for the next release of our product (programming cutoff is mid-September). Are you confident to deliver the fix before? Is there another way to add an image inside a TextBox?

Hello Jean-Christophe,

Thanks for your patience and sorry for replying you late.
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Our development team is working hard to get this issue fixed but I am afraid it’s not yet completely resolved. I am not entirely certain but as per my understanding, we hope to get this issue resolved in upcoming release version. In fact the issue is occurring when using the source image file that you have shared.


Nevertheless, I have requested the team to share the ETA regarding its resolution. Soon you will be updated with the status of correction. We apologize for your inconvenience.

Your patience and comprehension is greatly appreciated in this regard.

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


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