ABCpdf not rendering images or applying CSS





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















The problem is that the CSS is not applying and the images are not rendering in the PDF. This only happens on a staging and production environment. Unable to recreate the problem on my development environment.



Both are under https, the links to the images and CSS files are http. So, I changed my development environment to use https to see if this was the issue. It didn't make any difference.



This is the code I have in place for rendering the PDF from HTML (I didn't write it, its quite old code):



Doc theDoc = new Doc();
theDoc.HtmlOptions.Engine = EngineType.Gecko;
theDoc.HtmlOptions.UseScript = true;
theDoc.HtmlOptions.Media = MediaType.Screen;
theDoc.HtmlOptions.AutoTruncate = true;

XHtmlOptions.GeckoSubsetType options = theDoc.HtmlOptions.GeckoSubset;
options.AddLinks = true;

//Write the CSS to PDF
StringBuilder coreCssBuilder = new StringBuilder();
StringWriter coreCssWriter = new StringWriter(coreCssBuilder);
HtmlTextWriter coreCssHtmlWriter = new HtmlTextWriter(coreCssWriter);
lnkCoreCss.RenderControl(coreCssHtmlWriter);

String coreCssHtml = coreCssBuilder.ToString().Replace("href="..", "href="http://example.com");

StringBuilder testTranscriptCssBuilder = new StringBuilder();
StringWriter testTranscriptCssWriter = new StringWriter(testTranscriptCssBuilder);
HtmlTextWriter testTranscriptCssHtmlWriter = new HtmlTextWriter(testTranscriptCssWriter);
lnkTestTranscriptCss.RenderControl(testTranscriptCssHtmlWriter);

String testTranscriptCssHtml = testTranscriptCssBuilder.ToString().Replace("href="..", "href="http://example.com");

StringBuilder templateTableCssBuilder = new StringBuilder();
StringWriter templateTableCssWriter = new StringWriter(templateTableCssBuilder);
HtmlTextWriter templateTableCssHtmlWriter = new HtmlTextWriter(templateTableCssWriter);
lnkTemplateTableCss.RenderControl(templateTableCssHtmlWriter);

String templateTableCssHtml = templateTableCssBuilder.ToString().Replace("href="..", "href="http://example.com");

StringBuilder extraCssBuilder = new StringBuilder();
StringWriter extraCssWriter = new StringWriter(extraCssBuilder);
HtmlTextWriter extraCssHtmlWriter = new HtmlTextWriter(extraCssWriter);
styleExtraCss.RenderControl(extraCssHtmlWriter);

String extraCssHtml = extraCssBuilder.ToString().Replace("</style>", ".BorderCell {border: none;}</style>");

StringBuilder transcriptBuilder = new StringBuilder();
StringWriter transcriptWriter = new StringWriter(transcriptBuilder);
HtmlTextWriter transcriptHtmlWriter = new HtmlTextWriter(transcriptWriter);

pnlTranscript.RenderControl(transcriptHtmlWriter);

//Add the transcript html to the PDF
String transcriptHtml = transcriptBuilder.ToString()
.Replace("src="/", "src="http://example.com/")
.Replace("src="../", "src="http://example.com/");

//Add the page CSS to the PDF
transcriptHtml = coreCssHtml + testTranscriptCssHtml + templateTableCssHtml + extraCssHtml + transcriptHtml;

int pageId = theDoc.AddImageHtml(transcriptHtml);

while (true)
{
if (!theDoc.Chainable(pageId))
break;
theDoc.Page = theDoc.AddPage();
pageId = theDoc.AddImageToChain(pageId);
}

//Flatten pages
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}

return theDoc;


More information




  • ABCpdf .NET version 8.1 x64

  • Staging and production environments run IIS 8.5 on Windows Server 2012 R2

  • Development environment runs IIS 7.5


Can anyone help with this?










