omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. CastroSATT
    3. Posts

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 14
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by CastroSATT

    • RE: File parts error running apps via home shorcut

      Looks like that would work not sure how to implement it if you got any clues a am full beginnerish

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: File parts error running apps via home shorcut

      Cool

      Here’s a snippet really it’s for reading and writing the ini file

      For example Same command used but for the sound fx

      def SoundFx(N):
      	if N == 1:
      		# Honour position of phone silent switch  
      		sound.set_honors_silent_switch(True)
      		# sets volume 
      		sound.set_volume(1.0)
      		#preloads 
      		sound.load_effect('./RR/img/hadouken.mp3')
      		#sample to be played when imaged pressed
      		sound.play_effect('./RR/img/hadouken.mp3')
      		vibrate()
      
      
      posted in Pythonista
      CastroSATT
      CastroSATT
    • File parts error running apps via home shorcut

      Hiya guys taking a break from the pdf issue I had,, I think I found a solution but it’s on a take me a week or so to implement... so on to the easier issue

      I have an app that uses a load of subvies etc also uses a few folder for templates and invoices also got a folder for sound effects banners etc

      No the issue is works fine when I run the script from within pythonista... but if I run from shortcut straight into the app I get file not found errors it’s almost as if the app can not see its file paths

      And help would be great

      This is a pic of the error

      [https://drive.google.com/file/d/1KyJGl9R7DdBXhh1JRl45r34mAXsEhhhT/view?usp=drivesdk](link url)

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      Still having a barney

      -Tried your original template works
      -Tried your template altered on 2 other form makers and they then have the issue after that

      Weird so now gonna
      Start with a blank form and 1 text box each see what happens then

      I think the issue has something to do with the NONE

      -When using pdfscrape I get 1 none (needs more testing)

      -Using pdfelement 6 pro I get 2 none one and the top 2nd at the end
      —Maybe something to do with the water mark provided by the software, I am reaching.

      Both using your working template (which has NO none)

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      Yeah might be gonna download a demo of adobe try and remake the template not sure how to get rid of that none from there thanks so much will post an update in a few I’ve been using pdfscape to make the template and the template source (years ago) has been played with a few time after the years so maybe conflicts there some where but your right

      Seems to work ok with that test one although would preferred to be uneditable but 1 thing at a time me thinks

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      thanks for the help it’s on my snagging list

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      So this is a complete template as you can see clean but after processing

      This is what it looks like

      Name and first line of address only
      after processing

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      Sorry still no go it makes the pdf but adds my dictionary to the form which is perfect
      I just can’t make the text read only so everyone can see it even In preiview mode

      Template PDF

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      @cvp sorry when I said didn’t work I meant it kinda of worked the issue is it made the pdf but still with editable forms and not ready only it’s weird

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Issue with flattening PDF

      didn’t work gives me me a pdf with the replaced same issue

      posted in Pythonista
      CastroSATT
      CastroSATT
    • Issue with flattening PDF

      Hiya guys got an issue need to use obvs in pure python to fill out a pdf form then flatten it as apprantly that’s how you make the form uneditable having really big issue I just can’t get it done

      So now here’s the question how do I take the output stream and save it as a pdf

      from io import BytesIO
      import PyPDF2
      from PyPDF2.generic import BooleanObject, NameObject, IndirectObject, NumberObject
      
      def set_need_appearances_writer(writer):
          # basically used to ensured there are not 
          # overlapping form fields, which makes printing hard
          try:
              catalog = writer._root_object
              # get the AcroForm tree and add "/NeedAppearances attribute
              if "/AcroForm" not in catalog:
                  writer._root_object.update({
                      NameObject("/AcroForm"): IndirectObject(len(writer._objects), 0, writer)})
      
              need_appearances = NameObject("/NeedAppearances")
              writer._root_object["/AcroForm"][need_appearances] = BooleanObject(True)
      
      
          except Exception as e:
              print('set_need_appearances_writer() catch : ', repr(e))
      
          return writer  
      
      
      
      
      # open the pdf
      input_stream = open("JMA.pdf", "rb")
      pdf_reader = PyPDF2.PdfFileReader(input_stream, strict=False)
      if "/AcroForm" in pdf_reader.trailer["/Root"]:
          pdf_reader.trailer["/Root"]["/AcroForm"].update(
              {NameObject("/NeedAppearances"): BooleanObject(True)})
      
      pdf_writer = PyPDF2.PdfFileWriter()
      set_need_appearances_writer(pdf_writer)
      if "/AcroForm" in pdf_writer._root_object:
          # Acro form is form field, set needs appearances to fix printing issues
          pdf_writer._root_object["/AcroForm"].update(
              {NameObject("/NeedAppearances"): BooleanObject(True)})
      
      #data_dict = dict() # this is a dict of your form values
      
      data_dict = {
         'name': 'Jason allen',
         'addressf': 'Test address',
         }
      
      pdf_writer.addPage(pdf_reader.getPage(0))
      page = pdf_writer.getPage(0)
      # update form fields
      pdf_writer.updatePageFormFieldValues(page, data_dict)
      for j in range(0, len(page['/Annots'])):
          writer_annot = page['/Annots'][j].getObject()
          for field in data_dict:
              if writer_annot.get('/T') == field:
                  writer_annot.update({
                      NameObject("/Ff"): NumberObject(1)    # make ReadOnly
                  })
      output_stream = BytesIO()
      pdf_writer.write(output_stream)
      
      # output_stream is your flattened pdf
      
      print(output_stream)
      
      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: mypy does not install

      Hiya I will say you can run stash under python 3.6 or what ever it is . just press go on the stash script it will show errors but I have found it to generally work if not manual install sorry dude and if there’s some c bits then it won’t work

      posted in Pythonista
      CastroSATT
      CastroSATT
    • RE: Webview , google api calendar 403 user agent issue

      Sorry dude need it plainer than that

      So I saw the function but have no real idea on how to use this in conjunction with the test script

      Either to do auth in another browser then hope it keeps that auth for google cal api
      (I tried cut/paste with link ) got further but I think it saves an auth file which is meant to alter the cred.jsn or be saved along side
      So when I went back into pythonista same error if feels like iam missing something

      It feels like I have to change user agent of the webview/in built browser on pythonista It self not the code BUT the work around allows you to temp specify a user agent by adding the function to the google test script

      If that’s the case I’m not sure where to go next “I am the idiot”

      posted in Pythonista
      CastroSATT
      CastroSATT
    • Webview , google api calendar 403 user agent issue

      Guys I’m like 3 weeks into learning python already built a BTC balance checker for an arcade machine with Arduino

      So I’m kind of in love with pythonista....

      Now for my next trick

      I want to parse a CSV file then pipe the contents into a google calendar etc etc
      After a time I found a solution to get real-time data rather than a saved CSV file so until I get that platform sorted I wanted to try and learn how to play with the google calendar... which is one half of the quest

      So here’s the issue

      Loaded python google bits as per instructions

      Loaded up all the requirements and it’s seems to be working

      -Using the standard Calendar QuickStart.py

      The issue is I get a warning about please visit this url to auth

      -click link

      Brings me to pythonista web view

      • brings up and error 403
      1. That’s an error.

      Error: disallowed_useragent

      Google can’t sign you in safely inside this app. You can use Google sign-in by visiting this app’s website in a browser like Safari or Chrome.

      • so I gatherd that’s it’s the user agent issue with pythonista and webview

      So heres the question what do I do to clear it

      Is it pythonista that’s needs to change or the scripts or an edit to the google python module

      I will need this to obvs work all platforms ish

      Also a decent explanation of what’s going on and where the issue

      Please reply like I’m an idiot as I said, I’m super new to python but I am an all round tech so not completely useless

      Thanks guys

      posted in Pythonista
      CastroSATT
      CastroSATT