usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.39k stars 1.26k forks source link

Spacing problem with PDF preview #2696

Open gbouget opened 3 months ago

gbouget commented 3 months ago

I have checked the following:

Describe the bug

There is a spacing like a "padding-left" in PDF preview. When i use others tools, the render is fine.

Version : 1.22.0

Attachment:

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Its-treason commented 3 months ago

Hey, I downloaded the "body_response_pdf_binary.log" but Firefox only shows a Blank page after renaming it to .pdf and opening it. Maybe it could be corrupt during the upload. Could you upload the file again? You can upload .pdf directly to GitHub without changing the file extension.

gbouget commented 3 months ago

I've updated a lot of the code in my application and database. However, I used an online tool to convert the base 64 into a binary file (https://base64.guru/converter/decode/file). The PDF in base64 format is saved in the attribute named “content” in the body_response.json file.

result.pdf

Its-treason commented 3 months ago

Thank you, I can reproduce it with your PDF. It looks like s small style issue (Canvas is moved the to right, but Text layer not), but it could be a problem with the library.

gbouget commented 3 months ago

Rendering is correct if the parent frame is not too large (01.PNG). Otherwise, there's a mitchmatch (02.PNG).

Perhaps theses styles (https://github.com/usebruno/bruno/issues/970)?

    case 'preview-pdf': {
      return (
        <div className="preview-pdf" style={{ height: '100%', overflow: 'auto', maxHeight: 'calc(100vh - 220px)' }}>
          <Document file={`data:application/pdf;base64,${dataBuffer}`} onLoadSuccess={onDocumentLoadSuccess}>
            {Array.from(new Array(numPages), (el, index) => (
              <Page key={`page_${index + 1}`} pageNumber={index + 1} renderAnnotationLayer={false} />
            ))}
          </Document>
        </div>
      );
    }

01 02