Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Palle Hansen 143 posts 396 karma points
    Mar 10, 2017 @ 09:19
    Palle Hansen
    0

    PDF Creator - https

    Hi,

    I'm using your PDF Creator with a server licens, and have a question.

    Is it possible to run under https? And if so, is there anything I have to configure?

    I ask because my pdf is created just fine with images under http but then under https images is not rendered but text is.

    Can you help me with that question? I'm stuck and my pdf creator went live yesterday.

    I'm using Umb. 7.5.6

    Could any help me out?

    /Palle

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Mar 10, 2017 @ 11:23
    Darren Ferguson
    0

    Hi Palle,

    Do you have a URL?

    Could you post your template here?

    Many Thanks.

  • Palle Hansen 143 posts 396 karma points
    Mar 10, 2017 @ 11:45
    Palle Hansen
    0

    Hi Darren.

    Yeps, here's a link: https://www.engrosfaxen.dk/dagens-engrosfax?date=2017-03-10

    And here's my template: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using FergusonMoriyama.Pdf @using System.Xml @using umbraco.IO @{ Layout = null;

    Response.ContentType = "text/xsl";
    Response.AppendHeader("X-Pdf-Render", "true");
    
    // -- Uncomment this to force the browser to download the PDF.
    // Response.AppendHeader("X-Pdf-Force-Download","test.pdf");
    

    }

    @* Uncomment below to add protection to the PDF - optionally specify a password *@
    @* <ibex:security deny-print="true" deny-extract="true" deny-modify="true" user-password="" owner-password=""/> *@
    
    @* This defines a simple page layout with a heder and a footer *@
    @* See http://www.w3schools.com/xslfo/obj_layout-master-set.asp *@
    <fo:layout-master-set>
        <fo:simple-page-master master-name="master" page-width="210mm" page-height="297mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
            <fo:region-body margin-top="2.0cm" margin-bottom="1.5cm" column-count="1" column-gap="0.5cm" />
            <fo:region-before region-name="header" extent="3cm" />
            <fo:region-after region-name="footer" extent="0.7cm" />
        </fo:simple-page-master>
    </fo:layout-master-set>
    
    @* Main content starts within page sequence *@
    <fo:page-sequence master-reference="master">
    
        @* Doucment header *@
        <fo:flow flow-name="header">
            <fo:block>
                <fo:inline font-family="Arial" font-size="16pt" color="#000000">PDF NAME </fo:inline>
                <fo:block margin-top="0.3cm"></fo:block>
                <fo:external-graphic src="@Request.Form["url"]images/pdftop.png" height="0.1mm" content-width="190mm" />
            </fo:block>
    
        </fo:flow>
    
        @* Doucment footer *@
        <fo:static-content flow-name="footer">
            <fo:block font-size="8pt" color="#000000">
                <fo:block margin-top="0.3cm"></fo:block>
                <fo:external-graphic src="@Request.Form["url"]images/pdftop.png" height="0.1mm" content-width="190mm" />
                <fo:block text-align-last="center">
                    Udskrevet den @DateTime.Now.ToShortDateString()
                    <fo:block font-size="8pt" margin-bottom="0.5cm" margin-right="0.6cm" text-align="end">
                        Side <fo:page-number />
                    </fo:block>
                </fo:block>
            </fo:block>
        </fo:static-content>
    
        @* Document Body *@
        <fo:flow flow-name="xsl-region-body">
            <fo:block font-size="10pt" color="#000000">
                <fo:block-container margin-bottom="0.18cm">
                    <fo:block>
                        <fo:table width="297mm">
                            <fo:table-column column-width="38mm" />
                            <fo:table-column column-width="83mm" />
                            <fo:table-column column-width="20mm" />
                            <fo:table-column column-width="20mm" />
                            <fo:table-column column-width="30mm" />
                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                    <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                    <fo:table-cell><fo:block><fo:inline font-size="9pt" font-weight="bold">ÅR</fo:inline></fo:block></fo:table-cell>
                                    <fo:table-cell><fo:block><fo:inline font-size="9pt" font-weight="bold">KM</fo:inline></fo:block></fo:table-cell>
                                    <fo:table-cell><fo:block><fo:inline font-size="9pt" font-weight="bold">PRIS</fo:inline></fo:block></fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:block-container>
    
                @if (Request.Form["ids"] != null)
                {
                    var date = Request.QueryString["date"];
                    bool clr = true;
                    var selection = Umbraco.Content(1067).Children();
    
                    var iddecode = Decode(Request.Form["ids"]);
    
    
                    string[] ids = iddecode.ToString().Split(',');
    
    
    
                    List<string> salgs = new List<string>();
    
                    List<string> koebs = new List<string>();
    
                    List<string> stillings = new List<string>();
    
                    List<string> oevrige = new List<string>();
    
                    List<string> diverse = new List<string>();
    
                    foreach (var id in ids)
                    {
                        if (!String.IsNullOrEmpty(id))
                        {
                            if (Umbraco.Content(Convert.ToInt32(id)).wwtype == "1" || Umbraco.Content(Convert.ToInt32(id)).wwtype == "2")
                            {
                                salgs.Add(id);
                            }
    
                            if (Umbraco.Content(Convert.ToInt32(id)).wwtype == "3" || Umbraco.Content(Convert.ToInt32(id)).wwtype == "7")
                            {
                                koebs.Add(id);
                            }
    
                            if (Umbraco.Content(Convert.ToInt32(id)).wwtype == "4")
                            {
                                stillings.Add(id);
                            }
    
                            if (Umbraco.Content(Convert.ToInt32(id)).wwtype == "5")
                            {
                                oevrige.Add(id);
                            }
    
                            if (Umbraco.Content(Convert.ToInt32(id)).wwtype == "6")
                            {
                                diverse.Add(id);
                            }
    
    
                        }
                    }
    
                    salgs.ToArray();
                    koebs.ToArray();
                    stillings.ToArray();
                    oevrige.ToArray();
                    diverse.ToArray();
    
                    @*Salgsannoncer*@
                    if (salgs.Count > 0)
                    {
                        <fo:block margin-top="0.5cm"></fo:block>
                        <fo:inline font-family="Arial" margin-bottom="0.5cm" margin-top="0.5cm" font-size="13pt" color="#000000">Salgsannoncer</fo:inline>
                        <fo:block margin-bottom="0.5cm"></fo:block><fo:block />
                    }
                    foreach (var salg in salgs)
                    {
                        if (clr == true) { clr = false; }
                        else if (clr == false) { clr = true; }
                        @anonoutput(Convert.ToInt32(salg), clr)
                    }
                    @*Købsannoncer*@
                    if (koebs.Count() > 0)
                    {
                        <fo:block margin-top="0.5cm"></fo:block>
                        <fo:inline font-family="Arial" margin-bottom="0.5cm" margin-top="0.5cm" font-size="13pt" color="#000000">Købssannoncer</fo:inline>
                        <fo:block margin-bottom="0.5cm"></fo:block><fo:block />
                    }
                    foreach (var koeb in koebs)
                    {
                        if (clr == true) { clr = false; }
                        else if (clr == false) { clr = true; }
                        @anonoutput(Convert.ToInt32(koeb), clr)
                    }
                    @*Stillingsannoncer*@
                    if (stillings.Count() > 0)
                    {
                        <fo:block margin-top="0.5cm"></fo:block>
                        <fo:inline font-family="Arial" margin-bottom="0.5cm" margin-top="0.5cm" font-size="13pt" color="#000000">Stillingssannoncer</fo:inline>
                        <fo:block margin-bottom="0.5cm"></fo:block><fo:block />
                    }
                    foreach (var stilling in stillings)
                    {
                        if (clr == true) { clr = false; }
                        else if (clr == false) { clr = true; }
                        @anonoutput(Convert.ToInt32(stilling), clr)
                    }
                    @*Øvrige*@
                    if (oevrige.Count() > 0)
                    {
                        <fo:block margin-top="0.5cm"></fo:block>
                        <fo:inline font-family="Arial" margin-bottom="0.5cm" margin-top="0.5cm" font-size="13pt" color="#000000">Øvrige tilbud</fo:inline>
                        <fo:block margin-bottom="0.5cm"></fo:block><fo:block />
                    }
                    foreach (var oevrig in oevrige)
                    {
                        if (clr == true) { clr = false; }
                        else if (clr == false) { clr = true; }
                        @anonoutput(Convert.ToInt32(oevrig), clr)
                    }
                    @*Diverse*@
                    if (diverse.Count() > 0)
                    {
                        <fo:block margin-top="0.5cm"></fo:block>
                        <fo:inline font-family="Arial" margin-bottom="0.5cm" margin-top="0.5cm" font-size="13pt" color="#000000">Diverse</fo:inline>
                        <fo:block margin-bottom="0.5cm"></fo:block><fo:block />
                    }
                    foreach (var divers in diverse)
                    {
                        if (clr == true) { clr = false; }
                        else if (clr == false) { clr = true; }
                        @anonoutput(Convert.ToInt32(divers), clr)
                    }
                }
    
    
    
            </fo:block>
            <fo:block id="last-page" keep-together.within-page="auto"></fo:block>
    
        </fo:flow>
    
    
    </fo:page-sequence>
    

    @helper ParseElement(XmlNode node) { @* @node.Name *@ switch (node.Name) { case "p": break; case "strong": break; case "em": break; case "a": break; case "u": break; case "ol": break; case "ul": break; case "li": break; case "img": var docRoot = IOHelper.MapPath("~/"); @ParseRichText(node.ChildNodes) break; case "&": break;

    }
    

    }

    @helper ParseRichText(XmlNodeList nodes) { foreach (XmlNode node in nodes) {

        switch (node.NodeType)
        {
            case XmlNodeType.Text:
                @node.Value
                @ParseRichText(node.ChildNodes);
                                            break;
            case XmlNodeType.Element:
            @ParseElement(node);
                                break;
            default:
            @ParseRichText(node.ChildNodes);
                                            break;
        }
    }
    

    }

    @helper anonoutput(int Id, bool clr) { var cp = Umbraco.Content(Id); var bgclr = ""; if (clr == true) { bgclr = "#f9f9f9"; }

    <fo:block-container border="1px" margin-bottom="0.5cm">
        <fo:block>
            <fo:table width="297mm">
                <fo:table-column column-width="38mm" />
                <fo:table-column column-width="83mm" />
                <fo:table-column column-width="20mm" />
                <fo:table-column column-width="20mm" />
                <fo:table-column column-width="30mm" />
                <fo:table-body>
    
    
                    <fo:table-row background-color="@bgclr">
                        <fo:table-cell>
                            <fo:block>
                                @if (Umbraco.Content(Id).wwimg != "")
                                {
                                    string[] imgsplit = Umbraco.Content(Id).wwimg.ToString().Split(',');
                                    var img = imgsplit.First();
                                    <fo:external-graphic content-height="scale-to-fit" height="1.0in" content-width="1.40in" scaling="non-uniform" src="@Request.Form["url"]@Umbraco.Media(img).GetCropUrl("umbracoFile", "pdf")" />
    
                                }
                                else
                                {
                                    <fo:external-graphic content-height="scale-to-fit" height="1.0in" content-width="1.40in" scaling="non-uniform" src="@Request.Form["url"]@Umbraco.Media(11904).GetCropUrl("umbracoFile", "pdf")" />
                                }
                            </fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block margin-top="2mm">
    
    
                                @if (cp.wwtype != "1")
                                {
                                    <fo:inline font-family="Arial" font-size="12pt" font-weight="bold" color="#000000">@Html.Raw(cp.wwoverskrift.Replace(" ", "&#xA0;"))</fo:inline>
                                }
                                else
                                {
                                    <fo:inline font-family="Arial" font-size="12pt" font-weight="bold" color="#000000">
                                        @Html.Raw(cp.wwmerke)
                                        @Html.Raw(cp.wwmodel)
                                    </fo:inline>
    
                                }
                                <fo:inline font-family="Arial" font-size="12pt" font-weight="bold" color="#000000">
                                    @if (cp.wwvariant != "")
                                    {
                                        @Html.Raw(cp.wwvariant)<fo:leader leader-length="1mm" />
                                    }
                                    @if (cp.wwdoors != "")
                                    {@Html.Raw(cp.wwdoors)<fo:inline font-family="Arial" font-size="12pt" font-weight="bold" color="#000000">d</fo:inline>}
                                </fo:inline>
                            </fo:block>
                            <fo:block margin-top="2mm" width="200mm" padding-bottom="0.2cm">
                                @Html.Raw(cp.wwtxt.Replace(" ", "&#xA0;"))
                                <fo:block />
                                <fo:inline></fo:inline>
                                <fo:block />
                                @cp.wwfirmanavn
                                <fo:block />
                                Tlf: @Html.Raw(cp.wwtlf)
                            </fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block margin-top="2mm">
                                @if (cp.wwyear != "")
                                {
                                    @Html.Raw(cp.wwyear)
                                }
                            </fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block margin-top="2mm">
                                @if (cp.wwkm != "")
                                {
                                    @Html.Raw(cp.wwkm)                                                  }
    
    
    
                            </fo:block>
                        </fo:table-cell>
                        <fo:table-cell>
                            <fo:block margin-top="2mm">
                                @if (cp.wwcarprice != "")
                                {
                                    @:Kr. @Html.Raw(cp.wwcarprice)
                                                        }
                                else
                                {
                                    @Html.Raw(cp.wwprice)
                                }
    
                            </fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>
            </fo:table>
        </fo:block>
    
    </fo:block-container>
    <fo:block id="TheVeryLastPage"> </fo:block>
    

    }

    @helper Truncate(string input, int length) { if (input.Length <= length) { @input } else { @input.Substring(0, length) } }

    @functions{ public static string Decode(string decodeMe) { byte[] encoded = Convert.FromBase64String(decodeMe); return System.Text.Encoding.UTF8.GetString(encoded); }

    }

    /Palle

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Mar 10, 2017 @ 12:58
    Darren Ferguson
    0

    I can see that you are prefixing all of your graphics with Request.Form["Url"]

    Is there a reason?

    What immediately comes to mind is that if you are requesting the template via https and the images via http that FO may not allow this.

    What is the value of Request.Form["Url"]

    Can you remove the Response.AppendHeader("X-Pdf-Render", "true");

    so that i can see the XML of the FO template that is passed to PDF creator?

  • Palle Hansen 143 posts 396 karma points
    Mar 10, 2017 @ 13:26
    Palle Hansen
    0

    Hi Darren.

    The website is being redirectet from http to https, so I'll check up on the request of the images.

    I'll get back. Thanks

    /Palle

Please Sign in or register to post replies

Write your reply to:

Draft