PDF.BindXML creating empty/blank PDF file

Hi


I am trying to create a PDF file using the PDF.BindXml method. I am passing it two Memory streams, one for the XML file and the other for the XSLT. When I run the code I do not receive any errors and it creates a PDF file. However, that PDF file that it creates is just a blank document. Below is the code I am running and I have also attached a zip file with the XML and XSLT files. I am currently using the Aspose 8.5.0 version.

Code:
private void ConvertXmlXsltToPDF(MemoryStream msXml, MemoryStream msXslt)
{
msXslt.Position = 0;
msXml.Position = 0;

aGenPDF.Pdf pdfNew = new aGenPDF.Pdf();
pdfNew.BindXML(msXml, msXslt);

pdfNew.Save(@“C:\temp\xml\test.pdf”);
}


Thanks

Arthur

Hi Arthur,

We are sorry for the inconvenience faced. While testing the scenario with Aspose.Pdf for NET 8.5.0, we've managed to reproduce this issue on our side and logged it as PDFNEWNET-35985 in our bug tracking system for further investigation and resolution. We've also linked your request to this issue and you will be notified via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,

Tilal


Curious if you have a time frame on when any additional information will be available or the issue will be resolved? This is for a project that we have a deadline for and this is a key part of the project.

Thanks for all your help.

Arthur

Hi Arthur,


Thanks for your inquiry. I’m afraid we can’t share any timelines at the moment, as we have recently noticed the issue and its investigation is pending in the queue with other priority tasks. However we have recorded your concerns and requested our development team to investigate the issue and share an ETA at their earliest. We will update you as soon as we get a feedback.

Thanks for your patience and cooperation.

Best Regards,

Hi Arthur,


Thanks for your patience.

We have further investigated the issue PDFNEWNET-35985 reported earlier and it does not seem to be an issue with Aspose.Pdf for .NET. Please note that BindXML expects that summery XML that it will get after applying XSLT to that supplied XML, will contain special tags related to PDF document object model. Something like this XML must be generated after translation.

[XML]

<?xml version="1.0" encoding="utf-8" ?><o:p></o:p>

<Pdf xmlns="Aspose.Pdf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Aspose.Pdf

C:\PROGRA~1\Aspose\ASPOSE~1.NET\Xml\Aspose.Pdf.xsd" DestinationType="FitPage">

<Section ID="section1" PageMarginLeft="1cm" PageMarginRight="1cm" PageMarginTop="4.5cm" PageMarginBottom="3.5cm" PageSize="A4">

<PageBorder>

<All BorderStyle="Normal"></All>

</PageBorder>

<Image ID="id1" File="PDFNET-15770-1.gif" Type="Gif" FixHeight="5cm" FixWidth="15cm" Alignment="Center" MarginTop="1cm"></Image>

<Image ID="id2" File="PDFNET-15770-2.gif" Type="Gif" FixHeight="10cm" FixWidth="15cm" Alignment="Center" MarginTop="1cm"></Image>

<Text MarginLeft="2cm" MarginRight="2cm" FontName="Arial" MarginTop="1cm">

<TextBorder>

<All BorderStyle="Normal"></All>

</TextBorder>

<Segment IsTrueTypeFontBold="true" FontSize="12">Commentaires :#$NL</Segment>

<Segment>

dsfk mkf mskdf skdfm skdf ldkf mslkfd smdfkms dfkmkf;koki mslmkf mkmfk mlkf lkf mkmsfk l kmfksmfmskf ifmks lkfm smkmfk s#$NL

sdfjfhsdfhdsjf lkf fjslkfd ljflskdfpokmlkrt dmlfkger lkvgdhjh fhkjhdhfyez ajd s#$NL

sdfjfhsdfhdsjf lkf fjslkfd ljflskdfpokmlkrt dmlfkger lkvgdhjh fhkjhdhfyez ajd s#$NL

sdfjfhsdfhdsjf lkf fjslkfd ljflskdfpokmlkrt dmlfkger lkvgdhjh fhkjhdhfyez ajd s#$NL

sdfjfhsdfhdsjf lkf fjslkfd ljflskdfpokmlkrt dmlfkger lkvgdhjh fhkjhdhfyez ajd s#$NL

sdfjfhsdfhdsjf lkf fjslkfd ljflskdfpokmlkrt dmlfkger lkvgdhjh fhkjhdhfye#$NL

</Segment>

</Text>

<Image ID="id3" File="PDFNET-15770-3.gif" Type="Gif" FixHeight="10cm" FixWidth="15cm" Alignment="Center" MarginTop="1cm"></Image>

<Image ID="id4" File="PDFNET-15770-4.gif" Type="Gif" FixHeight="10cm" FixWidth="15cm" Alignment="Center" MarginTop="1cm"></Image>

</Section>

</Pdf>


However, as we can see from set of sample files, customer's set of XML+XSLT generates HTML, that will not (and should not) be correctly processed with BingXML method. Please get HTML from XML + XSLT and then use BindHTML method to get desired results.

Hi codewarior,

As per my requirement I have to take data from XML and use custom XSL to generate PDF Which I am able to do with first approach but not using second approach.

I have tried as below post

To generate the PDF, I have tried 2 approaches-

  1. Transformed XML data with XSL and converted into HTML then Using Aspose.HTML, converted HTML to PDF(It’s working as expected using same .xml and .xsl files)

  2. When I am trying to use Aspose.PDF please check below code. Pdf is generating and is not opening because it’s blank pdf. Even I have used same xml which suggested by Farhan (Programmers Guide)
    and try to generate PDF using XML only it’s generating BLANK PDF.

If XML schema is not proper in attached snapshot please share the updated valid XML so I can use below code for my requirement.2.PNG (8.6 KB)

Document pdf = new Document();

        using (FileStream fs1 = new FileStream(xmlpath + "Examples.xml", FileMode.Open))
        using (FileStream fs2 = new FileStream(xmlpath + "Examples.xsl", FileMode.Open))
        {
            // Bind the XML file
            pdf.BindXml(fs1, fs2);
            // Save the resultant PDF
            pdf.Save(xmlpath + "Examples.pdf");
        }

I am achieving requirement using first approach but I don’t have ASPOSE.Html lic but I have for ASPOSE.Pdf.lic

Thanks in advance

@jitendrapatil2514

We have addressed your concerns in other thread created by you. Kindly follow up in respective thread.

Thank you so much for help.