This is a migrated thread and some comments may be shown as answers.

Include pdf/pictures attachment to final pdf

1 Answer 151 Views
ClientExportManager
This is a migrated thread and some comments may be shown as answers.
Grégory
Top achievements
Rank 1
Grégory asked on 31 Jan 2018, 08:24 AM

Hi,

 

I'm trying to generate a full report as a single pdf and I'm wondering if it's possible to add for example an existing pdf file between 2 pages of the pdf rendered ?

Should I find a way to render the pdf on a view page using third party js libraries for pdf rendering or is there a way to do this using only this component ?

 

Thanks,

1 Answer, 1 is accepted

Sort by
0
Grégory
Top achievements
Rank 1
answered on 31 Jan 2018, 01:55 PM

My report has 8 parts, each parts can have photos and pdf, I thought pictures would have been easier as I just have to print them but I have another problem that I don't really understand.

I create a new PageView in my Page_Load only if there's any picture to add using this code:

if (M_Attachment.hasPictureAttachmentForSample(_sample.Id, "Shadowgraph"))
{
     RadPageView _pageView = new RadPageView();
     _pageView.ID = "ShadowgraphAttachment";
                 
     RadMultiPage1.PageViews.AddAt(RadMultiPage1.PageViews.IndexOf(RadMultiPage1.FindControl("ShadowGraphPage")) + 1, _pageView);
}

 

And this:

protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
    if (e.PageView.ID == "ShadowgraphAttachment")
    {
        List<M_Attachment> _lists = M_Attachment.getAttachmentForSample(_sample.Id, "Shadowgraph");
 
        e.PageView.CssClass = "pagebreak AttachmentPicturePage pageExport";
 
        #region Génération header div
        HtmlGenericControl _headerDiv = new HtmlGenericControl("div");
        _headerDiv.Attributes.Add("class", "export_pageHeader centerContent");
        HtmlImage _logoHeader = new HtmlImage();
        _logoHeader.Attributes.Add("class", "headerLogo");
        _logoHeader.Src = "../../Images/Logo_new.png";
        _headerDiv.Controls.Add(_logoHeader);
        e.PageView.Controls.Add(_headerDiv);
        #endregion
 
        #region Génération content div
        HtmlGenericControl _contentDiv = new HtmlGenericControl("div");
        _contentDiv.Attributes.Add("class", "export_pageContent");
        HtmlGenericControl _contentH2Title = new HtmlGenericControl("h2");
        _contentH2Title.Attributes.Add("class", "SectionTitle");
        _contentDiv.Controls.Add(_contentH2Title);
        #region Ajout des images
        foreach (M_Attachment _picture in _lists)
        {
            Image pic = new Image();
            pic.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(_picture.Attached_File);
            _contentDiv.Controls.Add(pic);
        }
        #endregion
        e.PageView.Controls.Add(_contentDiv);
        #endregion
    }
}

 

When I try to export my page, all my page that I exported by setting them in .aspx works fine but this one I cerated, doesn't appear on the pdf. HOWEVER this pageview is present on the web page opened while generating the pdf.

My 2 previous code parts are working fine, but the pdf seems to take only .aspx radpageview.

I also link some parts of the aspx that can be usefuls:

<telerik:RadClientExportManager runat="server" ID="RadClientExportManager1">
    <PdfSettings PageBreakSelector=".pageBreak" MarginRight="10mm" PaperSize="A4" Landscape="false" MarginBottom="10mm" MarginTop="10mm" MarginLeft="10mm" />
</telerik:RadClientExportManager>
<telerik:RadTabStrip ID="tabstrip" runat="server" MultiPageID="RadMultiPage1">
    <Tabs>
        <telerik:RadTab Text="Main"></telerik:RadTab>
        <telerik:RadTab Text="Summary"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
        <telerik:RadTab Text="Content1"></telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="1" CssClass="innerMultiPage" Width="535px" Height="850px" OnPageViewCreated="RadMultiPage1_PageViewCreated">

 

</telerik:RadMultiPage>
<script type="text/javascript">
    var $ = $telerik.$;
 
    $(function () {
        var cem = $find("<%=RadClientExportManager1.ClientID%>");
 
        cem.exportPDF($telerik.$(".innerMultiPage"));
    })
</script>
Tags
ClientExportManager
Asked by
Grégory
Top achievements
Rank 1
Answers by
Grégory
Top achievements
Rank 1
Share this question
or