How to use aspose-pdf-2.7.0-java for converting xml to pdf

Hi,

I have downloaded the software.my current app is running on eblogicportal.I have a xml file.Now i am trying to convert it to the pdf template.I have no clue how to start, i did followed the documentation, but i didn't get.

Can somebody explain me how to proceed.Your help is appreciated.

Thanks in advance

Hi,

Thanks for considering Aspose.

Please find attached an XML document which contains Text, Heading, Table, Labeled list and Bulleted List items. The text objects also contain formatting information. For your reference, I have attached the resultant PDF generated with this XML file using Aspose.Pdf for Java 2.7.0. In case it does not satisfy your requirement, please share some details regarding the source XML file that you would like to have. We are sorry for your inconvenience.

I would also recommend you to visit the following links for more information on

Please make sure that the source XML should be in Aspose.Pdf for Java compatible format. For more related information, please visit Aspose.Pdf Document Object Model (DOM)

I have used the following code snippet to test the scenario

[Java]

try{
aspose.pdf.License lic = new aspose.pdf.License();
lic.setLicense(new FileInputStream(new File("D:/ASPOSE/Aspose.Total.Java.lic")));
}catch(Exception ex)
{}

Pdf pdf = new Pdf();
pdf.bindXML("D:/pdftest/samplesource.xml",null);
// Save the document
pdf.save("d:/pdftest/Java_HelloWorld.pdf");

In case you have any further query, please feel free to contact. We apologize for your inconvenience.

Hi Nayyer,

Thanks for your response, i have gone through all the links that you provided.please find my attached xml.

i am not sure how to procced furthur.I have a java project , in that i have an xml, i generated using eclipse.Now i have created a classsome testpdf.java.I have installed the aspose in my c:\aspose.

how do i call the xml in the testpdf class,how do i get it as a template.

can you help me with that part.

Thanks

Hi,

Thanks for your interest in our products.

As far as I can see, the XML file that you are using is not according to Aspose.Pdf DOM (Document Object Model). As I have shared earlier, in order to convert the XML file into PDF format without any problem, the source XML must be in Aspose.Pdf compatible format.

However, in case you need to use your own XML file, you can use XSLT to make your source XML compatible to Aspose.Pdf. Please visit the following link for information on

The above links are from Aspose.Pdf for .NET section but the information is also applicable to Aspose.Pdf for Java because both the products have same DOM. In case I have not properly understood your requirement or you have any further query, please feel free to contact. We apologize for your inconvenience.

PS, When you are using XML and XSLT to generate PDF document, please try using Pdf.bindXML(java.lang.String xmlFile, java.lang.String xslFile) over loaded method.

Ok, Let’s not even bother about my xml.suppose i am using your sample xml .and crated a java class with the code what u mentioned in the below.How did you generate the pdf.
I was asking for those steps.you keep on talking about the documentation, i have already gone through that,.all the sample are there in your documentation.

I just want to to know with your xml after getting this software what are the steps need to be followed to generate the pdf.


Thanks

Hi,

Please accept my apologies for not replying you earlier on how to use Aspose.Pdf for Java.

In case you need to use Aspose.Pdf for Java in Eclipse project, first you need to create a Java project. Select "Project" and then select "Properties". Select Java Build Path from Left tree over "Properties window" and select Libraries Tab. Press "Add External JARs" button and provide the path for aspose.pdf.jar. I have also attached a screenshot which shows the project properties windows once JAR file has been included in the project.

Once the JAR file has been added, open the class file (or create one using New -> Class Menu option). Add the reference of Aspose.Pdf for Java library inside code using import aspose.pdf.*;.

Now you can use the code that I have shared in my earlier posts inside Main method or any of your customer method. Please try using this approach and in case you encounter any issue or you have any further query, please feel free to contact. We apologize for your inconvenience.

Hi,

Thanks for the reply,i did the samething , anyway it did worked for me.

now i am looking how to create xml or how to convert my current xml to the aspose compatible way.

Now my requirement is converting the xml to pdf.I have generated the xml just using eclipse first generated xsd, and then generated the xml.Now i need to know how to create an xml compatible for the aspose.

or you did send me the links to convert the current xml to Xslt, i did followed those links but i couldn't get it.Let me know whichever is easier way, and give me the steps to create an eclipse with eclipse in the compatible format.

And i would like to know one more thing you have aspose.total, aspose.pdfkit and aspose.pdf.

I thought for my requirement i can go with aspose.pdf for java.

or do i need to go with aspose.pdf .total for java.

my requirement is converting xml to pdf and adding some images to the pdf in byte stream.

please do guide me the steps need to be followeddon't send the doc, i alredy had gone through that

I appreciate your help

Thanks

In other way when i create the xsd in eclipse along with the elements that i need to populate what else are required to create the pdf template.When we do the layout we have to allocate the margins and heades, allocate the space for images and etc.My template looks something like this.I need to add a header and do the layout font, adding images etc

ProductId

15385AZT

Desc

Hooded Adjustable Wide Flood Light

Dimension

lengthxwidthxheight

Product

Type Flood light wall wash accent light

Style Test Data

Finish Textured Architecture Bronze,Bronzed Brass,Beach

Housing Alumininu or Brass Heat resistant flat glass lens is fully sealed

Specs

A-Width 5-3/8"

B-width 6"

Length Test Data

weight Test Data

LampInfo

LightSource 12 V Incandescent bi-pin, high temperature porcelain socket

No.ofBulbs Test Data

MaxWattage Test Data

WattageRange Test Data

LampType Test Data

SocketBase Test Data

SocketWire 35" of usable # 18-2, SPT-1-W leads Cable connector specified

ColorTempRange >Test Data

CRI >Test Data

ExpectedLifeSpan >Test Data

Info

Efficacy >Test Data

VA VA MAX:75-w(VA) Aluminium, 50=w(VA) Brass,Supplied:50-w(VA) QT3 or

QT4(17015)

InputVolatage >Test Data

OutputVoltage >Test Data

Certification >Test Data

EnergyEfficient >Test Data

PatentInfo Us Patent Pending

DarkSkyComplaint Test Data

Features

Large(63/4: x 5") floodlight with wide beam spread for dramatic up or down

wall-washing of taller walls and vertical stone work Eyebroe shields glare to allow

for horizontal use

MountingAccessories

15385AZT

OptionalMountingAccessories

15385AZT

OptionalLensAccessories

15385AZT

PhotometricData

Test Data

thanks

Hi
I am converting to xml to pdf. then empty pdf crated but no xml content there .please someone help me . i am using in java .

@Ajeet2018

Thanks for contacting support.

Would you please share your sample XML file with us. We will test the scenario in our environment and address it accordingly. However, before sharing the file, please make sure that it follows the element sequence provided in XML Schema of Aspose.PDF.