Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for Elefy
| Type | On... | Excerpt | Status | Date |
|---|---|---|---|---|
| Comment | Post #296311 |
Hi @#56855, the main reason for this answer was simply to say 'use headless mode to force a download of the PDF', but you're right about the example not being very useful (I couldn't really share it unfortunately as it involved logging into an intranet).
If I find myself using this again for ... (more) |
— | 2 months ago |
| Edit | Post #296318 |
Post edited: |
— | 3 months ago |
| Edit | Post #296318 | Initial revision | — | 3 months ago |
| Answer | — |
A: Download a PDF file in Playwright instead of opening it in a new tab when clicking on its link This is as much as I was able to shorten it (it downloads all the visible links with `\nTitle` in their text): ```ts import { chromium } from 'playwright'; (async () => { const browser = await chromium.launch(); const context = await browser.newContext({ storageState: 'loggedInState.json... (more) |
— | 3 months ago |
| Edit | Post #296311 |
Post edited: |
— | 3 months ago |
| Edit | Post #296312 | Initial revision | — | 3 months ago |
| Answer | — |
A: Download a PDF file in Playwright instead of opening it in a new tab when clicking on its link Since this is a Q&A site and it took me hours to figure out this small detail actually works, here is my working code in the hope this saves future users a lot of fruitless searching: ```js const { chromium } = require('playwright'); // Use 'playwright' instead of '@playwright/test' (async... (more) |
— | 3 months ago |
| Edit | Post #296311 | Initial revision | — | 3 months ago |
| Question | — |
Download a PDF file in Playwright instead of opening it in a new tab when clicking on its link My organisation uses Moodle as their online e-learning system on which teachers share resources, and oftentimes numerous documents that we need to view/download are posted there. The default way of attaching documents (which is what everyone ends up using) requires the recipient to `ctrl`-click o... (more) |
— | 3 months ago |
| Comment | Post #296285 |
their own instance, [posting an issue on GitHub](https://github.com/codidact/qpixel/issues/) will definitely improve the visibility of this post and fix a search bug which is likely to affect and/or disrupt many users. (more) |
— | 3 months ago |
| Comment | Post #296285 |
Now that we have access to [data dumps](https://software.codidact.com/data) as well as the [website source code](https://github.com/codidact/qpixel), we should be able to reproduce this on our own machines to allow debugging and fixing it easier. For now I have yet to get `qpixel` up and running ... (more) |
— | 3 months ago |
| Comment | Post #296274 |
You're right: `em` won't parse, at least inside `margin`, but `in` will, so what worked in the end was
```js
await page.pdf({path: "khan.pdf", format: "A4", scale: 0.8, margin: { top: "3in", right: "1in", bottom: "3in", left: "1in"}, outline:true, tagged:true});
```
I also noticed from https:... (more) |
— | 3 months ago |
| Comment | Post #296274 |
Ah yes, that is it. I also tried `await page.pdf({path: "khan.pdf", format: "A4", scale: 0.8, margin: { top: "3", right: "1", bottom: "3", left: "1"}, outline:true});` to add margins and an outline, but both of those silently failed for some reason... (more) |
— | 3 months ago |
| Comment | Post #296274 |
@ggorlen thank you, it works great!
My only concern is: can we tell Playwright when to page break inside your script so that it outputs A4 sheets?
From my testing, changing any `height`-related variable in this code will not work as it is currently 'slurping' up the entire page to feed in... (more) |
— | 3 months ago |
| Edit | Post #296260 |
Post edited: |
— | 3 months ago |
| Edit | Post #296260 |
Post edited: |
— | 3 months ago |
| Edit | Post #296260 |
Post edited: |
— | 3 months ago |
| Edit | Post #296260 | Initial revision | — | 3 months ago |
| Question | — |
Playwright script to generate PDF of a page that requires scrolling (Khan Academy) Currently I am using One Click Page to PDF to get the job done, although the lack of working open-source tools fit for this task has led me to creating my own; the web page "that won't print" is this Khan Academy article. It seems as though I have 2 options, both involving Playwright: A. (S... (more) |
— | 3 months ago |
