Free Support Forum - aspose.com

While converting html to pdf- html controls are printed twice in pdf

Hi,


I am generating html string from the current page(in C#.net) and I want to generate pdf from that string.
I have tried this from 2 ways :
1. Generated HTML / HTM file from that string and tried to convert it into pdf.
2. Fed that string to Aspose.Pdf.Generator.Text object as an input.
In both ways, I am getting same pdf.
The issues I am facing are -
1. The controls are repeating (getting printed 2 times) in the pdf.
2. On 1st page, I am not getting radio buttons that are on html page.(I am getting radio buttons on 2nd page).
I have checked the html string is correct by saving the page as .html. Also the same string is generating correct pdf by using some other pdf generator tool.

I am using latest version of aspose.

I have attached sample file with test data.

Thanks




Hi Rucha,


Thanks for using our products.

Can you please share the source HTML so that we can test the conversion at our end. We are really sorry for this inconvenience.

Hi,


Please find PrintPage.txt - Source code for PrintPage.html. I am writing html - string into .html file and then trying to convert it into pdf.

This is the code :

TextWriter tsw = new StreamWriter(@“C:\Documents and Settings\RuchaD\Desktop\PrintPage.html”);
tsw.WriteLine(html);
tsw.Close();


Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

section.PageInfo.Margin.Left = 0;
section.PageInfo.Margin.Right = 0;
section.PageInfo.Margin.Bottom = 0;
section.PageInfo.Margin.Top = 0;

section.PageInfo.PageWidth = 800;
section.PageInfo.PageHeight = 1000;

section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterHeight;
section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;

StreamReader r = File.OpenText(@“C:\Documents and Settings\RuchaD\Desktop\PrintPage.html”);
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(r.ReadToEnd());

text2.IsHtmlTagSupported = true;
section.Paragraphs.Add(text2);

string fileName1 = “Form” + System.DateTime.Now.ToString(“yyyyMMddHHmmss”);
fileName1 = “D:/pdftest/” + fileName1 + “.pdf”;
pdf.Save(fileName1);

Also can you suggest any page layout, to fit this html page into appropriate pdf page ?

Thanks,
Rucha

Hi Rucha,


Thanks for sharing the resource file.

I
have tested the scenario and I am able to reproduce the same problem that controls are appearing twice on resultant PDF file. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-35760. We
will investigate this issue in details and will keep you updated on the status
of a correction. <o:p></o:p>

We apologize for your inconvenience.

Hi Nayyer,


Any updates from your side ?

Can you suggest any other way to generate pdf from the input HTML string ? Please reply ASAP.

Thanks,
Rucha

damlerucha2:
Any updates from your side ?
Hi Rucha,

Since we recently have been able to notice this issue, and until
or unless we have investigated and have figured out the actual reasons of this
problem, we might not be able to share any timelines by which this problem will
be resolved.<o:p></o:p>

However, as soon as we have made some significant progress towards the resolution of this issue, we would be more than happy to update you with the status of correction. Please be patient and spare us little time. Your patience and comprehension is greatly appreciated in this regard.


damlerucha2:
Can you suggest any other way to generate pdf from the input HTML string ?
Currently Aspose.Pdf.Generator supports the capability to transform HTML files to PDF format. However, you may also consider using Aspose.Words for .NET which provides the capability to create and manipulate MS Word files. It also offers the feature to read HTML files and save the output as either DOC/DOCX or PDF format. My fellow worker from respective team will share further details regarding this component.

Hi Rucha,


Thanks for your inquiry. You can convert html to Pdf file format by using Aspose.Words. Please use the following code snippet to convert your html to Pdf.

Document doc = new Document(MyDir

  • “in.html”);<o:p></o:p>

doc.Save(MyDir + "Out.pdf");


Moreover, upon processing HTML, some features of HTML might be lost. You can find a list of limitations upon HTML exporting/importing here:
http://www.aspose.com/docs/display/wordsnet/Load+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format
http://www.aspose.com/docs/display/wordsnet/Save+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format

Hope this helps you. Please let us know if you have any more queries.

Hi Rucha,


Further to my last post, I have noticed that your input html contain the form fields (TextInput and DropDown) which do not export in output Pdf. I have logged this issue as WORDSNET-8874 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Moreover, Form fields are fully supported by Aspose.Words.There is an option to export form fields as dynamic fields in HTML as and tags or to export them as plain text.

Only and tags are imported back as fields. The input types that have direct Microsoft Word analogs are imported as working form fields.

Radio and image input elements are imported as image shapes and are non-clickable. Input elements attributed with hidden or disabled are not imported.

Hi Nayyer and Tahir,


Thanks for your reply.

I tried your code.

Document doc = new Document(MyDir + “in.html”);
doc.Save(MyDir + “Out.pdf”);

But its not working for my code. Its printing .doc in correct format, but its pdf is not as per required format.

Thanks,
Rucha

Hi Rucha,


Thanks for your inquiry. I have already logged the same issue as WORDSNET-8874 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi


Can you provide any update ?

Thanks,
Rucha

damlerucha2:
Can you provide any update ?
Hi Rucha,

Thanks for your patience.

The development team has been busy resolving other priority issues and I am afraid the above stated problem is not yet resolved. Nevertheless, as soon as we have some further updates regarding its resolution, we would be more than happy to update you with the status of correction. Please be patient and spare us little time.

We are sorry for this delay and inconvenience.

Hi Rucha,


damlerucha2:
Can you provide any update ?
Thanks for your inquiry. I have verified the status of your issue WORDSNET-8874 from our issue tracking system and like to share with you that your issue is pending for analysis and is in the queue. I am afraid, I cannot provide you any reliable estimate at the moment. Once your issue is analyzed, we will then be able to provide you an estimate.

Thank you for your patience and understanding.

Hi Rucha,

Regarding WORDSNET-8874, I like to share with you that we have pointed two issues in output PDF file. Following are the detail.

WORDSNET-9258 : The checkbox position is incorrect after conversion from HTML to Pdf
WORDSNET-9259 : HTML Button tag does not export correctly in output PDF

Please see the attached images for the detail of these issue. We will update you via this forum thread once these issues are resolved. Thanks for your patience.

The issues you have found earlier (filed as WORDSNET-9258) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as PDFNET-35760) have been fixed in Aspose.PDF for .NET 20.1.