Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple objects in one conversion issue, only last page renders #23

Closed
tinyfingersdev opened this issue Jun 16, 2014 · 7 comments
Closed

Comments

@tinyfingersdev
Copy link

I was having trouble getting the multiple objects in one conversion working so I pulled in the code from the readme sample (with a few modifications like changing from pageurl to htmltext).

byte[] pdfContent = null;
var document = new HtmlToPdfDocument
{
    GlobalSettings =
    {
        ProduceOutline = true,
        DocumentTitle = "Pretty Websites",
        PaperSize = PaperKind.A4, // Implicit conversion to PechkinPaperSize
        Margins =
        {
            All = 1.375,
            Unit = Unit.Centimeters
        }
    },
    Objects = {
        new ObjectSettings { HtmlText = "<h1>1Pretty Websites</h1><p>This might take a bit to convert!</p>" },
        new ObjectSettings { HtmlText = "<h1>2Pretty Websites</h1><p>This might take a bit to convert!</p>" },
        new ObjectSettings { HtmlText = "<h1>3Pretty Websites</h1><p>This might take a bit to convert!</p>" },
        new ObjectSettings { HtmlText = "<h1>4Pretty Websites</h1><p>This might take a bit to convert!</p>" }
    }
};

IPechkin converter = Factory.Create();

converter.Begin += OnBegin;
converter.Error += OnError;
converter.Warning += OnWarning;
converter.PhaseChanged += OnPhase;
converter.ProgressChanged += OnProgress;
converter.Finished += OnFinished;


pdfContent = converter.Convert(document);

However, when this runs I'm getting three blank pages and the last page has the expected content (the one with "4Pretty Websites"

I'm also getting three warnings such as the one below corresponding to the three blank pages.

Failed loading page file:///C:/Users/slpaige/AppData/Local/Temp/wktemp-f0b0c5ba-e83a-4f2c-8cca-862aa54c790c.html (ignored)"

It looks like maybe the html string is being saved in a temporary file that for some reason is no longer available when the conversion runs?

@danspam
Copy link

danspam commented Jun 18, 2014

Also getting this problem when using multiple objectsettings using htmltext. A similar warning message appears for each page and only the last page content renders. All other pages are blank except for the header and footer content.

@tuespetre
Copy link
Owner

Hmmm... interesting. I think I will set up a trace for changes to the temp folder so it interleaves with the wkhtmltopdf trace, so we can get a better timeline of events.

@MrGlacier
Copy link

Is there an Workaround for this Bug? I need this Function :-(

@tuespetre
Copy link
Owner

A workaround would be to make your content accessible via urls and use the urls instead of the string html. I know that could be pretty inconvenient, especially with highly dynamic content, but the only other thing to do is wait for the issue in wkhtmltopdf to be resolved.

@tuespetre tuespetre mentioned this issue Aug 10, 2014
@ashkulz
Copy link

ashkulz commented Jan 3, 2015

This would be fixed for the 0.12.2 release, which should happen in a week.

@ashkulz
Copy link

ashkulz commented Jan 9, 2015

I think you forgot to close this issue 😄

@tuespetre
Copy link
Owner

Indeed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants