Inverted colors when printing to PDF on iOS

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Inverted colors when printing to PDF on iOS

Post by joel.epsteinBUS31vi » Tue May 05, 2015 3:41 am

Okay, this is a ridiculously vexing one for me. I'd appreciate any advice you might be able to provide.

In the process of using the app, the user can create a drawing. At a later point in the app, the user can compile the drawings to a PDF. This is working fine except for one small problem.

The drawings have a white background, a black silhouette, and different colored lines on top of the black. These drawings are saved as expected. I verified this in the simulator, by digging into the directories. So far, all is well.

But the problem comes when I print to PDF.

When I do that, the image gets compiled to the PDF. And in those images, the white appears as white, the black appears as black, but the colors are inverted. I've attached an image that demonstrates what I'm seeing. Another thing I've noticed is that the image has a black border, even though I've specified it not to show the border.
example.jpg
And here's my code.

Code: Select all

on mouseUp
   answer "Please tap OK and then wait while report is compiled"
   lock screen
   put number of lines of field "customDates" into tHowMany
   
   repeat with i=1 to tHowMany
      clone card "templateCard"
      set the name of this card to "Diary - " & i   
      
      put line i of field "customDates" of card "PainCalendar" into tLine
      
      put replaceText(tLine,"/","-") into tLine
      put replaceText(tLine,tab,"-") into tLine
      
      put tLine&"Small.jpg" into tPix
      put tLine&".txt" into tTxt
      
      put specialfolderpath("documents")&"/"&tTxt into tTxt
      
      put url ("file:" & tTxt) into tTxt
      
      put line 1 of tTxt into word 3 of field "cardTitle"
      put line 2 of tTxt into field "startTime"
      put line 3 of tTxt into field "endTime"
      put line 4 of tTxt into field "notesField"
      
      set the filename of image "smallSilhouette" to specialfolderpath("documents")&"/"&tPix
      set the angle of image "smallSilhouette" to 90
      
      set the rect of image "smallSilhouette" to "0,0,300,600"
      
   end repeat
   
   put specialFolderPath("documents") & "/MyPainDiary.pdf" into tPDFPath
   
   open printing to pdf tPDFPath
   if the result is "Cancel" then
      exit mouseUp
   else
      repeat with i=1 to tHowMany
         put "Diary - " & i into tCard
         print card tCard of this stack into 0,0,550,367
         print break
      end repeat
   end if
   close printing
   
   repeat with i=1 to tHowMany
      delete card ("Diary - " & i) 
   end repeat
   
   unlock screen
   visual effect scroll left very fast
   go card "report"
end mouseUp
I'd appreciate it if you could tell me what I've done wrong.

Thanks so much.

joel

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Inverted colors when printing to PDF on iOS

Post by joel.epsteinBUS31vi » Tue May 05, 2015 1:32 pm

I've been continuing to mess with this and have made an additional discovery.

The image on the PDF is not actually reversed. In the example above, you see that the original drawing was black with a red line on top. The image in the PDF was black with a blue line. But when I took this all into Photoshop, to see if things were actually just getting reversed out, I see that the inverse of that original red is NOT the blue color that shows up on the PDF.

That seems even odder to me. Perhaps it will provide a clue for you.

I'd be ever so grateful for any advice.

Thanks so much.

Joel

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Inverted colors when printing to PDF on iOS

Post by joel.epsteinBUS31vi » Wed May 06, 2015 12:57 am

Continuing to make some progress in trying to figure this out.

But I'm still flummoxed and would really appreciate some help.

Here's what I've found out:
- exporting a snapshot to jpg works just fine
- importing a the same jpg snapshot works just fine
- BUT... printing this imported jpg to PDF causes the RGB values of the image to be reversed
- other images on the card are imported correctly

This is when working on either LiveCode 7.0.3 or 7.0.5 (rc2) and iOS 8.1 or iOS 8.3

At this point, I'm quite certain that this is not an anomaly - I've created the attached sample stack that demonstrates the problem.
testPDF.livecode.zip
(33.62 KiB) Downloaded 245 times
I'd appreciate it if someone could help me find a solution to this problem.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Inverted colors when printing to PDF on iOS

Post by jacque » Wed May 06, 2015 6:07 pm

Sounds like a bug to me. I'd report it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Inverted colors when printing to PDF on iOS

Post by joel.epsteinBUS31vi » Wed May 06, 2015 6:16 pm

Thanks. I have. I appreciate your advice.

Joel

Post Reply