Coder Social home page Coder Social logo

pdf_render's People

Contributors

basicinside avatar bellwether-softworks avatar divergentdave avatar efx avatar eijebong avatar ggodlewski avatar nbraud avatar nickelc avatar ploppz avatar s3bk avatar tako8ki avatar zuruuh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pdf_render's Issues

Conflicting packages when using with pdf from crate.io

Tried running the pdf_text example, the cargo build fails pointing out that we are indeed using two different versions of the pdf package. The cargo tree traceback is as follows:

cargo tree --depth 3 | grep 'pdf' 

results in

├── pdf v0.9.0
│   ├── pdf_derive v0.2.0 (proc-macro)
└── pdf_text v0.1.0 (https://github.com/pdf-rs/pdf_text.git#03d4789b)
    ├── font v0.1.0 (https://github.com/pdf-rs/font#9aa9b821)
    │   ├── pdf_encoding v0.4.0
    ├── pdf v0.9.0 (https://github.com/pdf-rs/pdf#b06cfdf1)
    │   ├── pdf_derive v0.2.0 (proc-macro) (https://github.com/pdf-rs/pdf#b06cfdf1)
    ├── pdf_render v0.1.0 (https://github.com/pdf-rs/pdf_render#39a877d3)
    │   ├── font v0.1.0 (https://github.com/pdf-rs/font#9aa9b821) (*)
    │   ├── pdf v0.9.0 (https://github.com/pdf-rs/pdf#b06cfdf1) (*)
    │   ├── pdf_encoding v0.4.0 (*)

This can avoided by using mulitple locations feature for

pdf = { path = "../pdf/pdf", default-features=false }

to

 pdf = { path = "../pdf/pdf", default-features=false, version = "0.9.0" }

I am very new to rust 🦀, please let me know if I missed anything.

Some PDF render blank

This happens with multiple files. I'm testing with PDF files that contain embedded raster images. Some of them seem to work fine though.

[HELP ME] When using `pdf_render` outside, build error occurred.

This line, cargo said that points is private.

let clip_polygon = outer_contour.points();

Build error is occurred.

error[E0599]: no method named `points` found for reference `&Contour` in the current scope
  --> /root/.cargo/git/checkouts/pdf_render-56211f49c16f7190/a57d54f/render/src/graphicsstate.rs:83:50
   |
83 |                 let clip_polygon = outer_contour.points();
   |                                                  ^^^^^^ private field, not a method

For more information about this error, try `rustc --explain E0599`.
error: could not compile `pdf_render` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

I think this error is meaning using pub(carte) item. let see below.
https://github.com/s3bk/pathfinder/blob/bb4792c3b04be6bc05848534dc924946d60fd142/content/src/outline.rs#L44

Please, help me.

Wrong transparency on Backend.draw

PDF: https://arxiv.org/pdf/2002.10413.pdf
Page: 3 (0 indexed)

pdf-render
image
pdf-js
image

The differences are the thick edges (transparency) and the small arrows (position). You can find the call for the left thick edge on the first Backend.draw (matrix(0.87888 0 0 0.87888 127.801 71.99902)), and the arrow (in front of "standard message") has a transformation matrix of matrix(0.87888 0.18372811 -0.18372811 0.87888 127.801 71.99902).

build failed

--- 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

Unable to run pdf2image

When I am doing "cargo run" in the examples/pdf2image directory, I get:

error[E0277]: the trait bound `pdf::file::File<Vec<u8>, NoCache, NoCache, NoLog>: Resolve` is not satisfied
  --> examples/pdf2image/src/main.rs:40:31
   |
40 |     render_page(&mut backend, &file, &page, Transform2F::from_scale(opt.dpi / 25.4))?;
   |     -----------               ^^^^^ the trait `Resolve` is not implemented for `pdf::file::File<Vec<u8>, NoCache, NoCache, NoLog>`
   |     |
   |     required by a bound introduced by this call
   |
   = help: the trait `Resolve` is implemented for `NoResolve`
note: required by a bound in `render_page`
  --> /home/nathan/projects/external/pdf-rs/pdf_render/render/src/lib.rs:81:63
   |
81 | pub fn render_page(backend: &mut impl Backend, resolve: &impl Resolve, page: &Page, transform: Transform2F) -> Result<Transform2F, PdfError> {
   |                                                               ^^^^^^^ required by this bound in `render_page`

For more information about this error, try `rustc --explain E0277`.
warning: `pdf2image` (bin "pdf2image") generated 1 warning
error: could not compile `pdf2image` (bin "pdf2image") due to previous error; 1 warning emitted

am I compiling it wrong? But this error should be independent of that ...

Sample fonts.json request

What is the structure of fonts.json ? Could you please post a sample fonts.json somewhere ?

I am getting the following error.

PDF: STANDARD_FONTS not set. using fonts/ instead.
thread 'main' panicked at 'can't read fonts.json: Os { code: 2, kind: NotFound, message: "No such file or directory" }', render/src/font.rs:55:68
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1749:5
   3: core::result::Result<T,E>::expect
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1022:23
   4: pdf_render::font::StandardCache::new
             at /Users/omkarpatil/experiments/ghostscript/pdf_render/render/src/font.rs:55:20
   5: pdf_render::cache::Cache::new
             at /Users/omkarpatil/experiments/ghostscript/pdf_render/render/src/cache.rs:54:18
   6: pdf2image::main
             at ./src/main.rs:37:21
   7: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Font license

MIT license but some or all fonts you say to use have a license (GPL) that is extremely incompatible with permissively licensed software.
There is an exception for embedding in a document but not for use in an application.

strings d050000l.pfb | head -10
%!PS-AdobeFont-1.0: Dingbats 001.005
%%CreationDate: Tue Oct 19 1999
% Copyright URW Software, Copyright 1997 by URW
% URW Software, Copyright 1997 by URW
% See the file COPYING (GNU General Public License) for license conditions.
% As a special exception, permission is granted to include this font
% program in a Postscript or PDF file that consists of a document that
% contains text to be displayed or printed using this font, regardless
% of the conditions or license applying to the document itself.
12 dict begin

The 14 Adobe fonts are free to embed but not to use in software as well.

There are likely metric compatible fonts which have a legitimate license.

Does not compile

Hi, I'm trying to compile this project with cargo +nightly build --bin view --release but I get the following errors:

error[E0432]: unresolved import `pdf::font::ToUnicodeMap`
 --> render/src/fontentry.rs:4:42
  |
4 | use pdf::font::{Font as PdfFont, Widths, ToUnicodeMap};
  |                                          ^^^^^^^^^^^^ no `ToUnicodeMap` in `font`

error[E0432]: unresolved import `pdf::content::TextDrawAdjusted`
 --> render/src/renderstate.rs:7:5
  |
7 | use pdf::content::TextDrawAdjusted;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `TextDrawAdjusted` in `content`

error[E0599]: no method named `transpose` found for enum `Option<&pdf::object::Stream>` in the current scope
  --> render/src/fontentry.rs:29:52
   |
29 |         let mut to_unicode = pdf_font.to_unicode().transpose().unwrap();
   |                                                    ^^^^^^^^^ method not found in `Option<&pdf::object::Stream>`
   |
   = note: the method was found for
           - `Option<Result<T, E>>`

Which looks like there are some missing types in the pdf library, even though I'm using the same Cargo.lock from master.

Program crashes on Book

I tried to test this out on a book (first pdf file I tried). The first three pages where fine, but on the fourth page I got this:

    Finished release [optimized] target(s) in 0.16s
     Running `target/release/view /home/daniel/docs/code/go.pdf`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Try { file: "render/src/renderstate.rs", line: 227, column: 29, context: Context([]), source: Other { msg: "expected 3 color arguments, got [Number(0.061)]" } }', /home/daniel/proj/rs-pdf/pdf_render/view/src/lib.rs:47:76
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   3: <pdf_view::PdfView<B> as pathfinder_view::view::Interactive>::scene
   4: pathfinder_view::show::show::{{closure}}
   5: winit::platform_impl::platform::x11::EventLoop<T>::run_return
   6: pathfinder_view::show::show
   7: view::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
missing fonts:

Here's a full backtrace:

stack backtrace:
   0:     0x558f8e172a3d - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x558f8e172a3d - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x558f8e172a3d - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x558f8e172a3d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x558f8e19523c - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x558f8e16f891 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x558f8e174515 - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x558f8e174515 - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x558f8e174515 - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x558f8e1741c9 - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x558f8e174a62 - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:698:17
  11:     0x558f8e174947 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x558f8e172ef4 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x558f8e174679 - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x558f8dc768f3 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x558f8dc769e3 - core::result::unwrap_failed::hddd78f4658ac7d0f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
  16:     0x558f8de1e786 - <pdf_view::PdfView<B> as pathfinder_view::view::Interactive>::scene::h8b7dd69dfdb0b391
  17:     0x558f8de23fb8 - pathfinder_view::show::show::{{closure}}::h547afd43c791e3d8
  18:     0x558f8de16ce7 - winit::platform_impl::platform::x11::EventLoop<T>::run_return::h8241d74d0f13d5c5
  19:     0x558f8dc7eef9 - pathfinder_view::show::show::h1903cbab3e784b5a
  20:     0x558f8dd590ce - view::main::h6329ec99029927c8
  21:     0x558f8dd65133 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc0669745f611c36c
  22:     0x558f8dce7b09 - std::rt::lang_start::{{closure}}::h55713de905b4b591
  23:     0x558f8e169cae - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::had4f69b3aefb47a8
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:259:13
  24:     0x558f8e169cae - std::panicking::try::do_call::hf2ad5355fcafe775
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  25:     0x558f8e169cae - std::panicking::try::h0a63ac363423e61e
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  26:     0x558f8e169cae - std::panic::catch_unwind::h18088edcecb8693a
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  27:     0x558f8e169cae - std::rt::lang_start_internal::{{closure}}::ha7dad166dc711761
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
  28:     0x558f8e169cae - std::panicking::try::do_call::hda0c61bf3a57d6e6
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  29:     0x558f8e169cae - std::panicking::try::hbc940e68560040a9
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  30:     0x558f8e169cae - std::panic::catch_unwind::haed0df2aeb3fa368
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  31:     0x558f8e169cae - std::rt::lang_start_internal::h9c06694362b5b80c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  32:     0x558f8dd59242 - main
  33:     0x7f7aad3d9290 - <unknown>
  34:     0x7f7aad3d934a - __libc_start_main
  35:     0x558f8dc76b95 - _start
                               at /build/glibc/src/glibc/csu/../sysdeps/x86_64/start.S:115
  36:                0x0 - <unknown>

I get the message "missing fonts:", so it looks like the font instructions don't provide all of the fonts necessary to view my desired content. This should be easy to fix with some extra fonts right? I noticed that there's a download_fonts.sh file but it doesn't generate the fonts.json file needed by pathfinder or whatever it's called so I'm not sure what that's for.

Please let me know of a solution because I need to make a pdf viewer and if this doesn't work then I'll have to do it in C++.

Not compiling

Hi, I'm getting this when I'm trying to compile. Please help.

Caused by:
failed to read C:\Users\user\projects\pathfinder_rasterize\Cargo.toml

cargo run error

error[E0432]: unresolved import winit::platform::unix
--> /Users/ihoey/.cargo/git/checkouts/pathfinder_view-e3bb902cdb8b6e4b/559f5cc/src/show.rs:13:58
|
13 | use winit::platform::{run_return::EventLoopExtRunReturn, unix::EventLoopExtUnix};
| ^^^^ could not find unix in platform

error[E0599]: no function or associated item named new_any_thread found for struct EventLoop<_> in the current scope
--> /Users/ihoey/.cargo/git/checkouts/pathfinder_view-e3bb902cdb8b6e4b/559f5cc/src/show.rs:78:37
|
78 | let mut event_loop = EventLoop::new_any_thread();
| ^^^^^^^^^^^^^^ function or associated item not found in EventLoop<_>

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try rustc --explain E0432.
error: could not compile pathfinder_view due to 2 previous errors

PDF Rendering issues

Hey,

I just tried this out with a random PDF from my download folder, and there seem to be a couple of issues: https://leica-camera.com/sites/default/files/pm-73760-Leica-SL2_Technical-Data_en.pdf

First page (pdf_render, evince):

image

image

The first issue is in the title. Analyzing the PDF in Master PDF editor, one can see that there is the text "DAS WESENTLICHE" but with clipping path and white font behind the "LEICA SL2" text. So the clipping did not work in pdf_render.

The technical drawings are also present thrice, but two copies are clipped (I think).

Another image (pdf_render, evice):
image

image

In this picture, I see two issues: Missing special characters (e.g. TM), and missing gray outlines of text hanging over the gray box. These outlines are created by "Stroke Text" (opposed to normal "Fill Text", at least that is term Master PDF uses).

image

The camera body is too dark (the texture is still there, but I have to increase brightness to see it). Also, there is a gray line around the left and top border of the image (not visible at every zoom level).

zoomed out (pdf_render, evice):

image

image

I think when you zoom out far, you are supposed to render certain lines at a width of at least 1px per PDF specification.

spaces aren't written to TextSpan: text

if is_space {
let advance = self.word_space * self.horiz_scale + width;
self.text_matrix = self.text_matrix * Transform2F::from_translation(Vector2F::new(advance, 0.));
span.width += advance;
continue;
}

I presume a span.text.push(' '); is missing here. Adding it fixes the lack of spaces for me, but I am not sure if its the correct way.

Support Unicode CJK CMap

There are a lot of CJK CMaps, but some of them are just Utf16-BE. We can check the prefix of unknown encoding and treat the encoding begin with Uni as Utf16-BE.
Here are some information from pdf v1.5 spec p404
image
image

// fontentry.rs
let source_encoding = match base_encoding {
    Some(BaseEncoding::StandardEncoding) => Some(Encoding::AdobeStandard),
    Some(BaseEncoding::SymbolEncoding) => Some(Encoding::AdobeSymbol),
    Some(BaseEncoding::WinAnsiEncoding) => Some(Encoding::WinAnsiEncoding),
    Some(BaseEncoding::MacRomanEncoding) => Some(Encoding::MacRomanEncoding),
    Some(BaseEncoding::MacExpertEncoding) => Some(Encoding::AdobeExpert),
    ref e => {
        // we can do the check here, return AdobeStandard if matches.
        warn!("unsupported pdf encoding {:?}", e);
        None
    }
};

Panic when running `view` without any arguments

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', view/src/bin/view.rs:11:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error should be clearer, e.g. "You must provide path to pdf to view"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.