简体   繁体   中英

Convert html to pdf automatically using ASPOSE in Java

I am trying to convert html to pdf using aspose,also i have to use PageSize A1,A2,A3,A4 .this is worked perfectly..but i dont want set pagesize for pdf generation.So far i have tried below code

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);

htmloptions.getPageInfo().setWidth(PageSize.getA2().getWidth());
htmloptions.getPageInfo().setHeight(PageSize.getA2().getHeight());

// Load HTML file
Document doc = new Document(basePath + "400010_DOC002_L_10_2508016.html", htmloptions);
// Save HTML file

doc.save("D:/Web+URL_output.pdf");

Can anyone suggest with out set page size i have convert html to pdf conversion ? or else please let me know what tools are available for this. Please let me know any other tools for this conversion.

@Shankar, you may use the below code sample in order to convert an HTML file to a PDF file without setting page size. By default, the page size of the rendered PDF file will be as of the A4 page size.

Simply omit the code which is setting a page size, else remains the same.

        HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);

        // Load HTML file
        Document doc = new Document(basePath + "400010_DOC002_L_10_2508016.html", htmloptions);

        // Save HTML file
        doc.save("D:/Web+URL_output.pdf");

Please let us know if you need any further assistance. I work with Aspose as Developer Evangelist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM