Extract pages from prepared report to new prepared report
I would like to extract prepared pages from an fpx file, to either save to a new fpx stream/file or present in a viewer. The use case is extracting a specific user's invoice from a batch of invoices. I know which pages through report indexing.
Currently I do this with reports saved as PDF, but fpx files are much more compact and faster. I tried these ways below with a valid input fpx and page numbers. When I try to open the resulting fpx file, either the previewer doesn't open or it throws an exception. Speed is very important. What is best code to achieve this?
Currently I do this with reports saved as PDF, but fpx files are much more compact and faster. I tried these ways below with a valid input fpx and page numbers. When I try to open the resulting fpx file, either the previewer doesn't open or it throws an exception. Speed is very important. What is best code to achieve this?
        var report = new Report();
        report.LoadPrepared(@"E:\test.fpx");  //has 104 pages
        var subReport = GetPreparedPages(report, new[] { 55, 56});
    private static Report GetPreparedPages(Report report, int[] pageNumbers)
    {
        var report2 = new Report();
        report2.Prepare();
        foreach (var pageNumber in pageNumbers)
        {
            var page = report.PreparedPages.GetPage(pageNumber);
            report2.PreparedPages.AddPage(page);
            //report2.PreparedPages.AddPage(new ReportPage());
            //report2.PreparedPages.ModifyPage(report2.PreparedPages.Count - 1, page);
        }
        return report2;
    }
    private static Report GetPreparedPages2(Report report, int[] pageNumbers)
    {
        var report2 = new Report();
        report2.Pages.AddRange(pageNumbers.Select(pn => new ReportPage()).ToArray());
        report2.Prepare();
       Â
        for(var pn = 0; pn < report2.PreparedPages.Count; pn++)
        {
            var page = report.PreparedPages.GetPage(pageNumbers[pn]);
            report2.PreparedPages.ModifyPage(pn,page);
        }
        return report2;
    }
Comments
The fpx has a document outline. When the pages are removed, the outline remains and the invalid links raise an exception. Is there a way to either remove the invalid links or even remove the outline altogether?
This also answers another question I had about the fpx file format (xml & gzip).