Comments (12)
Probably not cause by that time some content is already written to the file and its a bit contrary to how pdfwrite doesnt things to go back.
How about you tell me more about why copying failes? Do you have a sample?
(Alternatively you could always work with two pdfs. Do action first on one, if doesnt fail, do on the other one)
from pdf-writer.
Please check this sample PDF
There is a missing object whose object ID = 16, but is referenced by an annotation object whose object ID = 19, in its "Parent" entry so CopyObject failed in copying source object ID = 19.
Is there any way that i can skip the failed object without writing a temp file (to rollback if failed) for every object copy?
from pdf-writer.
Well, this is something that PDFWriter should be corrected to handle. i mean, it is a valid possibility.
Gal.
from pdf-writer.
The ideal result is to skip the object copying on missing objects only.
i.e. for the missing object ID = 16, referenced by the other object (ID = 19) in its "Parent" entry, just skip copying the object whose ID = 16 and keep the destination exactly the same with the source is ideal although the missing condition will still preserve in the destination.
from pdf-writer.
I could make it into copying a null in this case, or create a deleted object entry. We will have to see which would be a more reliable recreation of the origin
from pdf-writer.
Do you mean to assign a deleted object ID (marked as unused in the xRefTable) for a missing object?
from pdf-writer.
that's a good option - if that's what makes 16 missing. is 16 marked as such? is it simply null? whatever it is in the source document...it's probably best to do the same in the target. i'm taking a look now
from pdf-writer.
What did you mean copying a null? (did you mean to replace the missing object ID with 0 ?) I am not as familiar with PDF spec as you. You are the PDF expert!!!
from pdf-writer.
yap. committed a solution along this line now. you can try it out. for me it worked well on the sample file, copying the annotation, and i also tried to append a page and it seemed to create a PDF is fine.
from pdf-writer.
It worked for the sample pdf.
Thank you very much for the solution!
However, do you have a solution for the case that a missing object has no associated deleted entry in the xRefTable?
from pdf-writer.
Look, it's valid to have deleted elements. the lib should take care of this case. it didn't and thanks to your note it's ok now.
anything else is just invalid. there are plenty possible exceptions. we could have an element pointing to an element it shouldn't (just having a wrong xref). xref table could be providing wrong positions (someone sent me a PDF like that recently). i think failing is a good policy then.
we could be writing another version of the copying method to handle all possible cases and fill up things with deleted elements (for instance, it could just do what i did for all "else" cases), but i feel that sometimes its ok to just fail if the file is invalid.
If you have an actual PDF that bothers you and you think we can figure out a good way out, we can tailor something around it together.
Gal.
from pdf-writer.
You are right!
from pdf-writer.
Related Issues (20)
- Can not modify a document by creating a new form XObject and using it in one of the pages HOT 3
- [Question] - pdf to image HOT 1
- Question about attachments HOT 2
- some example projects in wiki are missing HOT 2
- Streams objects writing problem HOT 2
- Add watermark to PDF HOT 7
- Missing lib.obj file HOT 3
- Android Build Workflow HOT 3
- CIDSet encoding does not conform with ISO 19005-2:2011, ISO 19005-3:2012 (PDF/A-2b or PDF/A-3b) HOT 21
- annotations are lost with PDFDocumentCopyingContext::AppendPDFPageFromPDF HOT 3
- How to draw Bezier curves using PDF-Witer library? HOT 2
- Parse a screenplay into scene objects? HOT 2
- color emojis HOT 16
- Links are removed when documents are merged HOT 8
- Color inversion problem occurs when exporting images HOT 1
- infinite loop HOT 2
- Crash when WriteUsedFontsDefinitions HOT 17
- Publish to github releases without PDFWriterTesting HOT 4
- U3D support, 10 years later HOT 10
- `Segmentation fault (core dumped)` just for adding `PDFWriter pdfWriter` in the `h` file HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdf-writer.