question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prevent BlobProvider from being reactive

See original GitHub issue

OS: macOs Mojave 10.14

React-pdf version:@react-pdf/renderer”: “^1.0.0-alpha.19”,

Description: Currently I am using BlobProvider in this way…

{!this.props.loading ?
    <div style={{float:'left'}}>
      {this.props.pdfPrintable ?
         <BlobProvider document={this.generateOrderPDF(this.props.form.getFieldsValue())}>
         {({ url }) => (
            <Button href={url} target="_blank" type="primary" style={{marginRight:'5px'}} className="download-pdf-btn ant-btn btn-secondary ant-btn-primary" loading={false}>Print</Button>
         )}
         </BlobProvider>
      :
         <Button href="#" target="_blank" type="primary" style={{marginRight:'5px'}} className="download-pdf-btn ant-btn btn-secondary ant-btn-primary" loading={true}>Print</Button>
      }
   </div>
: null}

<Button loading={Session.get('processing')} className="btn-secondary" type="primary" htmlType="submit">Save</Button>

Basically, each time I enter any character in any field, or make any selection from a dropdown, or make a radio selection, the PDF is updating. After a lot of trial and error where the PDF was not rendering changes made in fields etc. this was the only way I was able to get everything to work.

After running into countless issues/errors where the PDF would try to update itself while it was already rendered, I had to implement the pdfPrintable state which basically, upon each change in the form, will disable the button, re-render the PDF and enable the button again.

However, this is really not ideal at all, as the whole form/page becomes very laggy because it has to update after every change. It was ok at first but my PDF has become quite complex and it is no longer a viable solution.

What I want is to only render the form when I click the ‘Print’ button. Is this possible?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
serkyencommented, Nov 27, 2018

Thanks @diegomura

I’ve figured it out…

printPDF = () => {
  var obj = pdf(<BlankPDF />).toBlob();
  obj.then(function(blob) {
    var url = URL.createObjectURL(blob);
    window.open(url, '_blank');
  });
}
0reactions
claucarvajalcommented, Aug 3, 2022

Gracias@diegomura

Lo he descubierto…

printPDF = () => {
  var obj = pdf(<BlankPDF />).toBlob();
  obj.then(function(blob) {
    var url = URL.createObjectURL(blob);
    window.open(url, '_blank');
  });
}

Gracias amigo, tengo un pregunta, estoy enviando esto:

const printPDF = async ( descProyecto: string, etapa: string, idSello: number, idTomaDatosSelloCalidad: number ) => { console.log(“entre jiijij —”); var obj = pdf( <GenerarFormatoObra descProyecto={descProyecto} etapa={etapa} idSello={idSello} idTomaDatosSelloCalidad={idTomaDatosSelloCalidad} /> ).toBlob(); obj.then(function (blob) { var url = URL.createObjectURL(blob); window.open(url, “_blank”); }); };

como puede ver envió varios parámetros pero necesito que no se dispare aun el pdf, que espere porq tengo por dentro del documento muchas consultas y al generarlo queda en blanco

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Avoid Being Reactive - Mindsoother Therapy Center
One key strategy to combat these feelings is to avoid being reactive. When we are reactive, we allow events and other people to...
Read more >
6 Ways to Calm Your Reactive Dog - Wags & Wiggles
Being in a crate would lessen their reactivity in the car or ... In addition, avoid eye contact, look away, and remain calm...
Read more >
Page wrapping - React-pdf
If that's not what you need, you can disable this very easily by doing: ... import { BlobProvider, Document, Page } from '@react-pdf/renderer'; ......
Read more >
Reactive Dog Training: Tips To Help Your Dog Get Better
Many went from being quite reactive dogs and having to be separated ... But, of course on the long run we want to...
Read more >
How to Stop Being Reactive - Ray Williams - Medium
How to Stop Being Reactive ... He describes the reactive brain (amygdala and brain stem) as a reptilian brain, which seeks to avoid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found