Git Product home page Git Product logo

Comments (6)

ThomasWaldmann avatar ThomasWaldmann commented on June 30, 2024

@sunqianxiang i wrote some code based on the fancy_watermark.py, no issue with flipping.

from pdfrw.

pmaupin avatar pmaupin commented on June 30, 2024

Either your watermark or your PDF pages are probably rotated. (Probably the PDF page, I think rotation for the watermark is handled.) If you have examples (especially if you have examples I can add to the test suite) please email them to me and I will fix.

Thanks,
Pat

from pdfrw.

sqxccdy avatar sqxccdy commented on June 30, 2024

but I maybe need normal merger..Such as for example with PyPDF2..

from PyPDF2 import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
ipdf = PdfFileReader(open('output.pdf', 'rb'))
wpdf = PdfFileReader(open('transafe.pdf', 'rb'))
watermark = wpdf.getPage(0)
for i in xrange(ipdf.getNumPages()):
   try:
      page = ipdf.getPage(i)
      page.mergePage(watermark)
      output.addPage(page)
   except:
      pass
with open('newfile.pdf', 'wb') as f:
   output.write(f)

here generate not flipping pdf from code..but it have problem in pdf 1.4.
i think watemark need custom options or providing method to adjustment.
in pdf1.4 maybe have the problam.i can send mail to you for my pdf file..
Thanks in advance

from pdfrw.

pmaupin avatar pmaupin commented on June 30, 2024

Thank you for this bug report. I have checked in some code on a new branch that fixes this problem.

When I did a rewrite of my merge code, I forgot to save graphics state if the object was a regular page and not a form XObject. Most PDFs work fine this way, but your example PDF alters the graphics state and leaves it altered (which is perfectly legal, but which I did not have a failing PDF for).

I have not yet checked the fix into the master because I will first need to update expected checksums for the output of the watermark test. There is one changed file, here:

https://github.com/pmaupin/pdfrw/blob/pagemerge_state_save_restore/pdfrw/pagemerge.py

Please verify it works on all your files.

Also, if you can create a non-sensitive file that the old one fails on and the new one works on I will add it to the test suite.

@ThomasWaldmann -- you may also want this fix, depending on how much control you have over the PDFs you are watermarking -- it is a definite bug in pdfrw, but the PDFs you provided so far did not provoke it.

Thanks,
Pat

from pdfrw.

claytonbrown avatar claytonbrown commented on June 30, 2024

yup, works fine, had the same issue

from pdfrw.

takluyver avatar takluyver commented on June 30, 2024

The branch to fix this is now merged, so I'm closing this issue.

from pdfrw.

Related Issues (20)

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.