Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run examples #130

Open
nickfreemandesign opened this issue Mar 10, 2022 · 5 comments
Open

Unable to run examples #130

nickfreemandesign opened this issue Mar 10, 2022 · 5 comments

Comments

@nickfreemandesign
Copy link

Hello! I'm just trying to run some of the examples provided, and I'm not able to build after cloning the repo. The branch is at:

30db112 2022-02-23 | fixes: named Dest, inline image, cittfaxdecode, hex filter, unicode map, removes built in jp2k and jbig2 decoders. changes: ImageXObject handles filters separately now (HEAD -> master, origin/master, origin/HEAD) [Sebastian K]

This may have more to do with me learning rust, but my expectation is i should just be able to clone then cargo build in the root directory. Build log here:

    Updating crates.io index
   Compiling glob v0.3.0
   Compiling pdf_derive v0.1.22 (/Users/freeman/Documents/01-projects/rust-playground/pdf/pdf_derive)
   Compiling pdf v0.7.2 (/Users/freeman/Documents/01-projects/rust-playground/pdf/pdf)
error: there is no argument named `cid`
   --> pdf/src/font.rs:484:70
    |
484 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                ^^^^^

error: there is no argument named `bytes`
   --> pdf/src/font.rs:484:76
    |
484 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                      ^^^^^^^^^

error: there is no argument named `cid`
   --> pdf/src/font.rs:507:74
    |
507 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {unicode_data:?}"),
    |                                                                ^^^^^

error: there is no argument named `unicode_data`
   --> pdf/src/font.rs:507:80
    |
507 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {unicode_data:?}"),
    |                                                                      ^^^^^^^^^^^^^^^^

error: there is no argument named `cid`
   --> pdf/src/font.rs:524:74
    |
524 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                ^^^^^

error: there is no argument named `bytes`
   --> pdf/src/font.rs:524:80
    |
524 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                      ^^^^^^^^^

error: there is no argument named `rows`
   --> pdf/src/enc.rs:362:60
    |
362 |             bail!("decoded length does not match (expected {rows}∙{columns}, got {})", buf.len());
    |                                                            ^^^^^^

error: there is no argument named `columns`
   --> pdf/src/enc.rs:362:67
    |
362 |             bail!("decoded length does not match (expected {rows}∙{columns}, got {})", buf.len());
    |                                                                   ^^^^^^^^^

error: there is no argument named `filter`
   --> pdf/src/enc.rs:395:35
    |
395 |         _ => bail!("unimplemented {filter:?}"),
    |                                   ^^^^^^^^^^

warning: unused import: `std::sync::Arc`
  --> pdf/src/object/mod.rs:25:5
   |
25 | use std::sync::Arc;
   |     ^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `Arc`, `Condvar`, `Mutex`, `RwLock`
 --> pdf/src/file.rs:5:17
  |
5 | use std::sync::{Arc, RwLock, Mutex, Condvar};
  |                 ^^^  ^^^^^^  ^^^^^  ^^^^^^^

warning: unused import: `std::thread::ThreadId`
  --> pdf/src/file.rs:38:5
   |
38 | use std::thread::ThreadId;
   |     ^^^^^^^^^^^^^^^^^^^^^

error: there is no argument named `cid`
   --> pdf/src/font.rs:484:70
    |
484 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                ^^^^^

error: there is no argument named `bytes`
   --> pdf/src/font.rs:484:76
    |
484 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                      ^^^^^^^^^

error: there is no argument named `cid`
   --> pdf/src/font.rs:507:74
    |
507 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {unicode_data:?}"),
    |                                                                ^^^^^

error: there is no argument named `unicode_data`
   --> pdf/src/font.rs:507:80
    |
507 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {unicode_data:?}"),
    |                                                                      ^^^^^^^^^^^^^^^^

error: there is no argument named `cid`
   --> pdf/src/font.rs:524:74
    |
524 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                ^^^^^

error: there is no argument named `bytes`
   --> pdf/src/font.rs:524:80
    |
524 | ...                   Err(e) => warn!("invalid unicode for cid {cid} {bytes:?}"),
    |                                                                      ^^^^^^^^^

error: there is no argument named `rows`
   --> pdf/src/enc.rs:362:60
    |
362 |             bail!("decoded length does not match (expected {rows}∙{columns}, got {})", buf.len());
    |                                                            ^^^^^^

error: there is no argument named `columns`
   --> pdf/src/enc.rs:362:67
    |
362 |             bail!("decoded length does not match (expected {rows}∙{columns}, got {})", buf.len());
    |                                                                   ^^^^^^^^^

error: there is no argument named `filter`
   --> pdf/src/enc.rs:395:35
    |
395 |         _ => bail!("unimplemented {filter:?}"),
    |                                   ^^^^^^^^^^

warning: unused import: `std::sync::Arc`
  --> pdf/src/object/mod.rs:25:5
   |
25 | use std::sync::Arc;
   |     ^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `Arc`, `Condvar`, `Mutex`, `RwLock`
 --> pdf/src/file.rs:5:17
  |
5 | use std::sync::{Arc, RwLock, Mutex, Condvar};
  |                 ^^^  ^^^^^^  ^^^^^  ^^^^^^^

