Log of #mupdf at irc.freenode.net.

Search:
 <<<Back 1 day (to 2021/02/24)Fwd 1 day (to 2021/02/26)>>>20210225 
pedr0 hi all - forgive me if I am saying silly things. I am struggling to translate an overlay that I drawing on the rendered image of a page into its page's coordinates. This is because the page is rotated via its page dictionary, what I do is to inject an instruction which defines a clipping area, but coordinates are totally wrong when pages are rotated.11:48.21 
  One of the many questions I've is: is it possible to 'embed' the rotation of the whole page within the stream of the page and get rid of the page dictionary /Rotate entry ? I don't think so as all coordinates after such instruction would be relative to another coordinate space. am I talking complete rubbish ?11:51.46 
artifexirc-bot <Robin_Watts> pedr0: Yes, it's possible to embed the rotation of the whole page within the stream of the page.11:56.19 
  <Robin_Watts> How much do you know about PDF page streams?11:56.36 
pedr0 I understand cm, rotation and translation, skew and T[jJ] - but the former more in theory than in practice as I never had to do anything like that11:57.43 
  I did try to insert a cm rotation operation, but it ruined the whole page and my understanding was that all what followed was referring to the wrong 'space'11:58.21 
  I read the specs a lot of times :-)11:58.38 
artifexirc-bot <Robin_Watts> Right. So there is a 'current transformation matrix' (ctm) that maps from the space stuff is described in, to the actual pixels on the device.11:58.46 
  <ator> could you be looking at something ilke this maybe? "q <rotation matrix> cm <original contents> Q <non-rotated extras>"11:59.21 
  <Robin_Watts> Page contents can't ever 'set' that ctm, they can only modify it (using the cm instruction)11:59.26 
  <Robin_Watts> What @ator says is exactly what you need.11:59.56 
  <Robin_Watts> q stores the current state, and Q restores it.12:00.28 
pedr0 The fact is that I want to rotate the whole thing - and get rid of the entry in the dictionary.12:00.34 
  I tried and did not work, let me try again12:00.44 
artifexirc-bot <Robin_Watts> So, assuming your page contents are well formed (i.e. that the q and Q's match up), you can just modify the cm at the top level, and that will affect everything underneath it.12:01.21 
pedr0 at the end I want the same page as before being rendered with the only exception that the /Rotate entry isn't there any longer12:01.22 
artifexirc-bot <Robin_Watts> Basically, all the /Rotate entry does is to modify the initial ctm we pass in, so this approach WILL work.12:01.51 
pedr0 Right12:02.00 
artifexirc-bot <Robin_Watts> It's just that modification will happen within the page, rather than outside it.12:02.11 
pedr0 That was my first hunch, I must have got lost somewhere while doing it, thanks *a lot* for that.12:02.32 
artifexirc-bot <Robin_Watts> The one wrinkle in doing this generically is that some pages may have unbalanced q and Q operations.12:02.43 
  <KenSharp> @Robin_Watts the /Rotate also modifies the MediaBox.....12:03.01 
  <Robin_Watts> But you can solve that by 'sanitising' the stream.12:03.10 
  <KenSharp> Or is applied to the MediaBox or CropBox I should probably say12:03.16 
  <Robin_Watts> @KenSharp Right, yes.12:03.19 
  <KenSharp> So when removing teh /Rotate key from the /Page dictionary, you would need to alter teh MediaBox/CropBox/ArtBox/BleedBox....12:04.03 
pedr0 that's why I got an empty page when I tried maybe - did not notice that the MediaBox needed adjustment12:05.42 
  will keep you posted, thank you all12:05.53 
artifexirc-bot <KenSharp> Ah, you will also need to translate the current point12:10.28 
pedr0 what's that ?12:11.53 
  my stream started with [q ...] and I've prepended [q12:12.48 
  0 -1 1 0 0 0 cm12:12.48 
  ] and got rid of the rotate entry12:12.48 
  changed the media box - and I get a blank page12:13.35 
artifexirc-bot <KenSharp> Sorry, wasn't paying attention....12:20.38 
  <KenSharp> Actually if you rotate the MediaBox you probably don't need to worry about the current point.12:20.57 
  <KenSharp> But if you rotate the content or the media independently of each other then you do.12:21.12 
artifexirc-bot <KenSharp> reconsiders that12:21.51 
  <KenSharp> /Rotate (IIRC) rotates clockwise, I think you haev rotated the content anti-clockwise12:22.13 
  <KenSharp> In PDF 0,0 is the bottom left hand corner. If you rotate the CTM then the origin doesn't move.12:23.09 
  <KenSharp> The content rotates around the origin12:23.22 
  <KenSharp> So after you have done the rotate, you need to shift the origin so that it is at the bottom left again12:23.58 
  <KenSharp> Take a piece of A4, portrai.12:24.18 
  <KenSharp> Hold the bottom left coner, an rotate it by 90 degrees12:24.30 
  <KenSharp> You'll notice that the 'content' is now below the baselin and so falls off12:25.18 
  <KenSharp> So you need to shift the whole content up by the 'width' of the original page12:25.34 
  <KenSharp> Does thia make any sense ?12:25.39 
artifexirc-bot <KenSharp> lunches12:27.31 
pedr0 yes - but how do I shift the origin ?12:29.12 
  I see, with another cm12:29.29 
artifexirc-bot <Robin_Watts> Or the same cm, just change the last 2 numbers.12:30.55 
  <KenSharp> Back. Yes what Robin said12:56.37 
pedr0 It works, thank you all!13:02.50 
artifexirc-bot <KenSharp> Ah good, glad it worked!13:04.47 
pedr0 I've learned a few things along the way too13:06.33 
 <<<Back 1 day (to 2021/02/24)Forward 1 day (to 2021/02/26)>>> 
ghostscript.com #ghostscript
Search: