Coder Social home page Coder Social logo

Comments (5)

J-F-Liu avatar J-F-Liu commented on August 26, 2024

Thanks for trying lopdf, which example are you using, the one in readme file?
You can upload your PDF to https://paste.rs/

curl --data-binary @file.txt https://paste.rs/

BTW, field_init_shorthand will be available in Rust 1.17.

from lopdf.

fschutt avatar fschutt commented on August 26, 2024

I'm sorry, GitHub didn't want me to attach files. The file is available at: https://paste.rs/ztf

I created a new project, copy-pasted the code from the README, hit cargo run. This is the result:

%PDF-1.5
1 0 obj<</Type/Pages/Kids[5 0 R]/Count 1/Resources 3 0 R/MediaBox[0 0 595 842]>>endobj
2 0 obj<</Type/Font/Subtype/Type1/BaseFont/Courier>>endobj
3 0 obj<</Font<</F1 2 0 R>>>>endobj
4 0 obj<</Length 45>>stream
BT
/F1 48 Tf
100 600 Td
(Hello World!) Tj
ET
endstream endobj
5 0 obj<</Type/Page/Parent 1 0 R/Contents[4 0 R]>>endobj
xref
0 6
0000000000 65535 f 
0000000009 00000 n 
0000000096 00000 n 
0000000155 00000 n 
0000000191 00000 n 
0000000281 00000 n 
trailer
<</Root<</Type/Catalog/Pages 1 0 R>>/Size 6>>
startxref
338
%%EOF

There are some things that I wanted to note: Usually, a PDF file has several high-bit characters on the second line, like this:

%PDF-1.4
%¥±ë
1 0 obj

It doesn't change anything if I add these characters, though. I also wanted to note that this only appears in the default Linux PDF viewer (I think it is called Risetto). pdftk even crashes on this file and Chrome does not want to display it either.

There is certainly something wrong with it, however it displays fine in Adobe Reader.

from lopdf.

fschutt avatar fschutt commented on August 26, 2024

Just for reference, here is a very similar PDF that is displaying well on all browsers / PDF viewers:

%PDF-1.1
%¥±ë

1 0 obj
  << /Type /Catalog
     /Pages 2 0 R
  >>
endobj

2 0 obj
  << /Type /Pages
     /Kids [3 0 R]
     /Count 1
     /MediaBox [0 0 300 144]
  >>
endobj

3 0 obj
  <<  /Type /Page
      /Parent 2 0 R
      /Resources
       << /Font
           << /F1
               << /Type /Font
                  /Subtype /Type1
                  /BaseFont /Times-Roman
               >>
           >>
       >>
      /Contents 4 0 R
  >>
endobj

4 0 obj
  << /Length 55 >>
stream
  BT
    /F1 18 Tf
    0 0 Td
    (Hello World) Tj
  ET
endstream
endobj

xref
0 5
0000000000 65535 f 
0000000018 00000 n 
0000000077 00000 n 
0000000178 00000 n 
0000000457 00000 n 
trailer
  <<  /Root 1 0 R
      /Size 5
  >>
startxref
565
%%EOF

see https://brendanzagaeski.appspot.com/0004.html

from lopdf.

J-F-Liu avatar J-F-Liu commented on August 26, 2024

zathura can open this file, the reason of other readers is that they don't allow Catalog as an direct object in trailer.
I updated my example code now.

from lopdf.

fschutt avatar fschutt commented on August 26, 2024

Yup, seems to work now, thanks for making this library.

from lopdf.

Related Issues (20)

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.