share|improve this question





























    2















    The problem is that the CSS is not applying and the images are not rendering in the PDF. This only happens on a staging and production environment. Unable to recreate the problem on my development environment.



    Both are under https, the links to the images and CSS files are http. So, I changed my development environment to use https to see if this was the issue. It didn't make any difference.



    This is the code I have in place for rendering the PDF from HTML (I didn't write it, its quite old code):



    Doc theDoc = new Doc();
    theDoc.HtmlOptions.Engine = EngineType.Gecko;
    theDoc.HtmlOptions.UseScript = true;
    theDoc.HtmlOptions.Media = MediaType.Screen;
    theDoc.HtmlOptions.AutoTruncate = true;

    XHtmlOptions.GeckoSubsetType options = theDoc.HtmlOptions.GeckoSubset;
    options.AddLinks = true;

    //Write the CSS to PDF
    StringBuilder coreCssBuilder = new StringBuilder();
    StringWriter coreCssWriter = new StringWriter(coreCssBuilder);
    HtmlTextWriter coreCssHtmlWriter = new HtmlTextWriter(coreCssWriter);
    lnkCoreCss.RenderControl(coreCssHtmlWriter);

    String coreCssHtml = coreCssBuilder.ToString().Replace("href="..", "href="http://example.com");

    StringBuilder testTranscriptCssBuilder = new StringBuilder();
    StringWriter testTranscriptCssWriter = new StringWriter(testTranscriptCssBuilder);
    HtmlTextWriter testTranscriptCssHtmlWriter = new HtmlTextWriter(testTranscriptCssWriter);
    lnkTestTranscriptCss.RenderControl(testTranscriptCssHtmlWriter);

    String testTranscriptCssHtml = testTranscriptCssBuilder.ToString().Replace("href="..", "href="http://example.com");

    StringBuilder templateTableCssBuilder = new StringBuilder();
    StringWriter templateTableCssWriter = new StringWriter(templateTableCssBuilder);
    HtmlTextWriter templateTableCssHtmlWriter = new HtmlTextWriter(templateTableCssWriter);
    lnkTemplateTableCss.RenderControl(templateTableCssHtmlWriter);

    String templateTableCssHtml = templateTableCssBuilder.ToString().Replace("href="..", "href="http://example.com");

    StringBuilder extraCssBuilder = new StringBuilder();
    StringWriter extraCssWriter = new StringWriter(extraCssBuilder);
    HtmlTextWriter extraCssHtmlWriter = new HtmlTextWriter(extraCssWriter);
    styleExtraCss.RenderControl(extraCssHtmlWriter);

    String extraCssHtml = extraCssBuilder.ToString().Replace("</style>", ".BorderCell {border: none;}</style>");

    StringBuilder transcriptBuilder = new StringBuilder();
    StringWriter transcriptWriter = new StringWriter(transcriptBuilder);
    HtmlTextWriter transcriptHtmlWriter = new HtmlTextWriter(transcriptWriter);

    pnlTranscript.RenderControl(transcriptHtmlWriter);

    //Add the transcript html to the PDF
    String transcriptHtml = transcriptBuilder.ToString()
    .Replace("src="/", "src="http://example.com/")
    .Replace("src="../", "src="http://example.com/");

    //Add the page CSS to the PDF
    transcriptHtml = coreCssHtml + testTranscriptCssHtml + templateTableCssHtml + extraCssHtml + transcriptHtml;

    int pageId = theDoc.AddImageHtml(transcriptHtml);

    while (true)
    {
    if (!theDoc.Chainable(pageId))
    break;
    theDoc.Page = theDoc.AddPage();
    pageId = theDoc.AddImageToChain(pageId);
    }

    //Flatten pages
    for (int i = 1; i <= theDoc.PageCount; i++)
    {
    theDoc.PageNumber = i;
    theDoc.Flatten();
    }

    return theDoc;


    More information




    • ABCpdf .NET version 8.1 x64

    • Staging and production environments run IIS 8.5 on Windows Server 2012 R2

    • Development environment runs IIS 7.5


    Can anyone help with this?










    share|improve this question

























      2












      2








      2








      The problem is that the CSS is not applying and the images are not rendering in the PDF. This only happens on a staging and production environment. Unable to recreate the problem on my development environment.



      Both are under https, the links to the images and CSS files are http. So, I changed my development environment to use https to see if this was the issue. It didn't make any difference.



      This is the code I have in place for rendering the PDF from HTML (I didn't write it, its quite old code):



      Doc theDoc = new Doc();
      theDoc.HtmlOptions.Engine = EngineType.Gecko;
      theDoc.HtmlOptions.UseScript = true;
      theDoc.HtmlOptions.Media = MediaType.Screen;
      theDoc.HtmlOptions.AutoTruncate = true;

      XHtmlOptions.GeckoSubsetType options = theDoc.HtmlOptions.GeckoSubset;
      options.AddLinks = true;

      //Write the CSS to PDF
      StringBuilder coreCssBuilder = new StringBuilder();
      StringWriter coreCssWriter = new StringWriter(coreCssBuilder);
      HtmlTextWriter coreCssHtmlWriter = new HtmlTextWriter(coreCssWriter);
      lnkCoreCss.RenderControl(coreCssHtmlWriter);

      String coreCssHtml = coreCssBuilder.ToString().Replace("href="..", "href="http://example.com");

      StringBuilder testTranscriptCssBuilder = new StringBuilder();
      StringWriter testTranscriptCssWriter = new StringWriter(testTranscriptCssBuilder);
      HtmlTextWriter testTranscriptCssHtmlWriter = new HtmlTextWriter(testTranscriptCssWriter);
      lnkTestTranscriptCss.RenderControl(testTranscriptCssHtmlWriter);

      String testTranscriptCssHtml = testTranscriptCssBuilder.ToString().Replace("href="..", "href="http://example.com");

      StringBuilder templateTableCssBuilder = new StringBuilder();
      StringWriter templateTableCssWriter = new StringWriter(templateTableCssBuilder);
      HtmlTextWriter templateTableCssHtmlWriter = new HtmlTextWriter(templateTableCssWriter);
      lnkTemplateTableCss.RenderControl(templateTableCssHtmlWriter);

      String templateTableCssHtml = templateTableCssBuilder.ToString().Replace("href="..", "href="http://example.com");

      StringBuilder extraCssBuilder = new StringBuilder();
      StringWriter extraCssWriter = new StringWriter(extraCssBuilder);
      HtmlTextWriter extraCssHtmlWriter = new HtmlTextWriter(extraCssWriter);
      styleExtraCss.RenderControl(extraCssHtmlWriter);

      String extraCssHtml = extraCssBuilder.ToString().Replace("</style>", ".BorderCell {border: none;}</style>");

      StringBuilder transcriptBuilder = new StringBuilder();
      StringWriter transcriptWriter = new StringWriter(transcriptBuilder);
      HtmlTextWriter transcriptHtmlWriter = new HtmlTextWriter(transcriptWriter);

      pnlTranscript.RenderControl(transcriptHtmlWriter);

      //Add the transcript html to the PDF
      String transcriptHtml = transcriptBuilder.ToString()
      .Replace("src="/", "src="http://example.com/")
      .Replace("src="../", "src="http://example.com/");

      //Add the page CSS to the PDF
      transcriptHtml = coreCssHtml + testTranscriptCssHtml + templateTableCssHtml + extraCssHtml + transcriptHtml;

      int pageId = theDoc.AddImageHtml(transcriptHtml);

      while (true)
      {
      if (!theDoc.Chainable(pageId))
      break;
      theDoc.Page = theDoc.AddPage();
      pageId = theDoc.AddImageToChain(pageId);
      }

      //Flatten pages
      for (int i = 1; i <= theDoc.PageCount; i++)
      {
      theDoc.PageNumber = i;
      theDoc.Flatten();
      }

      return theDoc;


      More information




      • ABCpdf .NET version 8.1 x64

      • Staging and production environments run IIS 8.5 on Windows Server 2012 R2

      • Development environment runs IIS 7.5


      Can anyone help with this?










      share|improve this question














      The problem is that the CSS is not applying and the images are not rendering in the PDF. This only happens on a staging and production environment. Unable to recreate the problem on my development environment.



      Both are under https, the links to the images and CSS files are http. So, I changed my development environment to use https to see if this was the issue. It didn't make any difference.



      This is the code I have in place for rendering the PDF from HTML (I didn't write it, its quite old code):



      Doc theDoc = new Doc();
      theDoc.HtmlOptions.Engine = EngineType.Gecko;
      theDoc.HtmlOptions.UseScript = true;
      theDoc.HtmlOptions.Media = MediaType.Screen;
      theDoc.HtmlOptions.AutoTruncate = true;

      XHtmlOptions.GeckoSubsetType options = theDoc.HtmlOptions.GeckoSubset;
      options.AddLinks = true;

      //Write the CSS to PDF
      StringBuilder coreCssBuilder = new StringBuilder();
      StringWriter coreCssWriter = new StringWriter(coreCssBuilder);
      HtmlTextWriter coreCssHtmlWriter = new HtmlTextWriter(coreCssWriter);
      lnkCoreCss.RenderControl(coreCssHtmlWriter);

      String coreCssHtml = coreCssBuilder.ToString().Replace("href="..", "href="http://example.com");

      StringBuilder testTranscriptCssBuilder = new StringBuilder();
      StringWriter testTranscriptCssWriter = new StringWriter(testTranscriptCssBuilder);
      HtmlTextWriter testTranscriptCssHtmlWriter = new HtmlTextWriter(testTranscriptCssWriter);
      lnkTestTranscriptCss.RenderControl(testTranscriptCssHtmlWriter);

      String testTranscriptCssHtml = testTranscriptCssBuilder.ToString().Replace("href="..", "href="http://example.com");

      StringBuilder templateTableCssBuilder = new StringBuilder();
      StringWriter templateTableCssWriter = new StringWriter(templateTableCssBuilder);
      HtmlTextWriter templateTableCssHtmlWriter = new HtmlTextWriter(templateTableCssWriter);
      lnkTemplateTableCss.RenderControl(templateTableCssHtmlWriter);

      String templateTableCssHtml = templateTableCssBuilder.ToString().Replace("href="..", "href="http://example.com");

      StringBuilder extraCssBuilder = new StringBuilder();
      StringWriter extraCssWriter = new StringWriter(extraCssBuilder);
      HtmlTextWriter extraCssHtmlWriter = new HtmlTextWriter(extraCssWriter);
      styleExtraCss.RenderControl(extraCssHtmlWriter);

      String extraCssHtml = extraCssBuilder.ToString().Replace("</style>", ".BorderCell {border: none;}</style>");

      StringBuilder transcriptBuilder = new StringBuilder();
      StringWriter transcriptWriter = new StringWriter(transcriptBuilder);
      HtmlTextWriter transcriptHtmlWriter = new HtmlTextWriter(transcriptWriter);

      pnlTranscript.RenderControl(transcriptHtmlWriter);

      //Add the transcript html to the PDF
      String transcriptHtml = transcriptBuilder.ToString()
      .Replace("src="/", "src="http://example.com/")
      .Replace("src="../", "src="http://example.com/");

      //Add the page CSS to the PDF
      transcriptHtml = coreCssHtml + testTranscriptCssHtml + templateTableCssHtml + extraCssHtml + transcriptHtml;

      int pageId = theDoc.AddImageHtml(transcriptHtml);

      while (true)
      {
      if (!theDoc.Chainable(pageId))
      break;
      theDoc.Page = theDoc.AddPage();
      pageId = theDoc.AddImageToChain(pageId);
      }

      //Flatten pages
      for (int i = 1; i <= theDoc.PageCount; i++)
      {
      theDoc.PageNumber = i;
      theDoc.Flatten();
      }

      return theDoc;


      More information




      • ABCpdf .NET version 8.1 x64

      • Staging and production environments run IIS 8.5 on Windows Server 2012 R2

      • Development environment runs IIS 7.5


      Can anyone help with this?







      css abcpdf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 14 '14 at 14:13









      97ldave97ldave

      4,48912035




      4,48912035
























          1 Answer
          1






          active

          oldest

          votes


















          0














          It turns out that the site where the CSS and images were stored did not have the correct DNS settings in order to allow my staging and production environments to access it.



          Adjusted the DNS settings and this now works.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25310313%2fabcpdf-not-rendering-images-or-applying-css%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It turns out that the site where the CSS and images were stored did not have the correct DNS settings in order to allow my staging and production environments to access it.



            Adjusted the DNS settings and this now works.






            share|improve this answer




























              0














              It turns out that the site where the CSS and images were stored did not have the correct DNS settings in order to allow my staging and production environments to access it.



              Adjusted the DNS settings and this now works.






              share|improve this answer


























                0












                0








                0







                It turns out that the site where the CSS and images were stored did not have the correct DNS settings in order to allow my staging and production environments to access it.



                Adjusted the DNS settings and this now works.






                share|improve this answer













                It turns out that the site where the CSS and images were stored did not have the correct DNS settings in order to allow my staging and production environments to access it.



                Adjusted the DNS settings and this now works.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 17 '14 at 21:42









                97ldave97ldave

                4,48912035




                4,48912035
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25310313%2fabcpdf-not-rendering-images-or-applying-css%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas