We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

New Aspose.pdf

Our order id is 180115093517
we are trying to use new version of aspose.pdf ,can you let us know the alternate code for old Aspose.Pdf.Generator and InteractiveFeatures property missing

using Rectangle = Aspose.Pdf.Rectangle;

case “tiff”:
{
try
{
var pdfDoc = new Aspose.Pdf.Generator.Pdf();
var pdfSection = pdfDoc.Sections.Add();
pdfSection.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;
pdfSection.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;
pdfSection.PageInfo.Margin = new Aspose.Pdf.Generator.MarginInfo();

                        var pdfImage = new Aspose.Pdf.Generator.Image(pdfSection);
                        pdfImage.ImageInfo.File = fileName;
                        pdfImage.ImageInfo.ImageFileType = GetImageSaveFormat(fileExtn);
                        pdfSection.Paragraphs.Add(pdfImage);

                        using (var wrt = File.OpenWrite(newFileName))
                        {
                            pdfDoc.Save(wrt);
                            File.Delete(fileName);
                        }
                    }
                    catch (Exception)
                    {
                        throw new Exception("Conversion failed for file type '" + fileExtn + "'.");
                    }
                }
                break;



 case "txt":
                {
                    var pdfDoc = new Aspose.Pdf.Generator.Pdf();
                    var pdfSection = pdfDoc.Sections.Add();
                    pdfSection.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;
                    pdfSection.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;

                    using (var rdr = File.OpenText(fileName))
                    {
                        var pdfText = new Aspose.Pdf.Generator.Text(pdfSection, rdr.ReadToEnd());
                        pdfSection.Paragraphs.Add(pdfText);
                    }

                    pdfDoc.Save(newFileName);
                    File.Delete(fileName);
                }
                break;

private static Aspose.Pdf.Generator.ImageFileType GetImageSaveFormat(string fileType)
{
switch (fileType)
{
case “bmp”:
return Aspose.Pdf.Generator.ImageFileType.Bmp;
case “gif”:
return Aspose.Pdf.Generator.ImageFileType.Gif;
case “jpe”:
case “jpeg”:
case “jpg”:
return Aspose.Pdf.Generator.ImageFileType.Jpeg;
case “png”:
return Aspose.Pdf.Generator.ImageFileType.Png;
case “tif”:
case “tiff”:
return Aspose.Pdf.Generator.ImageFileType.Tiff;
default:
return Aspose.Pdf.Generator.ImageFileType.Unknown;
}
}

var bookmark = new Aspose.Pdf.OutlineItemCollection(pdfDocument.Outlines);
bookmark.Title = bookmarkTitle;
bookmark.Action = new Aspose.Pdf.InteractiveFeatures.GoToAction(pdfDocument.Pages[pageNum]);

@philip.thomas

Thank you for contacting support.

Please note that latest version of Aspose.PDF for .NET API uses Pages instead of Sections so you may add a page to a PDF document by calling Add method. Moreover, the classes which were present under InteractiveFeatures, Annotations for instance, are now present under Aspose.Pdf.Annotations namespace instead of Aspose.Pdf.InteractiveFeatures.Annotations.

Moreover, Height of a page can be set as under:

Document document = new Document();
Page page = document.Pages.Add();
page.PageInfo.Width = PageSize.PageLetter.Width;
page.PageInfo.Margin = new MarginInfo(72, 72, 72, 72);
//OR
page.PageInfo.Margin.Left = 72;

Furthermore, you may visit below documentation articles for your kind reference.

For adding bookmarks you may use below code snippet as per your requirements.

var pdfDocument = new Document();
Page page = pdfDocument.Pages.Add();
var bookmark = new Aspose.Pdf.OutlineItemCollection(pdfDocument.Outlines);
bookmark.Title = "bookmarkTitle";
bookmark.Action = new GoToAction(pdfDocument.Pages[page.Number]);

We hope this will be helpful. Please feel free to contact us if you need any further assistance.