warning: unused import: `std::thread::ThreadId`
  --> pdf/src/file.rs:38:5
   |
38 | use std::thread::ThreadId;
   |     ^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `Substr`
   --> pdf/src/parser/mod.rs:343:28
    |
343 |         use super::lexer::{Substr, Lexer};
    |                            ^^^^^^

error[E0277]: `[f32; 2]` is not an iterator
   --> pdf/src/object/function.rs:151:80
    |
151 |                         let encode = info.encode.unwrap_or_else(|| size.iter().flat_map(|&n| [0.0, (n-1) as f32]).collect());
    |                                                                                ^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
    |
    = help: the trait `Iterator` is not implemented for `[f32; 2]`
    = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]`
    = note: required because of the requirements on the impl of `IntoIterator` for `[f32; 2]`

error[E0599]: the method `collect` exists for struct `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>`, but its trait bounds were not satisfied
   --> pdf/src/object/function.rs:151:115
    |
151 |                         let encode = info.encode.unwrap_or_else(|| size.iter().flat_map(|&n| [0.0, (n-1) as f32]).collect());
    |                                                                                                                   ^^^^^^^ method cannot be called on `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>` due to unsatisfied trait bounds
    |
   ::: /Users/freeman/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/flatten.rs:12:1
    |
12  | pub struct FlatMap<I, U: IntoIterator, F> {
    | ----------------------------------------- doesn't satisfy `_: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `[f32; 2]: IntoIterator`
            which is required by `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>: Iterator`
            `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>: Iterator`
            which is required by `&mut FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>: Iterator`

error[E0277]: `[f32; 2]` is not an iterator
   --> pdf/src/object/function.rs:151:80
    |
151 |                         let encode = info.encode.unwrap_or_else(|| size.iter().flat_map(|&n| [0.0, (n-1) as f32]).collect());
    |                                                                                ^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
    |
    = help: the trait `Iterator` is not implemented for `[f32; 2]`
    = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]`
    = note: required because of the requirements on the impl of `IntoIterator` for `[f32; 2]`

error[E0599]: the method `collect` exists for struct `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>`, but its trait bounds were not satisfied
   --> pdf/src/object/function.rs:151:115
    |
151 |                         let encode = info.encode.unwrap_or_else(|| size.iter().flat_map(|&n| [0.0, (n-1) as f32]).collect());
    |                                                                                                                   ^^^^^^^ method cannot be called on `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>` due to unsatisfied trait bounds
    |
   ::: /Users/freeman/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/flatten.rs:12:1
    |
12  | pub struct FlatMap<I, U: IntoIterator, F> {
    | ----------------------------------------- doesn't satisfy `_: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `[f32; 2]: IntoIterator`
            which is required by `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>: Iterator`
            `FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>: Iterator`
            which is required by `&mut FlatMap<std::slice::Iter<'_, u32>, [f32; 2], [closure@pdf/src/object/function.rs:151:89: 151:113]>: Iterator`

error: aborting due to 11 previous errors; 3 warnings emitted

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `pdf`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to 11 previous errors; 4 warnings emitted

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: build failed
@s3bk
Copy link
Contributor

s3bk commented Mar 10, 2022

I may have used a new feature: https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html#captured-identifiers-in-format-strings

Please check if it works with Rust 1.58

@nickfreemandesign
Copy link
Author

Wonderful @s3bk, I upgraded to latest (1.59) and it compiled successfully.

I was not able to figure out what was meant by the -- <files/{choose a pdf}> part of the command cargo run --example {content,metadata,names,read,text} -- <files/{choose a pdf}> trying several permutations to add a path (relative, absolute, with space between -- without, etc. Hard coding however, managed to work.

I really appreciate your help! No need to take this further, but just to share- my goal is simply to read a PDF and examine its contents. The hope is to have a table within the PDF stored in some vector, but I've little clue how to go about that with your library. If it's worthwhile assisting me to achieve this, I'll be more than glad to help with improving documentation in return.

Either way, this is an issue solved. Cheers

@s3bk
Copy link
Contributor

s3bk commented Mar 11, 2022

The examples are mostly outdated.. unfortunately.

Please check https://github.com/pdf-rs/pdf_render/blob/master/render/examples/trace.rs for text extraction.

@nickfreemandesign
Copy link
Author

Took some time to clone pdf_render but hit a blocker at pdf2image dependency pathfinder_rasterizer (which i assumed was the "pathfinder_rasterize" repo), and ultimately result in not having EGL on my machine (macOS)

 --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: `"pkg-config" "--libs" "--cflags" "egl" "egl >= 1"` did not exit successfully: exit status: 1
  error: could not find system library 'egl' required by the 'khronos-egl' crate

  --- stderr
  Package egl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `egl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'egl' found
  Package egl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `egl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'egl' found
  ', /Users/freeman/.cargo/registry/src/github.com-1ecc6299db9ec823/khronos-egl-4.1.0/build.rs:10:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@s3bk
Copy link
Contributor

s3bk commented Mar 12, 2022

You should be able to run the example from inside the render folder. The egl stuff is only needed for pdf2image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants