Hi,
Really I dont know under whcih category I have to post this query.
I want to convert the plain text to PDF/TIFF using Aspose. Please share if any sample code available.
Thanks,
Ponraj.M
Hi,
Really I dont know under whcih category I have to post this query.
I want to convert the plain text to PDF/TIFF using Aspose. Please share if any sample code available.
Thanks,
Ponraj.M
Hi Ponraj,
// Read whole txt file into string.<o:p></o:p>
string txt = File.ReadAllText(“in.txt”);<o:p></o:p>
// Insert string into document.<o:p></o:p>
DocumentBuilder builder = new DocumentBuilder();<o:p></o:p>
builder.Write(txt);<o:p></o:p>
// Save output.<o:p></o:p>
builder.Document.Save(“out.pdf”);
builder.Document.Save(“out.tiff”);
Hi Ponraj,
loadOptions.LoadFormat = LoadFormat.Text;
Document doc = new Document(@"C:\Temp\input.txt", loadOptions);
http://www.aspose.com/docs/display/wordsnet/ImageSaveOptions+Class
Thanks for your sample code. It is working fine.
Now I could able to save file as Multipage TIFF/PDF. Is it possible to save the file as Searilized TIFF/PDF. For example if the palin text exceeds more than one page it should automatically save as seperate files.
loadOptions.LoadFormat = LoadFormat.Text;
Thanks for the updates.
Now if I want to save only the Speaker Notes as PDF, I have use Apose.Slides to extract the notes then I have to use Aspose.words to save the text DocumentBuilder to convert to PDF. I lost all the formats which I applied for Notes. For example font style,name,size etc.
Kindly let me know is there any way to save the notes with the actual format which I applied for notes in PPT,even by using aspose.words is OK for me.
Also Is there any direct method to split the Slides and Notes to PDF/TIFF without using Aspose.words.
Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation(MyDir + "in.ppt");
//Access the first slide
Aspose.Slides.Slide sld = pres.Slides[0];
//Creating Slide note instance
Aspose.Slides.Notes note = sld.Notes;
Aspose.Slides.FontEntity noteFont = pres.Fonts[sld.Notes.Paragraphs[0].Portions[0].FontIndex];
// Insert string into document.
DocumentBuilder builder = new DocumentBuilder();
builder.Font.Name = noteFont.FontName;
builder.Font.Size = sld.Notes.Paragraphs[0].Portions[0].FontHeight;
builder.Font.Bold = sld.Notes.Paragraphs[0].Portions[0].FontBold;
builder.Font.Italic = sld.Notes.Paragraphs[0].Portions[0].FontItalic;
builder.Write(note.Text);
// Save output.
builder.Document.Save(MyDir + "out.pdf");
builder.Document.Save(MyDir + "out.tiff");
Hi ,
I tried with the above code. I'm facing an issue like I have 2 lines Bold and 2 lines Italic an d 2 lines underline..But its applying only Bold all the 4 lines of text...it is not applying Italic and Underline....its because of evalution vrsion..
I guess its not generic...if I apply bold it will apply to all the text in that notes...
pls let me know how to attach the sample file.
Also kindly let me know whther all the formats of MS slide notes are supported by Aspose?
// Insert string into document.
DocumentBuilder builder = new DocumentBuilder();
Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation(MyDir + "in.ppt");
//Access the first slide
Aspose.Slides.Slide sld = pres.Slides[0];
//Creating Slide note instance
Aspose.Slides.Notes note = sld.Notes;
//Iterate through all slides
foreach (Aspose.Slides.Slide slide in pres.Slides)
{
//Iterate through all note's Paragraphs
foreach (Aspose.Slides.Paragraph notePara in slide.Notes.Paragraphs)
{
//Iterate through all Portion
foreach (Aspose.Slides.Portion portion in notePara.Portions)
{
Aspose.Slides.FontEntity noteFont = pres.Fonts[portion.FontIndex];
builder.Font.Name = noteFont.FontName;
builder.Font.Size = portion.FontHeight;
builder.Font.Bold = portion.FontBold;
builder.Font.Italic = portion.FontItalic;
builder.Write(note.Text);
}
}
}
// Save output.
builder.Document.Save(MyDir + "out.pdf");
ponrajcm:
Also kindly let me know whther all the formats of MS slide notes are supported by Aspose?
ponrajcm:
pls let me know how to attach the sample file.
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.
Hi Ponraj,
public static void GetPptxFont(){Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(MyDir + “in.pptx”);// Insert string into document.DocumentBuilder builder = new DocumentBuilder();Aspose.Slides.Pptx.NotesSlideEx note;foreach (SlideEx sld in pres.Slides){//Getting notes slidesnote = sld.NotesSlide;if (note != null){builder.Write(“Slide Notes for Slide:” +sld.SlideNumber.ToString()+"\n\n");foreach (ShapeEx shape in note.Shapes){if (shape is AutoShapeEx){AutoShapeEx ashp = (AutoShapeEx)shape;if (ashp.TextFrame != null){foreach (ParagraphEx para in ashp.TextFrame){foreach (PortionEx portion in para.Portions){FontDataEx noteFont = portion.PortionFormat.LatinFont;builder.Font.Name = noteFont.FontName;builder.Font.Size = portion.PortionFormat.FontHeight;builder.Font.Bold = portion.PortionFormat.FontBold;builder.Font.Italic = portion.PortionFormat.FontItalic;}}}}}}//End if}//End for// Save output.builder.Document.Save(MyDir + “out.pdf”);builder.Document.Save(MyDir + “out.tiff”);}
Thanks for your response.
Let me explain clearly. I have attached the 2 sample file with 2 slides. One with normal format and another one with NotesPage format.
I want to save only the notes of 2 files and not the slide as a seperate pdf/tiff file . The format which I have applied should be reflected same in PDF/TIFF.
Kindly let me know if you have any questions.
Hi Ponraj,
Thanks for sharing the details. First of all, please note that Aspose.Words tries to mimic the same behavior as MS Word do. Please read Aspose.Words LoadFormat and SaveFormat form following documentation links.
Moreover, Microsoft Word and Microsoft PowerPoint documents are completely different file formats. So, it is hard to achieve exact requirements with 100% fidelity. However, you can extract note’s detail by using Aspose.Slides and write these notes into MS Word/Pdf document by using Aspose.Words. Pleas use the following code snippet read following documentation links for your kind reference.
Aspose.Slides.Presentation pres = new
Aspose.Slides.Presentation(MyDir + “Sample_NotesPage.ppt”);
// Insert string into document.
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder();
Aspose.Slides.Notes note;
Aspose.Slides.FontEntity noteFont;
foreach (Aspose.Slides.Slide sld in pres.Slides)
{
//Getting notes slides
note = sld.Notes;
if (note != null)
{
builder.Write("Slide Notes for Slide:" + sld.SlidePosition.ToString() + "\n\n");
foreach (Aspose.Slides.Shape shape in note.Shapes)
{
if (shape.TextFrame != null)
{
foreach (Aspose.Slides.Paragraph para in shape.TextFrame.Paragraphs)
{
//Set list formats
if (para.HasBullet && builder.ListFormat.List == null)
{
if (para.NumberedBulletStyle == Aspose.Slides.NumberedBulletStyle.BulletRomanLCPeriod)
builder.ListFormat.List = builder.Document.Lists.Add(ListTemplate.NumberLowercaseRomanDot);
else if (para.NumberedBulletStyle == Aspose.Slides.NumberedBulletStyle.BulletArabicPeriod)
builder.ListFormat.List = builder.Document.Lists.Add(ListTemplate.BulletSquare);
}
foreach (Aspose.Slides.Portion portion in para.Portions)
{
noteFont = pres.Fonts[portion.FontIndex];
builder.Font.Name = noteFont.FontName;
builder.Font.Size = portion.FontHeight;
builder.Font.Bold = portion.FontBold;
builder.Font.Italic = portion.FontItalic;
builder.Font.Color = portion.FontColor;
if (portion.FontUnderline)
builder.Font.Underline = Aspose.Words.Underline.Single;
else
builder.Font.Underline = Underline.None;
builder.Write(portion.Text);
}
builder.Writeln();
}
}
}
}//End if
builder.ParagraphFormat.ClearFormatting();
}//End for
// Save output.
builder.Document.Save(MyDir + "outWord.docx");
builder.Document.Save(MyDir + "outWord.pdf");
Hope this helps you. Please let us know if you have any more queries.
Thanks for your response. Your code is working perfect. But some * symbol is coming at the end of the document.
Is ther any way to delete or avoid this junk character..
Hi Ponraj,
Still I 'm getting the juck character at the end.(*). kindly let me know in which line you have modified in the attached file.
Hi
I have used the below code snippet to retrive the all bullets formats in MS powerpoint.
if (para.HasBullet )
{
if (para.NumberedBulletStyle == NumberedBulletStyle.BulletRomanLCPeriod)
builder.ListFormat.List = builder.Document.Lists.Add(ListTemplate.NumberLowercaseRomanDot);
else if (para.NumberedBulletStyle == NumberedBulletStyle.BulletArabicPeriod)
builder.ListFormat.List = builder.Document.Lists.Add(ListTemplate.BulletSquare);
}
During run time I could able to get BulletArabicPeriod as bullet type for all type of bullets attached in the file.
Please let me know how to get the equivalent MS PPT bullet in aspose.
Hi Ponraj,
Ok Thanks. Meanwhile can you please let me know in which line of code you have modified for removing the junk character(*) in the attached note file.
Hi Ponraj,
<span style=“font-size:
10.0pt;font-family:“Courier New”;color:blue;background:yellow;mso-highlight:
yellow;mso-no-proof:yes”>if<span style=“font-size:10.0pt;font-family:
“Courier New”;background:yellow;mso-highlight:yellow;mso-no-proof:yes”>
(portion.Field == null)<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”><o:p></o:p>
{
noteFont = pres.Fonts[portion.FontIndex];
builder.Font.Name = noteFont.FontName;
builder.Font.Size = portion.FontHeight;
builder.Font.Bold = portion.FontBold;
builder.Font.Italic = portion.FontItalic;
builder.Font.Color = portion.FontColor;
if (portion.FontUnderline)
builder.Font.Underline = Aspose.Words.Underline.Single;
else
builder.Font.Underline = Underline.None;
builder.Write(portion.Text);
}
Thanks! It is working fine.
Any updates about Bullets and Numbering format.