BaseUri and Local files

Last post 12-08-2011, 11:43 AM by alexey.noskov. 4 replies.
Sort Posts: Previous Next
  •  12-08-2011, 3:44 AM 347765

    BaseUri and Local files

    Hi

    I'm currently evaluating the aspose componente for converting HTML Files to pdf

    I read the HTML from the database from this html source (string) I generat PDF Files.

    Now this HTML contains img tags . this image tags have relative file pathes for exmaple like this

    <img width="991" height="296" id="_x0000_i1027" src="13000360/13000349/abc.0112360088.0112152959.jpg">

    the file is located unter C:\images\13000360\13000349\abc.0112360088.0112152959.jpg

    What should I do so that the files is included in the pdf ?
    How should I set the basepath ?
    Unfortunately the image path in the uri tag contains a Slash / not a Backslash \ like normal für file pathes. do I have to do some convesion logic ?

    --
     
  •  12-08-2011, 4:01 AM 347776 in reply to 347765

    Re: BaseUri and Local files

    Hi

     

    Thanks for your request. You should simply specify baseUri upon loading your HTML documents:

    http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.loadoptionsconstructor3.html

     

    Hope this helps.

     

    Best regards,


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  12-08-2011, 4:10 AM 347781 in reply to 347776

    Re: BaseUri and Local files

    Hi

    sorry I can't figure out how this should be formatted?

    If my folder is C:\images

    It doesn't work to set "C:\images" as baseuri.
    I also tried to the the base Uri to file:///C:/images

    I'm assuming i should write the path in a other format?


    Here my SourceCode

    string htmlSource = File.ReadAllText(@"C:\temp\BildMail.HTML");
                byte[] data = Encoding.Default.GetBytes(htmlSource);
     
                
                using (MemoryStream sourceStream = new MemoryStream(data))
                {
                    LoadOptions htmlLoadOptions = new LoadOptions(LoadFormat.Html, "",  @"C:\images");
                    Document doc = new Document(sourceStream);
     
                    doc.Save(@"C:\temp\bild.pdf"SaveFormat.Pdf);
                }

    Here the Html source

    <html >
    <body lang="DE" link="blue" vlink="purple">
    <img width="991" height="296" id="_x0000_i1027" src="myimage.jpg">
    </body>
    </html>


    the image is located in C:\images



    Now I've put the html and image file in the same folder. And exporting still doesn't incluide the image. There I set the basepath to an empty string.
    When I double click the HTML File, i can see the image in the browser

    --
     
  •  12-08-2011, 4:41 AM 347793 in reply to 347781

    Re: BaseUri and Local files

    Sorry my dubmness.

    I didn't pass the loadoptions to the load method.....

    --
     
  •  12-08-2011, 11:43 AM 347927 in reply to 347793

    Re: BaseUri and Local files

    Hi 

     

    It is perfect that you managed to resolve the problem. Please let me know if you need more assistance, I will be glad to help you.

     

    Best regards,


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML