question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subsequent PdfTools instances yield wrong PDF output

See original GitHub issue

Hi! I’m trying to write some automated tests.

If I:

using (var tools = new PdfTools())
{
 var converter = new SynchronizedConverter(tools);
 // do the stuff, many times over
}

…then everything works fine.

However, if I:

using (var tools = new PdfTools())
{
 var converter = new SynchronizedConverter(tools);
 // do the stuff
}
using (var tools = new PdfTools())
{
 var converter = new SynchronizedConverter(tools);
 // do the stuff
}

The “stuff” being done is a randomly-named temp folder being set up, a HTML file and CSS file being copied in and the HTML being converted. I’ve put breakpoints and verified that for each conversion, the HTML and CSS are all valid. It’s the PDF conversion bit which has the issue, for some reason!

…then only the first PDF is correct. Strangely, all of the subsequent PDFs simply have text in the source document dumped out.

The tests don’t run in parallel, it seems that using a second (or rather, non-first) PdfTools instance is the issue.

Anything I can do to help diagnose?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
kierenjcommented, Aug 24, 2018

Yes, it certainly seems so. But I’d have hoped that there would be an exception, rather than randomly-corrupted PDF output. If this is indeed a design restriction, could I suggest a static flag somewhere, such that subsequent calls to the constructors throw a helpful error message?

1reaction
mlynamcommented, Aug 24, 2018

The PdfTools and Converter need to behave as singletons in your AppDomain.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conversion Service
Once conversion is completed, the Conversion Service returns: Output document If the conversion was successful, the resulting document can be found in the ......
Read more >
PDF processing and analysis with open-source tools
In case of broken or malformed files the output includes error ... A PDF can subsequently be tested against these rules (here in...
Read more >
pdftools: Text Extraction, Rendering and Converting of PDF ...
The pdf_text function renders all textboxes on a text canvas and returns a character vector of equal length to the number of pages...
Read more >
pdftk - A handy tool for manipulating PDF
Pdftk is a simple tool for doing everyday things with PDF documents. ... prompt you for a password if the supplied password is...
Read more >
PDF Tools and How to View and Edit the Code ...
In this tutorial, we consider the PDF format and explore ways to view and edit its original source code. First, we take a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found