I am using xml template for generating pdf document using latest version. I am not able to reference sections or segments by their ID in xml anymore com.aspose.pdf.Document pdfDoc = new com.aspose.pdf.Document(); pdfDoc.bindXml(“D:\templates\sampleTags.xml”);
Following used to work with the legacy version. Pdf pdfDoc = new Pdf(bindXML(“D:\templates\sampleTags.xml”, null); pdfDoc.bindXml(“D:\templates\sampleTags.xml”); Section section = (Section)pdfDoc.getObjectByID(“mainSection”)
Sample xml file: <?xml version="1.0" encoding="utf-8" ?>
In legacy com.aspose.pdf package, each page is termed as Section and in new DOM, the page is referenced from A Page object. So in order to reference XML objects using new approach, you need to create XML according to Document Object Model of com.aspose.pdf. package. Please take a look over following code snippet. I have also attached the PDF output generated over this side.
Thanks for the response. We didn't know about the new structure. Is there documentation on how to write xml in the new format?
I am not able to access all the elements in the xml with the new format. I have included the xml file.
Document pdfDoc = new Document(); pdfDoc.bindXml("D:\\templates\\sampleTags.xml"); Page pdfSection = pdfDoc.getPages().get_Item(1); //how can I access Segments with id=boldHtml and strongHtml from page object
I want to dynamically place html values in the segments?
The Text and Segment objects are present in legacy Aspose.Pdf for Java and I am afraid they are not part of new DOM (Document Object Model). However you may consider using TextFragment and TextSegment objects when using new DOM approach of com.aspose.pdf package.
Thanks for your patience and sorry for the delayed response.
I have logged an investigation ticket as PDFNEWNET-40014 in our issue tracking system and have intimated our product team to start investigating this requirement. We need to determine the mechanism to accomplish this requirement and once we have some updates, we will let you know. Currently we have logged this investigation ticket for Aspose.Pdf for .NET project and once the feature is implementation, the same solution will be ported to Aspose.Pdf for Java.
Please be patient and spare us little time. We are sorry for this delay and inconvenience.
I was testing the behavior after the fix. It is not working properly. If TextSegment is inside a Table row, I am not able to access the object. But if it is directly inside Page element, I am able to access it.
we are sorry for the inconvenience. I have tested your scenario with the shared XML document and noticed that Aspose.Pdf for Java throws NullPointer exception for accessing TextFragment/TextSegment inside Row element. For further investigation, I have logged an issue in our issue tracking system as PDFNEWJAVA-35857 and also linked your request to it. We will keep you updated via this thread regarding the issue status.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.