Hi,
I try to convert the a word document (which has page and section breaks) to PDF and it works fine.
Dynamically using Docx Documents we insert html tags into the word document and try to convert into PDF.
When I separately get the content as text and enable the “IsHtmlTagSupported=true” it works but page break and section break on the word document fails to render on PDF because we give only string as input.
FYI: We use Aspose 8.5 version dlls.
/
I know we can directly convert a document into PDF but there is no option to enable
HTML tags when we do that.
So tried to convert the document into html file and read the content then converted into PDF
after enabling IsHtmlTagSupported = true.
Since we do not manipulate every line we were not using Aspose snippets as mentioned below.
https://docs.aspose.com/words/net/supported-features-on-document-load/
/
Question:-
Is there a way to pass entire document as stream having HTML tags into the following line instead of a piece of string?
“Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(doc1.GetText());”
Full Code Snippet as follows:
string dataDir = @"D:\testPdf";
//Save the document as HTML file
Aspose.Words.Document doc = new Aspose.Words.Document(dataDir + “Test.docx”);
doc.Save(dataDir+“out.html”);
//Convert to PDF from HTML File - Here No option to enable HTML tags
Aspose.Words.Document doc1 = new Aspose.Words.Document(dataDir + “out.html”);
doc1.SaveOptions.ExportPrettyFormat = true;
doc1.Save(dataDir + “Html_File_to_Pdf.pdf”);
//Convert HTML File to PDF - Here we can enable HTML tags but can send only text
//not the entire file as stream
Aspose.Words.Document doc2 = new Aspose.Words.Document(dataDir + “out.html”);
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(doc2.GetText());
text2.IsHtmlTagSupported = true;
sec1.Paragraphs.Add(text2);
pdf1.Save(dataDir + “html_enabled_pdf.pdf”);
Thank you!
Regards,
Vijay
Hi Vijay,
Thank you for your reply!
I am analyzing on this.
Regards,
Vijay