[Podofo-users] Bug in PdfVecObjects
Good morning dear podofo-community, I am quite new to Podofo, but In the last weeks I spend a lot of time with PDF generation. I found an error in the call "PdfVecObject" affecting the use of PdfStreamed documents in combination with XObjects. Problem: I tried to put a PDF-Document inside my new PDF-document without any problems. But when I tried the same on the second page, the PDF document was corrupted. So I had a closer look at the PDF-structure generated by Podofo and I recognized, that there were two PDF-objects with the same Object-ID. But this only happened when I tried it with the PdfStreamedDocument. With the PdfMemDocument there was no problem. After all I found out that the error occurred because objects were deleted from the PdfVecObject-vector. When the method "PdfDocument::Append(..)" tried to append the objects from the second PDF-file, it starts with the wrong Object-number. This is because it uses the method "m_vecObjects.GetSize()"" but this methods returns the total number of current objects inside the vector, but when objects have been deleted before, not the sequential number will be returned (needed for a unique object-number). Inside the PdfVecObjects-the call must look like: unsigned int difference = static_cast(m_vecObjects.GetObjectCount()) //__ CORRECT instead of: unsigned int difference = static_cast(m_vecObjects.GetSize() + m_vecObjects.GetFreeObjects().size()); //__ WRONG This must be applied to following methods: PdfDocument::InsertExistingPageAt(...) PdfDocument::Append(...) PdfDocument::FillXObjectFromDocumentPage(...) Best regards Hendrik -- ___ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users
Re: [Podofo-users] Adding text to an existing document
2016-11-28 23:34 GMT+01:00 Pantxo Diribarne : > > > 2016-11-28 15:47 GMT+01:00 Pantxo Diribarne : > >> Hi, >> >> I have pdf documents which are generated using gl2ps [1], on which I >> would like to superimpose text. >> >> As a first test, I used the provided example helloworld.cpp, which I >> modified as follows: >> * use a PdfMemDocument (instead of a PdfDocument) and load an existing >> pdf file. >> * use the Write method to export the modified pdf >> >> As a result I get a pdf that has been modified (at least its size on the >> disk is larger) and can be loaded, but the "hello world!" is no where to be >> found. >> >> What am I doing wrong? I played with the position arguments in DrawText >> to no avail. >> >> Thanks in advance, >> >> Pantxo >> > > Now I see that when the original pdf already contains text, the simple > approach described above works (incidentally?), the Hello World appears and > the right font is selected (different from the one in the original file). > > Are there some more examples around to get started? > > Pantxo > Ok I finally found what was wrong: the current color of the document (wherever the text was iserted) was white. I just had to use Painter::SetColor and the newly added text appeared. Pantxo -- ___ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users
Re: [Podofo-users] Bug in PdfVecObjects
On Wed, 2016-11-30 at 08:41 +, Dependahl, Hendrik wrote: > I found an error in the call “PdfVecObject” > affecting the use of PdfStreamed documents in combination with > XObjects. > > ... > > Inside the PdfVecObjects-the call must look like: > > unsigned int difference = static_cast int>(m_vecObjects.GetObjectCount()) //__ > CORRECT > ... Hi, thanks for reporting the problem. Particularly, you say that the bug is in PdfVecObjects, but your proposed changes do not touch it. Also, it would be more convenient to provide patches, then you'll not need to hardly describe the place where your changes should be done and it also avoids other confusion. Either you can generate them from a svn checkout, or use command like: $ diff -upr PoDoFo.orig/ PoDoFo.changed/ >podofo.patch Then _attach_ the proposed patch to an email and send it to the list, ideally keep threading (reply to this message). Looking at the PdfDocument::Append(), it looks like there is some idea behind the current behaviour (I do not say it's correct), because a comment right below the line you want to change says: // Ulrich Arnold 30.7.2009: Because GetNextObject uses m_nObjectCount instead // of m_vecObjects.GetSize()+m_vecObjects.GetFreeObjects().size()+1 // make sure the free objects are already present before appending to // prevent overlapping obj-numbers from which I understand that your change also makes those following lines useless. It needs some testing, though. Bye, zyx -- http://www.litePDF.cz i...@litepdf.cz -- ___ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users
[Podofo-users] Rich text
Hi, Is there somewhere an example of how to handle rich text. By this I mean: * add or modify an existing dictionary so that it includes non ascii characters written in whatever encoding * individual glyph positioning in a string such as what the TJ operator does Thanks in advance. Pantxo -- ___ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users
Re: [Podofo-users] Adding text to an existing document
On Wed, 2016-11-30 at 11:30 +0100, Pantxo Diribarne wrote: > Ok I finally found what was wrong: the current color of the document > (wherever the text was iserted) was white. I just had to use > Painter::SetColor and the newly added text appeared. Hi, nice. It seems that is sometimes helps to ask and the answer comes later on its own (it happens to me from time to time too). :-) Bye, zyx -- http://www.litePDF.cz i...@litepdf.cz -- ___ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users