Giter VIP home page Giter VIP logo

Comments (10)

jeroen avatar jeroen commented on July 21, 2024 1

Submitted qpdf 1.3.3 to cran.

from qpdf.

jeroen avatar jeroen commented on July 21, 2024

Can you send a pr?

from qpdf.

G5W avatar G5W commented on July 21, 2024

I think that you are asking for a pull request, which I understand to mean a proposed correction to the code. However, I am not a C++ programmer and could not find the part of the code that creates the filename. I am sorry, but I cannot help with fixing the code.

BTW, Above I proposed computing the exact size needed for the index numbers in the file name. I realized later that a simpler solution might be to always use a 9 digit number. That would accommodate up to 1 billion pages and so would be very unlikely to cause problems for anyone.

from qpdf.

enricoschumann avatar enricoschumann commented on July 21, 2024

I am not a C++ programmer either, but I'd also appreciate if this could be fixed.
The described behaviour stems from this line:

std::string outfile = outprefix + "_" + QUtil::int_to_string(i+1, pages.size()) + ".pdf";

int_to_string receives pages.size() as the number of digits of the resulting string, when it should for n pages receive floor(log10(n))+1 (in R-syntax).

(If I had to fix it, I'd #include <math.h> in bindings.cpp and use floor/log from that file. But I perhaps Rcpp offers something better here?)

from qpdf.

zeileis avatar zeileis commented on July 21, 2024

Yet another non-C++ programmer but one of my scripts also just choked on the same problem.

The description from Enrico @enricoschumann looks very useful for me but I also don't know enough C++ to turn this into a fix in the code (and ultimately into a PR).

Jeroen @jeroen, is this something you might be able to have a look again in the not so distant future?

from qpdf.

jeroen avatar jeroen commented on July 21, 2024

Can you please include example code? It seems to work as intended for me, the filename is postfixed with a number, but not excessive.

> pdf_file
[1] "/var/folders/gz/rwkfg8wx1wqgcr0ccpz42dyc0000gn/T//RtmpZvEBI7/output.pdf"
> pdf_length(pdf_file)
[1] 3
> pdf_split(pdf_file)
[1] "/private/var/folders/gz/rwkfg8wx1wqgcr0ccpz42dyc0000gn/T/RtmpZvEBI7/output_001.pdf"
[2] "/private/var/folders/gz/rwkfg8wx1wqgcr0ccpz42dyc0000gn/T/RtmpZvEBI7/output_002.pdf"
[3] "/private/var/folders/gz/rwkfg8wx1wqgcr0ccpz42dyc0000gn/T/RtmpZvEBI7/output_003.pdf"

from qpdf.

jeroen avatar jeroen commented on July 21, 2024

Ah I found the issue. It is fixed now, you can install the new version from https://ropensci.r-universe.dev/qpdf. I'll try to release to CRAN soon.

FWIW, if you had included a reprex code it would have been much easier for me to fix this sooner.

from qpdf.

zeileis avatar zeileis commented on July 21, 2024

Fantastic, Jeroen, thanks for resolving this issue - and apologies for not posting a reproducible example.

BTW: I think this also resolves the issue that had prompted PR #6 which can be closed now IMO. Your solution is nicer.

from qpdf.

zeileis avatar zeileis commented on July 21, 2024

Fantastic, thanks, already live.

from qpdf.

enricoschumann avatar enricoschumann commented on July 21, 2024

great, many thanks!

from qpdf.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.