vendredi 11 septembre 2015

itext how to check if giant string is present on the pdf page

-I am using the IText plugin to create/read pdfs on my java project. -I am reading multiple text files from any extension(pdf,doc,word etc) and writing their content on a new pdf(all the content of all the files joint together) -To separate each content of each file on the giant pdf, i am always starting a new page, writing the exact path to the file in red at the start of the new page and then writing the content of the file

The problem:

  • I want to write how many pages did the file have on this pdf
  • How do i check if a string is present on the pdf page? I have all the files paths, so i would like to check if any of the paths is written on the page
  • I was following this tutorial to extract the string of any of my pages: http://ift.tt/1ijcmkA
  • But when i extract all the page and check if one if my file paths is present at the page(doing a string.contains(...)), the system doesn't find my file path on the pdf page! I have checked why this happens and when i outputted one page's string, it was like this:

    1. PdfGeneratorForSoftwareRegistration/PdfGeneratorForSoftwareRegistration/ src/br/ufrn/pairg/pdfgenerator/LeitorArquivoTexto.java package br.ufrn.pairg.pdfgenerator;

    import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Scanner;

    public...

When i checked to see if the file path "PdfGeneratorForSoftwareRegistration/PdfGeneratorForSoftwareRegistration/ src/br/ufrn/pairg/pdfgenerator/LeitorArquivoTexto.java" was present at this giant string, the system didn't find it. Can you see the problem? My path is so big that occupies 2 lines! That's the problem!

So, my question is: is there a way to check if a giant string is present on a pdf text using itext plugin?



via Chebli Mohamed

How to get the value of an option in javascript parsing

Good day am having an HTML code in which i intend to get the innerText of a selected option

<div class="bag-option">
<div class="bag-option-label">colour:</div>
<div class="bag-option-control">
    <select name='select-colour-0' id='select-colour-0' onchange="onColourSelected(this, '0', '1', 'style-img-thb-', '_WLG.jpg', '_WXL.jpg', '_SKC.jpg');displayUpdateMsg();return false;">
        <option value="0" selected>orchid pink</option>
    </select>
</div>



via Chebli Mohamed

Can't locate IO/Pty.pm despte it being there

So I try and run my perl script using sudo and I get the following error:

Can't locate IO/Pty.pm in @INC (you may need to install the IO::Pty module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at /usr/local/bin/myscript.pl line 4.

But if I try and install the missing perl module, the following happens:

cpan[2]> install IO::Pty.pm
IO::Pty is up to date (1.12).

I'm not sure what is happening since I clearly have IO/Pty.pm



via Chebli Mohamed

WP - Create collapsable date indented archive list

Right now I have category titles listed by date like this...

01-01 - Cat Title
02-01 - Cat Title 2
02-01 - Cat Title 2
03-01 - Cat Title 3

The working code for this is ...

$posts = get_posts(array(
    'posts_per_page'    => -1,
    'post_type'         => 'post',
    'order'             => 'DESC',
    'orderby'           => 'date',
    'tag'               => 'editorial'
));

if( $posts ): ?>

    <ul>

       <?php  
       foreach( $posts as $post ): setup_postdata( $post ) ?>
          <li> 
          <div>
          <?php
            single_cat_title( '', true );

          ?>
          </div>
          <div>
            <?php echo get_the_date('m-Y');?><?php echo (' - ');?><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
          </div>
          </li> 
       <?php endforeach; ?>

  </ul>

I'd like for the list to look like this when all dates are open...

01-01 - Cat Title
02-01 - Cat Title 2
           - Cat Title 2
03-01 - Cat Title 3

And like this when all dates are closed...
01-01
02-01
03-01

There are plenty of plugins that do this but none that list titles with a specific tag, it would be amazing to have this solved.



via Chebli Mohamed

c# list of unspecified type

I've created a generic search parameter class for reuse in several libraries (see below). I'm trying to find a better way to implement the list of values for each parameter. I will be passing a list of the parameters but inconsistent types for each parameter. I've implemented it as simply an object and will convert to the correct type as necessary in my code, but I feel like there is probably a better way to do this and I'm not coming up with much. Anyone done anything similar or have a suggestion? Thanks!

Generic Abstract Class:

public class SearchParameter<T>
{
    public T Name { get; set; }
    public List<object> Values { get; set; }
}

Inheriting Class:

public enum OrderSearchParameterNames
{
    Barcode,
    DateCompleted,
    DatePlaced,
    OrderStatus,
    UserId
}

public class OrderSearchParameter : SearchParameter<OrderSearchParameterNames>
{
    public OrderSearchParameter(OrderSearchParameterNames name, List<object> values)
    {
        Name = name;
        Values = values;
    }
}

Example of method using the inherited class:

public ApiResponse<OrderWellplate, ApiResponseStatus> SearchOrders(int currentPageIndex, int pageSize, List<OrderSearchParameter> searchParameters, OrderSortParameter sortParameter, out int recordCount)



via Chebli Mohamed

Laravel 5 relationships

I have two tables. Like this

**

user_accounts               usersonglists
--------------              ---------------
id                          id
username                    user_account_id
slug                        etc..
etc..

** I created a route like this

/u/{slug}/songlists

This relation methot in songlist model

public function userAccounts()
{
    return $this->belongsTo('App\Models\User\UserAccounts','user_account_id','id');
}

I created controller methot like this

$songLists = $SongListRepository->getSongListsByUserSlug($slug);

This is getSongListByUserSlug($slug) methot

$songList = $this->model->with('userAccounts')->get();

I want to get songlists by user with $slug.

Can someone help me?



via Chebli Mohamed

changing button image removes skscene

I started my projects as a Spritekit game. Put a button on top of my defaultviewcontroller in storyboard. Presented a scene in viewwilllayoutsubviews.

 if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
            // Configure the view.
            let skView = self.view as! SKView
            self.skView = skView
            skView.showsFPS = true
            skView.showsNodeCount = true

            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.ignoresSiblingOrder = true

            /* Set the scale mode to scale to fit the window */
            scene.scaleMode = SKSceneScaleMode.AspectFill
            println("Width: \(scene.frame.width) andHEight: \(scene.frame.height)")
            scene.gameSceneDelegate = self
            sceneStack.append(scene)
            skView.presentScene(scene)
        }

After some time I transitioned to a new scene through viewcontroller code:

skView.presentScene(scene, transition: transition)

Now the scene changes but the button I had put on view storyboard stays there.. on top of the scene. Now On pressing the button I change the image of button... This surprisingly results in the scene changing back to the previous scene. As a result on changing the buttons any property it results in poping of my new scene and reverts back to the scene I presented initially.



via Chebli Mohamed