Hi Vishnu,
We don't have direct support for this option. However, we can work around this by creating new document which contains the first page of the original document. Now convert this first page document to HTML then convert this page to PDF document. Please refers to the below code snippet to do so:
WordDocument doc = new WordDocument(@"..\..\Doc to HTML.doc");
WordDocument doc1 = new WordDocument();
doc1.EnsureMinimal();
int flag = 0;
foreach (Entity ent in doc.ChildEntities)
{
if (ent is WSection)
{
WSection section = ent as WSection;
foreach (WParagraph paragraph in section.Body.Paragraphs)
{
if (flag != 1)
{
doc1.LastSection.Paragraphs.Add(paragraph.Clone() as IWParagraph);
foreach (ParagraphItem item in paragraph.Items)
{
if (item.EntityType == EntityType.Break)
{
Break br = item as Break;
if (br.BreakType == Syncfusion.DocIO.DLS.BreakType.PageBreak)
{
MessageBox.Show("break");
flag = 1;
doc1.LastParagraph.Items.Remove(doc1.LastParagraph.Items.LastItem) ;
break;
}
}
}
}
else
break;
}
}
}
if (doc.LastSection.HeadersFooters.Header.Paragraphs.Count != 0)
doc1.LastSection.HeadersFooters.Header.Paragraphs.Add(doc.LastSection.HeadersFooters.Header.Paragraphs[0].Clone() as IWParagraph ) ;
if (doc.LastSection.HeadersFooters.Footer.Paragraphs.Count !=0)
doc1.LastSection.HeadersFooters.Footer.Paragraphs.Add(doc.LastSection.HeadersFooters.Footer.Paragraphs[0].Clone() as IWParagraph);
//doc1.Save("sample.doc");
HTMLExport htmlExport = new HTMLExport();
htmlExport.SaveAsXhtml(doc1, "doctohtml_res.html");
System.Diagnostics.Process.Start("sample.doc");
System.Diagnostics.Process.Start("doctohtml_res.html");
Please refers to the below sample:
http://websamples.syncfusion.com/samples/PDF.Windows/F78102/main.htmIn this sample I have converted one page word document to HTML, then convert this page to PDF or image.
Please let me know if this helps you.
Best Regards,
Bhuvana