logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages<12
Options
Go to last post Go to first unread
Paul Rayman  
#21 Posted : Wednesday, June 26, 2019 6:52:29 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 760

Thanks: 1 times
Was thanked: 92 time(s) in 91 post(s)
Originally Posted by: rhnatiuk Go to Quoted Post
It seems that conversion from fake annotation to stream shrinks all contained objects. But this happens only to some files, like this one. Any ideas?


222.png (30kb) downloaded 2 time(s).

The problem is that the file contains an “unbalanced” zoom out matrix (line 21 in the screenshot)
And the text object, has the zoom in matrix (line 52)
The bounding box of the text object is obtained by multiplying these matrices.
When we add the path to the content of the page, this "unbalanced" matrix is ​​also applied to it (because it is not enclosed in the brackets of the stack operator - operator q..Q.
We must somehow compensate for this matrix, but I have not yet figured out how to do this, especially since a solution is needed in a general way.

So, if you add following
Code:
 pdfPathObject.Matrix = new FS_MATRIX(100 / 12f, 0, 0, 100 / 12f, 0, 0);

The path will shown in right place. But how to obtain these values....

Edited by user Wednesday, June 26, 2019 7:10:03 AM(UTC)  | Reason: Not specified

Paul Rayman  
#22 Posted : Wednesday, June 26, 2019 7:22:58 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 760

Thanks: 1 times
Was thanked: 92 time(s) in 91 post(s)
Originally Posted by: rhnatiuk Go to Quoted Post
It seems that conversion from fake annotation to stream shrinks all contained objects. But this happens only to some files, like this one. Any ideas?


I have one more idea.
You can eliminate the effect of drawing operators (as well as matrix operators) on your objects if you add your sinsert your stream as a first element of the contents array.

instead of
Code:
contentsArray.AddIndirect(list, stream);

use
Code:
contentsArray.Insert(...);


like shown below
Code:
var stream = PdfTypeStream.Create();
var list = PdfIndirectList.FromPdfDocument(doc);
int num = list.Add(stream);
....
contentsArray.Insert(0, PdfTypeIndirect.Create(list, num));


thanks 1 user thanked Paul Rayman for this useful post.
rhnatiuk on 6/26/2019(UTC)
rhnatiuk  
#23 Posted : Wednesday, June 26, 2019 7:40:24 AM(UTC)
rhnatiuk

Rank: Member

Groups: Registered
Joined: 4/30/2019(UTC)
Posts: 23
Man
Finland
Location: Raisio

Thanks: 7 times
Originally Posted by: Paul Rayman Go to Quoted Post
No, no

I mean following [...]


This one works, also on those "broken" files! :) I had to add AnnotationFlags.Locked | AnnotationFlags.LockedContents | AnnotationFlags.ReadOnly | AnnotationFlags.Print flags to all annotations (sad, that it is impossible to make annotations not selectable), but the result looks good. Probably we will go with this solution for now. Thank you!

rhnatiuk  
#24 Posted : Wednesday, June 26, 2019 8:25:57 AM(UTC)
rhnatiuk

Rank: Member

Groups: Registered
Joined: 4/30/2019(UTC)
Posts: 23
Man
Finland
Location: Raisio

Thanks: 7 times
Originally Posted by: Paul Rayman Go to Quoted Post
Originally Posted by: rhnatiuk Go to Quoted Post
It seems that conversion from fake annotation to stream shrinks all contained objects. But this happens only to some files, like this one. Any ideas?


I have one more idea.
You can eliminate the effect of drawing operators (as well as matrix operators) on your objects if you add your sinsert your stream as a first element of the contents array.

instead of
Code:
contentsArray.AddIndirect(list, stream);

use
Code:
contentsArray.Insert(...);



And yes, this works on "broken" PDFs as well!!! It is a bit faster than annotations-based solution as well. Thank you! We will use this approach!
Users browsing this topic
2 Pages<12
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.